generated from mwc/lab_iteration
	Checkpoint 1: - It wasn't really difficult. I initially wrote the loop based on the number of sides the square has but then noticed the input was size dependent and not shape. So I just used the number of inputs for the loop. Checkpoint 2: - I think the concept of range and the related function we use is pretty simple and I understood it pretty well overall. - My mind briefly wandered off to series while writing the odd function. I could probably figure out why that connection popped up in my mind and how to implement it if asked but it wasn't needed for this time. Checkpoint 3: - I definitely will utilize docstrings along with whitespaces to help making the code more legible and easier to follow. This doesn't only benefit people who are unfamiliar with my code but also it benefits me to keep track of my thoughts if I ever were to take a break from, or foresee editing my code.
		
			
				
	
	
		
			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)
 | 
						|
 |