-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdebug1.py
More file actions
22 lines (18 loc) · 714 Bytes
/
debug1.py
File metadata and controls
22 lines (18 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# debug1.py
# This script should calculate the sum of all even numbers in a given range,
# where the start and end of the range are input by the user.
# Prompt the user for a start and end number, and return them as integers.
def get_range():
start = int(input("Enter the start number: "))
end = int(input("Enter the end number: "))
return start, end
# Calculate the sum of all even numbers between start and end (inclusive).
def sum_of_evens(start, end):
total = 0
for i in range(start, end + 1):
if i % 2 == 0:
total += i
return total
# Get user input and display the result.
start, end = get_range()
print("The sum of even numbers is:", sum_of_evens(start, end))