CHECKPOINT 2 - RANGES

This one was easy! It is quite straightforward. I think ranges can become very useful. I do think it will take some getting used to that the maximum number is not included. I get the urge to make the range(21) instead of range(20) so I can get the "full" list of numbers.
This commit is contained in:
sigrid
2025-09-11 12:44:11 +08:00
parent 5f5e945dab
commit 2a738638ed

View File

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