From 34ca650305a511263f8f0ae534d30d06cbb4dba6 Mon Sep 17 00:00:00 2001 From: Cory Dean Chung Date: Thu, 20 Jul 2023 12:50:17 -0400 Subject: [PATCH] I implemented print_even_numbers, print_odd_numbers, and print_multiples_of_five. Checkpoint 2: I understand the "stride" in a for loop. Overall, I feel comfortable with ranges. The only thing I was unsure of was whether I did print_even_numbers correctly. The assignment specified that print_all_numbers was implemented correctly, and when I input 8 the output was the integers from 0 to 7 inclusive. When I did print_even_numbers(8), it returned 0 2 4 6. I would've thought from the description, returning even numbers from 0 to maximum, would also include 8, but since print_all_numbers did not include the maximum itself, I left it as is. --- ranges.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ranges.py b/ranges.py index 2fa00d7..7dd489f 100644 --- a/ranges.py +++ b/ranges.py @@ -9,15 +9,16 @@ 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}")