From 84f216674a1ee389ad2d613d7661d3cad5125880 Mon Sep 17 00:00:00 2001 From: caglazir Date: Fri, 12 Sep 2025 20:42:21 -0400 Subject: [PATCH] I added loops that were similar to the given ex. 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. --- ranges.py | 9 ++++++--- square.py | 13 +++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/ranges.py b/ranges.py index 2fa00d7..d9fdf8b 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 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(1,maximum,2): + print(number) 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}") diff --git a/square.py b/square.py index f1fb2a2..396982c 100644 --- a/square.py +++ b/square.py @@ -1,17 +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) - sizes = [20, 40, 60, 80, 100] for size in sizes: - square(size) + forward(side_length) + right(90) +square(size) input()