KnowledgeBoat Logo

Computer Science

Write a program to obtain temperatures of 7 days (Monday, Tuesday … Sunday) and then display average temperature of the week.

Python

Python Data Handling

101 Likes

Answer

d1 = float(input("Enter Sunday Temperature: "))
d2 = float(input("Enter Monday Temperature: "))
d3 = float(input("Enter Tuesday Temperature: "))
d4 = float(input("Enter Wednesday Temperature: "))
d5 = float(input("Enter Thursday Temperature: "))
d6 = float(input("Enter Friday Temperature: "))
d7 = float(input("Enter Saturday Temperature: "))

avg = (d1 + d2 + d3 + d4 + d5 + d6 + d7) / 7

print("Average Temperature =", avg)

Output

Enter Sunday Temperature: 21.6
Enter Monday Temperature: 22.3
Enter Tuesday Temperature: 24.5
Enter Wednesday Temperature: 23.0
Enter Thursday Temperature: 23.7
Enter Friday Temperature: 24.2
Enter Saturday Temperature: 25
Average Temperature = 23.47142857142857

Answered By

47 Likes


Related Questions