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.
This commit is contained in:
Lauren Dawnkaski 2024-09-10 16:29:23 -04:00
parent 0edd7574d2
commit 59a3a3b2d8
2 changed files with 8 additions and 5 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 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}")

View File

@ -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)