198k views
3 votes
Consider the following code, where temps is a list of floating point numbers.min_temp = Nonemin_index = Nonefor i in range(len(temps)):if __________________:min_temp = temps[i]_________________1. Fill in the first blank with a Boolean expression so that after the loop executes, the variable min_temp contains the minimum temperature. Do not use the built-in function min().2. Fill in the second blank with a statement completing the program so that after the loop executes, the variable min_index contains the index in the list corresponding to the minimum temperature.

User JohnTaa
by
4.2k points

1 Answer

5 votes

Answer:

1. min_temp = None

for i in range(len(temps)):

if min_temp == None or temps[i] < min_temp:

min_temp = temps[i]

2. min_index = None

for i in range(len(temps)):

if min_temp == None or temps[i] < min_temp:

min_temp = temps[i]

min_index = i

User Jakki
by
5.1k points