From 59a3a3b2d8bb4d818dbcb8c7c60be66f99c9514a Mon Sep 17 00:00:00 2001 From: Lauren Dawnkaski Date: Tue, 10 Sep 2024 16:29:23 -0400 Subject: [PATCH] I got to checkpoint 2. I really understand ranges maybe due to my math background. One thing that I tried when doing the odd numbers was to input the stride as 2*number+1. My thought process was to originally include zero. Putting in an equation like this unfortunately does not work. Then I thought about the definition of odd and realized that zero is not odd because it is divisible by 2. --- ranges.py | 9 ++++++--- square.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ranges.py b/ranges.py index 2fa00d7..6b915c9 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 c57419d..cedcacb 100644 --- a/square.py +++ b/square.py @@ -1,8 +1,8 @@ from turtle import * def square(side_length): - sides=[1, 2, 3, 4] - for sides in sides: + side=[1, 2, 3, 4] + for sides in side: forward(side_length) right(90)