Quiz
Python Return Values Quiz
…Leaving a function early with return : inside an if , a loop or nested loops Using a returned value straight away, and returning one of two values with a conditional expression How it works 15…
Showing 11–20 of 57
Quiz
…Leaving a function early with return : inside an if , a loop or nested loops Using a returned value straight away, and returning one of two values with a conditional expression How it works 15…
Quiz
…how tuples compare with lists Unpacking, with * and in for loops Why tuples cannot change, and how to build a new one instead count() , index() , sorting, nested tuples and divmod() How it works 15…
Quiz
…and reversing lists . After this one, try the Python For Loop Quiz or the Python While Loop Quiz . What does this code print? What does this code print? What does this code print? Given stops =…
Quiz
…in one function Reading keyword arguments with get() and looping over them with items() Unpacking a tuple, a string or a dictionary into a call with * and ** Passing *args and **kwargs on to another…
Challenge
Build the station's weekly shift rota: three shifts a day, the crew taken in turn so nobody works two shifts in a row, with a check that proves it, then plan around days off while keeping the work…
Challenge
Extend the feed parser from "Skip blanks and comments": a faulty sensor sends ERR and float() stops the program. Skip lines that fail to convert and count them, then let one try cover short lines too…
Challenge
…blocks with a list of (name, level) pairs and one loop, keeping the output exactly the same, then add a fourth tank with a single list item and list the low tanks.
Example
Functions enumerate() and range() extend for loop capabilities in Python.
Challenge
…on line 4: [T+00:14:47] ERROR Fuel valve 2 not responding Loop with enumerate(log, start=1) . Look for "] ERROR" , as in "Count warnings", so a message that only mentions the word doesn't count. break…
Challenge
…list with extend(), then fetch page after page in a while loop and stop at the first short page, the way paginated API responses are read.