Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions