From 0df5838eb4899a676d37c4a4710814293a2964cf Mon Sep 17 00:00:00 2001 From: ilmabura Date: Sun, 7 Sep 2025 22:35:34 -0400 Subject: [PATCH] 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. --- ranges.py | 9 ++++++--- square.py | 12 ++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ranges.py b/ranges.py index 2fa00d7..b6d6a64 100644 --- a/ranges.py +++ b/ranges.py @@ -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}") diff --git a/square.py b/square.py index f1fb2a2..c63b188 100644 --- a/square.py +++ b/square.py @@ -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: