Computer Science, asked by Sushmarai231982, 11 months ago


Write a program to obtain the temperature of 7 days from Monday to Sunday and find out the average
temperature of a week. Assign temperature to different variables. Save and run the program. using script mode of python​

Answers

Answered by vamanmadhavan10
2

Answer:

a=eval(input("total no of days :"))

for i in range(a) :

b=str(input("enter day :"))

c=int(input("enter temperature :"))

print("temperatures daily:",c)

import statistics

average=statistics.mean(c)

print("average temperature :",average)

Explanation:

I have used statistics module to get the average.Statistics.mean() helps us to find the average !

Answered by Anonymous
0

The code to obtain the temperature of 7 days from Monday to Sunday and the average temperature of a week is as follows:

average = 0

for i in range(1,8):

      a= int(input("Enter today's temperature"))

      average= average+a

print(average/7)

  • Here, python script is used.
  • We have taken a variable "average= 0".
  • The for loop runs 7 times starting from 1.
  • Variable "a" takes the temperature of each day and saves the sum to the variable "average".
  • At the end, the average is calculated by dividing the variable "average" by 7.

Similar questions