generated from mwc/lab_iteration
I got to checkpoint 2.
I really understand ranges maybe due to my math background. One thing that I tried when doing the odd numbers was to input the stride as 2*number+1. My thought process was to originally include zero. Putting in an equation like this unfortunately does not work. Then I thought about the definition of odd and realized that zero is not odd because it is divisible by 2.
This commit is contained in:
parent
0edd7574d2
commit
59a3a3b2d8
|
@ -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}")
|
||||||
|
|
Loading…
Reference in New Issue