Python 3.4 Celsius to Fahrenheit

I need a USER INPUT code in python 3.4 that turns Celsius into Fahrenheit. Where the user enters a Celsius number and turns into a farhenheit degree.

2

4 Answers

You will need to have an input statement to start with:

celsius = input("Enter degrees in Celsius')

Then write your code for converting Celsius to Fahrenheit:

Celsius -> Fahrenheit:

Multiply by 9, then Divide by 5, then Add 32
# Name
Name = raw_input("Enter name= ")

# Enter fDegree value
F = input("enter Fah Degree value= ")

# Calculation for cDegree
C = (5.00/9.00)*(F-32.00)`#formula`

print "The input Fdegress= {:.2f}".format(F)
print "Celsius Degree = {:.2f}".format(C)
1

Hi this program can calculate both Fahrenheit to Celsius and Celsius to Fahrenheit. If you scroll down you will see the code for Celsius itself.

import time # importing functions 
start=time.perf_counter()#starting timer 
try:
    x=int(input(' 1-Fahrenheit to Celsius. 2-Celsius to Fahrenheit please enter option 
1 or 2:')) #asking for input 
    if x==1:
        a=int(input('enter the temperature in Fahrenheit')) # asking the temperature
        b=(a-32)/1.8# calculating
        print('the temperature is',b,'degrees celsius')#printing 
     elif x==2:
        c=int(input('enter the temperature in celsius'))
        d=(c*9/5)+32
        print('the temperature is ' ,d,'degrees Fahrenheit')
    else:
        print('please enter a valid option')
except Exception:
    print('please enter something valid')#error statement 
finally:
    end=time.perf_counter()#ending timer
    f=end-start
message='The time taken is %s seconds'
print(message % f)# printing time 

The code for the Celsius itself:

c=int(input('enter the temperature in Celsius'))
d=(c*9/5)+32
print('the temperature is ' ,d,'degrees Fahrenheit')

Please let me know if you have any questions Anikait Sota

1

Write a Input Statement

celsius = float(input('Enter temperature in Celsius: ')) 

code for convert it to Fahrenheit

fahrenheit = (celsius * 1.8) + 32. 

print output

print('%0.1f Celsius is equal to %0.1f degree Fahrenheit'%(celsius,fahrenheit))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest