Example
Creating Variables
Variables store data in your program. Learning to create and name variables in Python.
Showing 221–230 of 237
Example
Variables store data in your program. Learning to create and name variables in Python.
Example
Simple way to check installed Python version on your system. First step for every programmer.
Challenge
Write convert(), which looks a unit pair up in a table of factors, works the other way round by dividing, and refuses unknown units or missing pairs with a clear ValueError, then extend the table with…
Challenge
Work out how many 12-slot crates 100 sample tubes fill with // and %, then how many crates they need and how full the last one is, including the case where the tubes fit exactly.
Example
Difference between positional and keyword arguments. Flexible function calling.
Example
Addition, subtraction, multiplication and division in Python. Basic arithmetic operations.
Challenge
The monitoring system raises the same alert over and over. Group repeats of an alert that come within 60 seconds of the first into one line with a count, in the order they first appeared, then add the…
Challenge
Refactor the level counter from "Entries per level": replace the dict and counts.get() with collections.Counter, which starts every key at 0, then list the levels from most to least common with…
Challenge
Extend format_log() from "Log formatter function" with **fields, so any extra keyword arguments are added to the line as key=value pairs, then pass whole dicts of fields into it with ** at the call.
Example
Multiple conditions with elif. Checking several possibilities in sequence.