0

conversion from Fahrenheit temperature to Celsius- python

Guys I am working on my python exercises and I need a program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning function defined to take a Fahrenheit temperature as a parameter. This function should calculate the equivalent Celsius temperature and return it. In the main function, your program should: prompt the user to enter a temperature (as a float type). indicate the temperature scale of the temperature just entered. call the appropriate function from the temps module. if the Celsius temperature is being determined, it should be displayed accurate to three decimal places. EXAMPLE OUTPUT 1 Enter a temperature 32 Was that input Fahrenheit or Celsius c/f? f 32.0 Fahrenheit equals 0.000 Celsius EXAMPLE OUTPUT 2 Enter a temperature 100 Was that input Fahrenheit or Celsius c/f? c 100.0 Celsius is 212.000 Fahrenheit

22nd Sep 2017, 12:39 AM
Alejandro Ariza
3 ответов
+ 5
The formula for converting: F = C * 1.8 + 32 C = (F - 32) / 1.8 For the functions, you will need a variable in the parameters: c_to_f would take the C. Then, you can use the formula to calculate the F value. Similar thing with the function f_to_c.
22nd Sep 2017, 2:27 AM
Rrestoring faith
Rrestoring faith - avatar
+ 4
To add to @Rrestoring Faith's answer, you can always use the Search bar on the Code Playground section, entering keyword "Fahrenheit Celsius" will return loads of results, you can learn from others' work, and make adjustments as necessary. Good luck!
22nd Sep 2017, 3:26 AM
Ipang
0
Actually, the formula is provided on the question page. You just have to copy and paste into the function. https://code.sololearn.com/cmb1VX4r61pq/?ref=app
18th Dec 2020, 6:06 PM
Lam Wei Li
Lam Wei Li - avatar