Challenge
Statistics module
…tested, in its standard library. Use them instead. Use the module Delete the hand-written mean() and median() , add import statistics at the top, and print the same two lines with statistics.mean()…
Showing 1–10 of 30
Challenge
…tested, in its standard library. Use them instead. Use the module Delete the hand-written mean() and median() , add import statistics at the top, and print the same two lines with statistics.mean()…
Example
Learning to import modules in Python. Modules extend your program capabilities.
Article Mini projects
…to create a random planet selector. Using Python's random module, you'll learn how to generate exciting space missions while mastering fundamental programming concepts.
Example
Namespaces isolate variables. Modules and functions create their own namespaces.
Challenge
…tank, under lines nobody needs. Switch to the logging module, where every message has a level and you decide which levels to show. Levels instead of prints Replace each print() with the logging call…
Example
Operator // for floor division and % for remainder (modulo) in Python.
Challenge
Load the downlink module's JSON settings over a copy of the defaults, check each value's type and range and report every problem in one go, then wrap it all in a load_config() that never crashes, even…
Challenge
…stations don't even agree on a time zone. Let the datetime module do the counting. Subtract two timestamps Parse both timestamps with datetime.fromisoformat() into launched and latest , subtract them…
Challenge
…that text into data. Do that step yourself with the json module, then deal with a response that didn't arrive in one piece. json.loads() The prints from "API response" expect a dict, but response_text…
Challenge
…changes every few seconds. Read the file itself, with the module made for it, then pick out the hottest reading. csv.DictReader Replace the old parser and its feed string: open telemetry.csv with…