Challenge
Undo and history
…and record every change that actually happens as (action, item, mass) : ("add", "CG-0042", 18.5) or ("remove", "CG-0042", 18.5) . Refused commands change nothing, so they aren't recorded. Add a…
Showing 31–40 of 56
Challenge
…and record every change that actually happens as (action, item, mass) : ("add", "CG-0042", 18.5) or ("remove", "CG-0042", 18.5) . Refused commands change nothing, so they aren't recorded. Add a…
Challenge
…the same, then add a fourth tank with a single list item and list the low tanks.
Challenge
Print each sensor name with its reading by looping over two lists together with zip(), then add a third list of units and warn when the lists don't have the same length, since zip() quietly stops at…
Challenge
readings[5] on a list of five readings stops with an IndexError. Predict it, work out the valid indexes with len(), fix it with [-1], then print the first, middle and last readings for any length.
Example
Adding and removing elements from a set. Basic set operations.
Quiz
A set keeps each item only once and in no particular order: the moons a probe has already photographed, the tools a rover carries, the planets two missions have visited. That makes sets the quickest…
Quiz
…the front and the back, slicing, len() and in Changing items, append() , insert() and extend() Removing items with pop() and remove() sort() vs sorted() , min() , max() and sum() Copying a list, and…
Example
For loop iterates through sequence elements. Basic iteration over lists.
Challenge
…missing eva_certified needed <= granted is True when every item of needed is in granted . needed - granted is what's missing. Every action The control panel shows every airlock action at once. ACTIONS…
Quiz
…a tuple is made, you cannot add, remove or replace its items. This free quiz has 15 short questions on creating, reading and unpacking tuples in Python, on what you can and cannot do with them, and on…