Write a program that can convert between celcius and farenheit temperature scales

Fahrenheit to Celsius formula: (°F - 32) x 5/9 = °C or in plain english, First subtract 32, then multiply by 5, then divide by 9.

Celsius to Fahrenheit formula: (°C × 9/5) + 32 = °F or in plain English, Multiple by 9, then divide by 5, then add 32

---------------------------------------------- Convert Fahrenheit to Celsius -----------------------------

#!/usr/bin/env python

Fahrenheit = int(raw_input("Enter a temperature in Fahrenheit: "))

Celsius = (Fahrenheit - 32) * 5.0/9.0

print "Temperature:", Fahrenheit, "Fahrenheit = ", Celsius, " C"

------------------------------------------   Convert Celsius to Fahrenheit    -------------------------

#!/usr/bin/env python

Celsius = int(raw_input("Enter a temperature in Celsius: "))

Fahrenheit = 9.0/5.0 * Celsius + 32

print "Temperature:", Celsius, "Celsius = ", Fahrenheit, " F"

--------------------------------------------------

An example of an acceptable solution to the problem using 'int' and 'print' functions to take input transform it and then display an output

Answered by Matthew P. Python tutor

3146 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

[Exam style] Python is an interpreted language. Explain what this means and how interpreted languages differ from compiled languages.


Given a list of N numbers, use a single list comprehension to produce a new list that only contains those values that are: (a) even numbers, and (b) from elements in the original list that had even indices .


Write a program that takes a value x and then outputs x Fibonnaci numbers. E.g. if x=6 output would be 1 1 2 3 5 8


With the help of Pandas and Numpy library create a DataFrame with the columns "Name", "Surname", "Age" and "Gender", create as many rows as you want. Print out the result.


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2024

Terms & Conditions|Privacy Policy