Question: Python Write a function definition for a function, get_temperature , that prompts the user for a numeric temperature. If the user enters a valid number

Python

Write a function definition for a function, get_temperature, that prompts the user for a numeric temperature. If the user enters a valid number, the function returns it (as a float). Otherwise the function returns the highest temperature recorded on earth: 134.1 (in F).

Start with:

def get_temperature(): # Your code here def main(): result = get_temperature() print(f'Temperature: {result}F') if __name__ == '__main__': main()

Here are some scenarios to test your code:

Please enter a temperature: 98.6 Temperature: 98.6F

Please enter a temperature: meh Temperature: 134.1F

Please enter a temperature: 1000.5 Temperature: 1000.5F

Please enter a temperature: -700 Temperature: -700.0F

Please enter a temperature: 12.14.6 Temperature: 134.1F

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!