added three for loop statements using the range command

Checkpoint 2: I understand the range command well. Using this command the first value is the starting point, second value is the end point, third value is the step. This command creates a list - like object. I wonder how I could use this command in other assignments and if it is useful!
This commit is contained in:
erbrown
2025-09-14 16:29:34 -04:00
parent 9ee9e17edb
commit 4cdcd61ee7

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}")