generated from mwc/lab_iteration
	Something i understood well was the idea that i needed to use the same "for number in range" prompt for all of the functions. Something I was unsure about was why my even numbers wouldnt work when i had (max, 2), but i realized the error of not having a strting value. Other than that theres not much i was unsure about as this is very similar to math.
		
			
				
	
	
		
			35 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
# ranges.py
 | 
						|
# ---------
 | 
						|
# By MWC Contributors
 | 
						|
 | 
						|
def print_all_numbers(maximum):
 | 
						|
    "Prints all integers from 0 to maximum."
 | 
						|
    for number in range(maximum):
 | 
						|
        print(number)
 | 
						|
 | 
						|
def print_even_numbers(maximum):
 | 
						|
    "Prints all even integers from 0 to maximum."
 | 
						|
    for number in range(0, maximum, 2):
 | 
						|
        print(number)
 | 
						|
 | 
						|
def print_odd_numbers(maximum):
 | 
						|
    "Prints all odd integers from 0 to maximum."
 | 
						|
    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."
 | 
						|
    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}")
 | 
						|
print_all_numbers(chosen_maximum)
 | 
						|
print(f"All even numbers from 0 to {chosen_maximum}")
 | 
						|
print_even_numbers(chosen_maximum)
 | 
						|
print(f"All odd numbers from 0 to {chosen_maximum}")
 | 
						|
print_odd_numbers(chosen_maximum)
 | 
						|
print(f"All multiples of 5 from  0 to {chosen_maximum}")
 | 
						|
print_multiples_of_five(chosen_maximum)
 | 
						|
 |