Tagged: modulo
Everything tagged "modulo", newest first.
Python Coding Exercise #48: The Next Leap Year
A beginner Python exercise on searching with a while loop — start from the year after the one entered, test each year against the leap year rule, and stop at the first one that fits.
Python Coding Exercise #40: Leap Year
A beginner Python exercise on if, elif and else with the remainder operator — decide whether a year is a leap year, handle the century-year exception, and compare a flat chain of conditions with a nested if.
Python Coding Exercise #39: FizzBuzz
A beginner Python exercise on the remainder operator and the and operator — print Fizz, Buzz or FizzBuzz depending on whether a number is divisible by 3, 5 or both, and see why the order of the conditions matters.
Python Coding Exercise #21: Grams to Kilograms
A beginner Python exercise on unit conversion — turn a whole number of grams into kilograms and leftover grams, then polish the output so singular and plural words and zero values read correctly.
Python Coding Exercise #12: Students in Groups
A beginner Python exercise on integer division, the remainder operator and if/else — work out how many groups a class needs when the students don't divide evenly.