generated from mwc/lab_iteration
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:
@@ -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}")
|
||||||
|
Reference in New Issue
Block a user