I made the print_even_numbers, print_odd_numbers and print_multiples_of_five code work.

It was difficulty to figure out how to rewrite square() with a for-loop,
I had to try out many different ways to use the for-loop code before it
finally worked.

Something interesting I find about ranges is how it does not count the
maximum when printing the numbers.

Why does it not count the maximum?
This commit is contained in:
kdang
2025-09-24 09:19:22 -04:00
parent 4e38e7d73a
commit 84a6690409

View File

@@ -9,15 +9,18 @@ def print_all_numbers(maximum):
def print_even_numbers(maximum):
"Prints all even integers from 0 to maximum."
pass
for number in range(0, maximum, 2):
print(number)
def print_odd_numbers(maximum):
"Prints all odd integers from 0 to maximum."
pass
for number in range(0, maximum, 2):
print(number + 1)
def print_multiples_of_five(maximum):
"Prints all integers which are multiples of five from 0 to maximum."
pass
for number in range(0, maximum, 5):
print(number)
chosen_maximum = int(input("Choose a number: "))
print(f"All numbers from 0 to {chosen_maximum}")