Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 generatetemperatures 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: the values of
all four parameters are floating point numbers, the coldesttemperature is less than the
hottesttemperature, the desiredtemperature is somewhere between the coldesttemperature
and the hottesttemperature and howclose is or greater.
def main:
c oldesttemperature
# The coldest temperature could be any value
hottesttemperature # The hottest temperature could be any value
desiredtemperature # A subjective ideal temperature could be any value
howclose
# Closeness to desired temperature could be any value
generatetemperaturescoldesttemperature, hottesttemperature,
desiredtemperature, howclose
main
What follows is a sample run that generates four random temperatures before stopping. The run
stops because the temperature is within degrees of the desired temperature.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started