-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathListing 1_14.py
More file actions
35 lines (31 loc) · 1.09 KB
/
Listing 1_14.py
File metadata and controls
35 lines (31 loc) · 1.09 KB
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
26
27
28
29
30
31
32
33
34
35
"""Manage a library summer reading program."""
# Annotate and initialize variables.
max_minutes: int = -1
total_minutes: int = 0
max_name: str = None
instructions: str
num_children: int
name: str
num_minutes: int
# Display instructions to the user.
instructions = "Enter each child's name and the number of "
instructions += "minutes they read this week."
print(instructions)
# Obtain information for five children.
num_children = 0
while num_children < 5:
name = input("What is the child's name? ")
num_minutes = int(input("How many minutes did "
+ name + " read this week? "))
# Find the max so far and total.
if num_minutes > max_minutes:
max_minutes = num_minutes
max_name = name
total_minutes += num_minutes
# Update the counter.
num_children += 1
# Display a summary of reading information.
print(max_name + " is our star reader, with a total of "
+ str(max_minutes) + " minutes.")
print("The total number of minutes read by all of the"
+ " children was " + str(total_minutes) + ".")