Example
Floor Division and Modulo
Operator // for floor division and % for remainder (modulo) in Python.
Showing 1–10 of 30
Example
Operator // for floor division and % for remainder (modulo) in Python.
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.
Quiz
…example: basic math operations , floor division and modulo , exponentiation and roots and order of operations . After this one, try the Python Data Types Quiz or the Python Basics Quiz . Which…
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.
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
Split 100,000 seconds of mission time into hours, minutes and seconds with // and %, pad it to a 27:46:40 clock, then add days in the DDD/HH:MM:SS format.
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
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…