i changed the square.py file to use iteration

checkpoint 1: no it wasn't difficult, i know how to use for loops

checkpoint 2: ranges are super helpful in iteration and can be very useful when you want to repeat stuff or go through data

checkpoint 3: yes, i do think i will write docstrings. I've read them in the past and have found them very insightful.
they make it easier to know how programs work, similar to comments in functions.
This commit is contained in:
ilmabura
2025-09-07 22:35:34 -04:00
parent f11330af49
commit 0df5838eb4
2 changed files with 10 additions and 11 deletions

View File

@@ -9,15 +9,18 @@ def print_all_numbers(maximum):
def print_even_numbers(maximum):
"Prints all even integers from 0 to maximum."
pass
for x in range(0,maximum,2):
print (x)
def print_odd_numbers(maximum):
"Prints all odd integers from 0 to maximum."
pass
for x in range(1,maximum,2):
print (x)
def print_multiples_of_five(maximum):
"Prints all integers which are multiples of five from 0 to maximum."
pass
for x in range(0,maximum,5):
print (x)
chosen_maximum = int(input("Choose a number: "))
print(f"All numbers from 0 to {chosen_maximum}")

View File

@@ -1,14 +1,10 @@
from turtle import *
def square(side_length):
forward(side_length)
right(90)
forward(side_length)
right(90)
forward(side_length)
right(90)
forward(side_length)
right(90)
for x in range(4):
forward(side_length)
right(90)
sizes = [20, 40, 60, 80, 100]
for size in sizes: