Question: 1. using python, Change your code for Temperature Converter so that it retrieves a float from the user and converts it from Celsius to Fahrenheit,

1. using python, Change your code for Temperature Converter so that it retrieves a float from the user and converts it from Celsius to Fahrenheit, and then retrieves another float from the user and converts it from Fahrenheit to Celsius. Your program should still have the two functions you wrote. In both cases, if the user enters something that cant be converted to a float, print an error message.

As a reminder, here are the formulas for temperature conversion:

2. In this exercise, you get to put together a bunch of the knowledge youve acquired in this module!

Write a function called retrieve_positive_number that repeatedly asks the user for a positive number. If the user enters a negative number or zero, the function should tell them and reprompt. If the user enters something that isnt a number, the function should also tell them and reprompt.

When the user finally enters a positive number, the function should return this number.

Call this function to test it!

You will need:

  • A function definition, with no parameters.
  • A try and except block.
  • A while loop.
  • A return statement.
  • An if statement.

Hint: The return keyword is even more powerful than break. If you are inside of a loop, and that loop is inside of a function, break just breaks out of the loop. return, on the other hand, breaks out of the entire function (and possibly also returns a value).

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!