A group of medical students were monitoring the body temperature of a patient daily basis. Students captured 10 temperature readings in Celsius on a particular day.
1. Write an Algorithm to input these ten values and get the average temperature for that day. if the average temperature value is in between 970 Fahrenheit and 990 Fahrenheit then display the message “Your body temperature is normal…”. If it is more than 100.40 Fahrenheit then display the message “You have a fever caused by an infection or illness…”.
2. Convert the above algorithm (written in part (1)) to a Python program to output the desired results
Algorithm
Start
Declare list temperatures[]
Declare variable averageTemperature
for i=1 to 10 do
Read temperature
add temperature to temperatures list
Set averageTemperature=sum(temperatures)/10.0
if averageTemperature>=970 and averageTemperature<=990 then
print "Your body temperature is normal…"
else if averageTemperature>=100.40 and averageTemperature<970 then
print "You have a fever caused by an infection or illness…"
else
print "Wrong average temperature"
end if
Stop
Python program
temperatures=[]
#input these ten values and get the average temperature for that day.
for i in range(1,11):
temperatures.append(float(input(f"Enter the temperatures {i}: ")))
averageTemperature=sum(temperatures)/10.0
#if the average temperature value is in between 970 Fahrenheit and 990 Fahrenheit then display the message "Your body temperature is normal…".
if averageTemperature>=970 and averageTemperature<=990:
print("Your body temperature is normal…")
#If it is more than 100.40 Fahrenheit then display the message "You have a fever caused by an infection or illness…".
elif averageTemperature>=100.40 and averageTemperature<970:
print("You have a fever caused by an infection or illness…")
else:
print("Wrong average temperature")
Comments
Leave a comment