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
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