Print numbers from 1-20, odds, even and in multiples of 5

something interesting about ranges is that it alway skips the last numbers
something im still unsure about is why in line 26 "Choose a number:" need a :
This commit is contained in:
tsmith37
2025-09-15 16:29:20 -04:00
parent 034481f2a5
commit af6ffdfbd8

View File

@@ -9,17 +9,21 @@ 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, 21, 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, 20, 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, 21, 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}")
print_all_numbers(chosen_maximum) print_all_numbers(chosen_maximum)
print(f"All even numbers from 0 to {chosen_maximum}") print(f"All even numbers from 0 to {chosen_maximum}")
@@ -28,4 +32,3 @@ print(f"All odd numbers from 0 to {chosen_maximum}")
print_odd_numbers(chosen_maximum) print_odd_numbers(chosen_maximum)
print(f"All multiples of 5 from 0 to {chosen_maximum}") print(f"All multiples of 5 from 0 to {chosen_maximum}")
print_multiples_of_five(chosen_maximum) print_multiples_of_five(chosen_maximum)