In: Computer Science
The program is given below: that take number of rooms from user, take temperature for s-th room from user, then find position of warmest room and print its position.
#take number of rooms from user
S=int(input(""))
temp=[]
#execute for loop upto S
for i in range(S):
#take temperature for s-th room from user
temp_1=float(input(""))
#check temperature taken from user is less than or eqaul
1000.00
if(temp_1<=1000.00):
#append temp_1 into temp array
temp.append(temp_1)
#set pos to 0
pos=0
#set warm_temp to temp[0]
warm_temp=temp[0]
#execute for loop upto S
for i in range(S):
#check warm_temp is less than or equal temp[i]
if(warm_temp<=temp[i]):
#set warm_temp to temp[i]
warm_temp=temp[i]
#set pos to i
pos=i
#print position of warmest room
print(pos+1)
The screenshot of code is given below:
Input Example 1:
5
5.26
10.59
8.4
9.2
10.58
Output Example 1:
2
Input Example 2:
6
5.26
10.59
8.4
9.051
10.58
10.59
Output example 2:
6