Question: Write a function named generate _ temperatures that works with the code below. The function should generate and print random temperatures between the coldest temperature

Write a function named generate_temperatures that works with the
code below. The function should generate and print random temperatures between the coldest
temperature and the hottest temperature until a temperature is generated that is close enough to
the desired temperature. Your program can make the following assumptions: (1) the values of
all four parameters are floating point numbers, (2) the coldest_temperature is less than the
hottest_temperature, (3) the desired_temperature is somewhere between the coldest_temperature
and the hottest_temperature and (4) how_close is 1.0 or greater.
def main():
c oldest_temperature =-70.0
# The coldest temperature (could be any value)
hottest_temperature =117.5 # The hottest temperature (could be any value)
desired_temperature =72.7 # A subjective ideal temperature (could be any value)
how_close =9.9
# Closeness to desired temperature (could be any value)
generate_temperatures(coldest_temperature, hottest_temperature, \
desired_temperature, how_close)
main()
What follows is a sample run that generates four random temperatures before stopping. The run
stops because the 78.11 temperature is within 9.9 degrees of the desired temperature.
-11.68
-10.16
54.53
78.11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!