Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Display Converted Temperatures

00:00 With both functions in place, you can tackle the next part of the challenge, which is prompting the user to enter a temperature and then convert Fahrenheit to Celsius and Celsius to Fahrenheit and then display all converted temperatures rounded to two decimal places.

00:19 Now this is very interesting how you want to tackle it. I decide to postpone the prompting part for later because otherwise when you want to test if your code works, you will be prompted all the time.

00:32 So instead of tackling the prompting part, I first tackle the displaying part. For this, I create a variable temp_far, which I set to 72.

00:49 This would be something that later we can prompt the user for. So it’s a nice idea to add a to-do there so we don’t forget to prompt the user later. And a temp_cel variable, which is the converted value from convert_far_to_cel().

01:05 So you pass in temp_far there, and then you can print temp_cel.

01:15 Okay. With this code in place, you can save and run it. And as you can see, there is the 22.222 and so on. So generally, the code works as expected.

01:27 There are a few adjustments that you need to do in a moment, but for now, continue with the temp_cel variable that you now set to the integer 37.

01:40 Again, this will be something that later, this will be an input from the user

01:46 and then temp_far is convert_cel_to_far() with temp_cel as the argument.

01:56 And then again, make a print() function call with temp_far as the argument. And then when you save and run it, you have the 98.6 with a bunch of zeros and the one as a result.

02:11 That means the first two parts of this part of the challenge are solved. And next, we should tackle the displaying of the decimal places behind the dot.

Become a Member to join the conversation.