Example
Floor Division and Modulo
Operator // for floor division and % for remainder (modulo) in Python.
Showing 1–10 of 14
Example
Operator // for floor division and % for remainder (modulo) in Python.
Challenge
…9 Tubes in the last crate: 4 Empty slots: 8 Rounding a division up is a classic trick: (tubes + slots_per_crate - 1) // slots_per_crate . Adding one tube less than a full crate pushes any leftover…
Quiz
…quiz covers The arithmetic operators + , - , * and / Floor division // and the remainder % , with practical uses Powers with ** and square roots Order of operations and brackets round() , abs()…
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
Divide a distance by the speed of light to get the radio delay to a Mars orbiter, show it in whole minutes and seconds, then add the round trip without doubling a rounding error.
Challenge
Turn a tank's capacity and contents into a fill percentage with one decimal place, then draw the crew display's ten-segment gauge with string repetition and int().
Example
…in Python. Parentheses, exponents, multiplication, division, addition.
Article Python Fundamentals
…fuel: {remaining_fuel} liters") Multiplication and Division # Calculate rocket thrust force (F = m * a) mass = 1000 # kg acceleration = 9.81 # m/s² thrust_force = mass * acceleration print(f"Thrust…
Example
Addition, subtraction, multiplication and division in Python. Basic arithmetic operations.
Article Mini projects
…composite number, making it more practical for everyday division. Fractions like 1/2 and 1/3 come out clean in base 6 (0.3 and 0.2 respectively), while in our decimal system, 1/3 gives us the…