generated from mwc/lab_iteration
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:
@@ -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(1, maximum, 2):
|
||||
print(number)
|
||||
|
||||
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}")
|
||||
|
||||
Reference in New Issue
Block a user