233k views
0 votes
Write a program in Python using a two-dimensional list to hold temperature information for four days. It will capture three temperature readings for the morning and three temperature readings for the afternoon. The user will enter in the start day in numeric form with "1" being Sunday, "2" being Monday, etc. The program will load the correct number for the following three days. The temperatures will be entered in Celsius and the programmer will set a reasonable upper and lower

1 Answer

4 votes

Final answer:

To write a program in Python using a two-dimensional list to hold temperature information for four days, you can use a for loop and prompt the user for temperature readings. The readings can be stored in a two-dimensional list called 'temperatures'.

Step-by-step explanation:

To write a program in Python using a two-dimensional list to hold temperature information for four days, you can start by creating an empty list called 'temperatures'. Then, you can use a for loop to iterate four times and prompt the user to enter the temperature readings for each day and time period. Here's an example code:

temperatures = []

for i in range(4):
day_temps = []
print(f'Day {i}:')
for j in range(2):
time = input('Enter the time period (morning or afternoon): ')
temps = []
for k in range(3):
temp = float(input(f'Enter the temperature for {time} (Celsius): '))
temps.append(temp)
day_temps.append(temps)
temperatures.append(day_temps)

print(temperatures)

This program will capture three temperature readings for the morning and three temperature readings for the afternoon for each of the four days. The temperature readings will be stored in the two-dimensional list 'temperatures'.

User Matthew Slattery
by
8.3k points