Respuesta :
Answer:
temps = [10.2, 20.4, 30.0]
avg_temp = 0.0
total = 0.0
for k in temps:
total += k
avg_temp = total/len(temps)
print(avg_temp)
Explanation:
- Create a list temps, that holds value for temperatures
- Initialize the average and total
- Initialize a for loop that iterates through the temps
- Add the values in temp to the total
- When the loop is done, calculate the average
- Print the average
Answer:
temps = [23.4, 20.2, 19.5, 21.3, 18.7, 25.4, 24.9]
avg_temp = 0.0
total = 0.0
for k in temps:
total += k
print("The total is \n", total)
avg_temp = total/len(temps)
print("The average temperature is \n", avg_temp)
Explanation:
Using Python programming language
Create a list with seven values for daily temperature values (Its hard-coded to represent seven days of the week)
Declare and initialize to zero the variables avg_temp and total
Use a for loop to add elements of the list
Print the values
see attached code and output
