From 4cdcd61ee7138707a9352f8a73e55b08035951d9 Mon Sep 17 00:00:00 2001 From: erbrown Date: Sun, 14 Sep 2025 16:29:34 -0400 Subject: [PATCH] added three for loop statements using the range command Checkpoint 2: I understand the range command well. Using this command the first value is the starting point, second value is the end point, third value is the step. This command creates a list - like object. I wonder how I could use this command in other assignments and if it is useful! --- ranges.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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}")