From 2a738638edf177ff6e8e7a9fabd3ce2ba965044f Mon Sep 17 00:00:00 2001 From: sigrid Date: Thu, 11 Sep 2025 12:44:11 +0800 Subject: [PATCH] CHECKPOINT 2 - RANGES This one was easy! It is quite straightforward. I think ranges can become very useful. I do think it will take some getting used to that the maximum number is not included. I get the urge to make the range(21) instead of range(20) so I can get the "full" list of numbers. --- ranges.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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}")