-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherror3.py
More file actions
25 lines (21 loc) · 724 Bytes
/
Copy patherror3.py
File metadata and controls
25 lines (21 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""
A program that finds a best fit value in a loop.
Maggie
"""
# Annotate and initialize variables.
best_fit: int = 0
value: int
num_values: int = 0
# Let the user know what the program does.
print("I'll tell you the largest value you enter.")
# Obtain positive values from the user until they enter -1,
# finding the largest value they enter.
value = int(input("Enter a positive value or -1 to quit: "))
while value != -1:
num_values += 1
if value > best_fit:
value = best_fit
value = int(input("Enter a positive value or -1 to quit: "))
# If any values were entered, display the largest.
if num_values != 0:
print(f"The largest value entered was {best_fit}.")