428 views

### 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

1 year ago

Answered by Matthew, a Mentoring Python tutor with MyTutor

## Still stuck? Get one-to-one help from a personally interviewed subject specialist

#### 0 SUBJECT SPECIALISTS

Currently unavailable: for new students

Degree: Electronic & Electrical Engineering (Bachelors) - Southampton University

Subjects offered:Python, Physics+ 1 more

Python
Physics
Maths
Electronics

“About me: I'm an undergarduate Electronic Engineer studying at the University of Southampton. I really enjoy working on new projects, such as designing robots and other rasberry pi projects, and it stems from a love of Physics and Mat...”

MyTutor guarantee

### You may also like...

#### Posts by Matthew

Convert the decimal number 165 to binary

Explain the difference between forced vibration and resonance in an oscillating object.

find general solution to: x(dy/dx) + 2y = 4x^2

Find Solution to x^2 + x - 2=0

#### Other Mentoring Python questions

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

What is the difference between & and && operators?

How could I write a program to convert Km/h to m/s in python

How do I define a function in Python?

We use cookies to improve your site experience. By continuing to use this website, we'll assume that you're OK with this.