generated from mwc/lab_iteration
change other functions code
2 it's very similar to math concept of range, it's actually very useful to find particular numbers among a range of numbers, but you have to figure out how to find that number. For odd number, I initially used minus one, then figure out that it should be plus one on the basis of even numbers identified among the range. It's not about range but I wonder if we could provide a list of numbers and identify numbers that meet requirement among them.
This commit is contained in:
parent
51f631303f
commit
ff4218a8ce
|
@ -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(0, maximum, 2):
|
||||
print(number+1)
|
||||
|
||||
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}")
|
||||
|
|
Loading…
Reference in New Issue