Write a program to convert Fahrenheit to Celsius or vice versa using functions.

Number of replies: 59
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md. Safiqul Islam Nasim -
def cel(celsius):
ans = float((celsius - 32) / 1.8)
return ans
def fah (fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Choice No 1 for Fahrenheit to Celsius")
print("Choice No 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ",ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Siam Ahmed -
from math import trunc


def celsius(temp):
converted_temp = (temp - 32) * (5 / 9)
return converted_temp


def fahrenheit(temp):
converted_temp = (temp * (9 / 5)) + 32
return converted_temp


print("1. Celsius\n2. Fahrenheit\n")
user_choice = float(input("Enter your choice: "))
answer = 0.00

if user_choice == 1:
temperature = float(input("Enter Temperature(F): "))
answer = celsius(temperature)
elif user_choice == 2:
temperature = float(input("Enter Temperature(C): "))
answer = fahrenheit(temperature)

print("Answer: ", round(answer, 2))
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md. Ataur Rahman -

def cel(temperature):
Celsius = (temperature - 32.0) * (5.0/9.0)
return Celsius

def fah(temperature):
Fahrenheit = (temperature * (9.0/5.0)) + 32.0
return Fahrenheit


print("Choice Number 1 for convert Fahrenheit to Celsius")
print("Choice Number 2 for convert Celsius to Fahrenheit")
choice = int(input("Choice the number : " ))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("Celsius temperature is: ",c)
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("Fahrenheit temperature is: ", f)
else:
print("Your input number is wrong! please try again... ")

In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Hasna Jahan Suborna 192-15-13066 -
def Celsius_to_Fahrenheit(c) :

f = float((celsius - 32) / 1.8)

return f

def Fahrenheit_to_Celsius(f) :

c = float(fahrenheit * 1.8) + 32

return c


print("Choice your Numb_1 for convert Fahrenheit to Celsius\nChoice your Numb_2 for convert Celsius to Fahrenheit\n")

choice = int(input("Enter the number which you are choice: "))

if you_are_choice == 1:

c = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("Celsius temperature is: ",c)

elif you_are_choice == 2:

f = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print(""temperature in Fahrenheit: ", f)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Nazmus Salehin -
def cel(celsius):
res = float((celsius - 32) / 1.8)
return res

def fah (fahrenheit):
res = float(fahrenheit * 1.8) + 32
return res

print("Choice No 1 for Fahrenheit to Celsius conversion Or Choice No 2 for Celsius to Fahrenheit conversion")

choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
res = float(cel(celsius))
print("temperature in Celsius: ",res)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
res = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", res)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Siam Ahamed -
def cel(celsius):
ans = float((celsius - 32) / 1.8)
return ans
def fah (fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Choice No 1 for Fahrenheit to Celsius")
print("Choice No 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ",ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Mohammad Dipo Sultan -
def Fahrenheit_to_Celsius(Fahrenheit):
celsius=float((Fahrenheit-32)/1.8)
return celsius

def Celsius_to_Fahrenheit(Celsius):
fahrenheit=float((Celsius*1.8)+32)
return fahrenheit

while 1:
x=int(input("Enter 1 for Fahrenheit to Celsius and covert Celsius to Fahrenheit input 2. Any key to exit: "))
if x==1:
Fahrenheit=float(input("Enter a in Fahrenheit: "))
print("Temperature in Celsius:",Fahrenheit_to_Celsius(Fahrenheit))

elif x==2:
Celsius=float(input("Enter a in Celsius: "))
print("Temperature in Fahrenheit:",Celsius_to_Fahrenheit(Celsius))
else: break
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md. Sabbir Hossain 192-15-2809 -
def getCelsius(celsius):
result = float((celsius - 32) / 1.8)
return result


def getFahrenheit(fahrenheit):
result = float(fahrenheit * 1.8) + 32
return result


print("Choice 1 for Fahrenheit to Celsius")
print("Choice 2 for Celsius to Fahrenheit")
choice = int(input("Enter Choice Your Option"))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
result = float(getCelsius(celsius))
print("Celsius: ", result)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
result = float(getFahrenheit(fahrenheit))
print("Fahrenheit: ", result)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by S. M Rifat Abdullah Tamim 192-15-2797 -
def celcious(cel):
number1=(cel* (9/5)) + 32
print(number1)

def fahrenhaiet(fahren):
number2= (fahren - 32) * (5/9)
print(number2)

cel=float(input("Enter a celcious number "))
celcious(cel)

fahren=float(input("Enter a fahrenhiet number "))
fahrenhaiet(fahren)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Ruhani Akter -
def cel():
fahrenheit = float(input("Enter temperature in fahrenheit: "))
celsius = (fahrenheit - 32) * 5/9
print('%.2f Fahrenheit is: %0.2f Celsius' %(fahrenheit, celsius))

def fah():
celsius = float(input("Enter temperature in celsius: "))
fahrenheit = (celsius * 9/5) + 32
print('%.2f Celsius is: %0.2f Fahrenheit' %(celsius, fahrenheit))

print("---------------------------------------------")
print("Enter 1 if you want to calculate celsius")
print("Enter 2 if you want to calculate fahrenheit")
print("---------------------------------------------")

choice = int(input("Enter your choice:"))

if choice == 1:
cel()
elif choice == 2:
fah()
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Momotaz Zahan Mim -
def cel(temperature):
Celsius = (temperature - 32.0) * (5.0/9.0)
return Celsius

def fah(temperature):
Fahrenheit = (temperature * (9.0/5.0)) + 32.0
return Fahrenheit


print("Choice Number 1 for convert Fahrenheit to Celsius")
print("Choice Number 2 for convert Celsius to Fahrenheit")
choice = int(input("Choice the number : " ))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("Celsius temperature is: ",c)
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("Fahrenheit temperature is: ", f)
else:
print("Your input number is wrong! please try again... ")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md.Tawhidul Islam -
def cel(celsius):
ans = float((celsius - 32) / 1.8)
return ans
def fah (fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Choice No 1 for Fahrenheit to Celsius")
print("Choice No 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ",ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md Rana hossain (192-15-13109) -
def cel(celsius):
ans = float((celsius - 32) / 1.8)
return ans
def fah (fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Choice No 1 for Fahrenheit to Celsius")
print("Choice No 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ",ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Sanjina Nowshin Moon -
from math import trunc


def celsius(temp):
converted_temp = (temp - 32) * (5 / 9)
return converted_temp


def fahrenheit(temp):
converted_temp = (temp * (9 / 5)) + 32
return converted_temp


print("1. Celsius\n2. Fahrenheit\n")
user_choice = float(input("Enter your choice: "))
answer = 0.00

if user_choice == 1:
temperature = float(input("Enter Temperature(F): "))
answer = celsius(temperature)
elif user_choice == 2:
temperature = float(input("Enter Temperature(C): "))
answer = fahrenheit(temperature)

print("Answer: ", round(answer, 2))
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md. Rafeul Islam Rafe -
Fahrenheit = int(input("Enter a temperature in Fahrenheit: "))

Celsius = (Fahrenheit - 32) * 5.0/9.0

print ("Temperature:", Fahrenheit, "Fahrenheit = ", Celsius, " C")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md.Sirajul Siddique 192-15-2845 -
def celcious(cel):
number1=(cel* (9/5)) + 32
print(number1)

def fahrenhaiet(fahren):
number2= (fahren - 32) * (5/9)
print(number2)

cel=float(input("Enter a celcious number "))
celcious(cel)

fahren=float(input("Enter a fahrenhiet number "))
fahrenhaiet(fahren)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Tawhid Ahmed Komol 192-15-2861 -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Mizanur Rahman 192-15-2788 -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Afroja Rahman -
def cel(celsius):
res = float((celsius - 32) / 1.8)
return res

def fah (fahrenheit):
res = float(fahrenheit * 1.8) + 32
return res

print("Choice No 1 for Fahrenheit to Celsius conversion Or Choice No 2 for Celsius to Fahrenheit conversion")

choice = int (input("Enter choice"))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
res = float(cel(celsius))
print("temperature in Celsius: ",res)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
res = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", res)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Jannatul Islam -
def cel( celsius ):
ans = float((celsius - 32) / 1.8)
return ans
def fah(fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Select Category 1 for Fahrenheit to Celsius")
print("Select Category 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ", ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by kamruzzaman chowdhury -
def cel(celsius):
res = float((celsius - 32) / 1.8)
return res

def fah (fahrenheit):
res = float(fahrenheit * 1.8) + 32
return res

print("Choice No 1 for Fahrenheit to Celsius conversion Or Choice No 2 for Celsius to Fahrenheit conversion")

choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
res = float(cel(celsius))
print("temperature in Celsius: ",res)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
res = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", res)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Jannatul Anjum Shafa 192-15-2787 -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Shahariar Sarowar Mampy 192-15-2856 -
def cel(celsius):
ans = float((celsius - 32) / 1.8)
return ans
def fah (fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Choice No 1 for Fahrenheit to Celsius")
print("Choice No 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ",ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md Sazzat Hossain -
def celsius(temp):
converted_temp = (temp - 32) * (5 / 9)
return converted_temp


def fahrenheit(temp):
converted_temp = (temp * (9 / 5)) + 32
return converted_temp


print("1. Celsius\n2. Fahrenheit\n")
user_choice = float(input("Enter your choice: "))
answer = 0.00

if user_choice == 1:
temperature = float(input("Enter Temperature(F): "))
answer = celsius(temperature)
elif user_choice == 2:
temperature = float(input("Enter Temperature(C): "))
answer = fahrenheit(temperature)

print("Answer: ", round(answer, 2))
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Liza Meem 192-15-2903 -
def getCelsius(celsius):
result = float((celsius - 32) / 1.8)
return result


def getFahrenheit(fahrenheit):
result = float(fahrenheit * 1.8) + 32
return result


print("Choice 1 for Fahrenheit to Celsius")
print("Choice 2 for Celsius to Fahrenheit")
choice = int(input("Enter Choice Your Option"))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
result = float(getCelsius(celsius))
print("Celsius: ", result)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
result = float(getFahrenheit(fahrenheit))
print("Fahrenheit: ", result)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by tamim rahman -
def Fah to Cel(n):

return (n*1.8)+32

n = 20
print(int(Fah_to_Cel(n)))
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Ismot samia 192-15-13028 -

def Fahrenheit_to_Celsius(Fahrenheit):
celsius=float((Fahrenheit-32)/1.8)
return celsius

def Celsius_to_Fahrenheit(Celsius):
fahrenheit=float((Celsius*1.8)+32)
return fahrenheit

while 1:
x=int(input("Enter 1 for Fahrenheit to Celsius and covert Celsius to Fahrenheit input 2. Any key to exit: "))
if x==1:
Fahrenheit=float(input("Enter a in Fahrenheit: "))
print("Temperature in Celsius:",Fahrenheit_to_Celsius(Fahrenheit))

elif x==2:
Celsius=float(input("Enter a in Celsius: "))
print("Temperature in Fahrenheit:",Celsius_to_Fahrenheit(Celsius))
else: break

In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Sujon Islam -
from math import trunc


def celsius(temp):
converted_temp = (temp - 32) * (5 / 9)
return converted_temp


def fahrenheit(temp):
converted_temp = (temp * (9 / 5)) + 32
return converted_temp


print("1. Celsius\n2. Fahrenheit\n")
user_choice = float(input("Enter your choice: "))
answer = 0.00

if user_choice == 1:
temperature = float(input("Enter Temperature(F): "))
answer = celsius(temperature)
elif user_choice == 2:
temperature = float(input("Enter Temperature(C): "))
answer = fahrenheit(temperature)

print("Answer: ", round(answer, 2))
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by MD.Munim Shariair Galib -
from math import trunc


def celsius(temp):
converted_temp = (temp - 32) * (5 / 9)
return converted_temp


def fahrenheit(temp):
converted_temp = (temp * (9 / 5)) + 32
return converted_temp


print("1. Celsius\n2. Fahrenheit\n")
user_choice = float(input("Enter your choice: "))
answer = 0.00

if user_choice == 1:
temperature = float(input("Enter Temperature(F): "))
answer = celsius(temperature)
elif user_choice == 2:
temperature = float(input("Enter Temperature(C): "))
answer = fahrenheit(temperature)

print("Answer: ", round(answer, 2))
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Easin Parvez(192-15-13197) -
def cel(temperature):
Celsius = (temperature - 32.0) * (5.0/9.0)
return Celsius

def fah(temperature):
Fahrenheit = (temperature * (9.0/5.0)) + 32.0
return Fahrenheit


print("Choice Number 1 for convert Fahrenheit to Celsius")
print("Choice Number 2 for convert Celsius to Fahrenheit")
choice = int(input("Choice the number : " ))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("Celsius temperature is: ",c)
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("Fahrenheit temperature is: ", f)
else:
print("Your input number is wrong! please try again... ")

week2problem2(C to F F to C).py
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Nakibul hoque Shohan 192-15-2808 -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again"
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Sajia Afrin 192-15-2907 -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Muhammad Rabiul Hossain -
def getCelsius(celsius):
result = float((celsius - 32) / 1.8)
return result


def getFahrenheit(fahrenheit):
result = float(fahrenheit * 1.8) + 32
return result


print("Choice 1 for Fahrenheit to Celsius")
print("Choice 2 for Celsius to Fahrenheit")
choice = int(input("Enter Choice Your Option"))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
result = float(getCelsius(celsius))
print("Celsius: ", result)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
result = float(getFahrenheit(fahrenheit))
print("Fahrenheit: ", result)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Ayatullah jubaer 192-15-2786 -

from math import trunc



def celsius(temp):

converted_temp = (temp - 32) * (5 / 9)

return converted_temp



def fahrenheit(temp):

converted_temp = (temp * (9 / 5)) + 32

return converted_temp



print("1. Celsius\n2. Fahrenheit\n")

user_choice = float(input("Enter your choice: "))

answer = 0.00


if user_choice == 1:

temperature = float(input("Enter Temperature(F): "))

answer = celsius(temperature)

elif user_choice == 2:

temperature = float(input("Enter Temperature(C): "))

answer = fahrenheit(temperature)


print("Answer: ", round(answer, 2))

In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Jannatul Fardus Armin 192-15-2802 -
def celcious(cel):
number1=(cel* (9/5)) + 32
print(number1)

def fahrenhaiet(fahren):
number2= (fahren - 32) * (5/9)
print(number2)

cel=float(input("Enter a celcious number "))
celcious(cel)

fahren=float(input("Enter a fahrenhiet number "))
fahrenhaiet(fahren)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Abu Salkin -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md. Touhedur Rahman Khan Zihad 192-15-2775 -
def get_Cel(cel):
    result = float((cel - 32) / 1.8)
    return result


def get_Fah(fah):
    result = float(fah * 1.8) + 32
    return result


print("1. Fahrenheit to Celsius")
print("2. Celsius to Fahrenheit")
choice = int(input("Enter Choice: "))

if choice == 1:
    cel = float(input("Enter temperature in Fahrenheit: "))
    result = float(get_Cel(cel))
    print("Celsius: ", result)
else:
    fah = float(input("Enter Celsius temperature: "))
    result = float(get_Fah(fah))
    print("Fahrenheit: ", result)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md. Sabbir Alam 192-15-2847 -
def celcious(cel):
number1=(cel* (9/5)) + 32
print(number1)

def fahrenhaiet(fahren):
number2= (fahren - 32) * (5/9)
print(number2)

cel=float(input("Enter a celcious number "))
celcious(cel)

fahren=float(input("Enter a fahrenhiet number "))
fahrenhaiet(fahren)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Shamiul Karim Sompod -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Shafa Islam (192-15-13050) -
def celcious(cel):
num1=(cel* (9/5)) + 32
print(num1)

def fahrenhaiet(fahren):
num2= (fahren - 32) * (5/9)
print(num2)

cel=float(input("Enter a celcious number "))
celcious(cel)

fahren=float(input("Enter a fahrenhiet number "))
fahrenhaiet(fahren)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Tonmoy Chandra Chando 192-15-2782 -
Notifications

You have no notifications
See all

Course Overview
SECTIONS

General
1
Student Attendance
2
Course Introduction
3
Week 1 (Python Introduction)
4
Class Video (Google Meet) Week-1
5
Practice Problems (Week 1)
6
Week 2 (Python Control Statement)
7
Practice Problems (Week 2)
8
Week 3 (Python Library)
9
Week 4 (Python Lists and Searching)
10
Week 5 (Lists)
11
Week 6 (Dictionary)
12
Midterm Course Survery
13
Week 7 (Midterm Exam)
14
Week 8 (OOP Concepts)
15
Week 9 (Inheritance)
16
Week 10 (Polymorphism and Exception)
17
Week 11 (Library)
18
Week 12 (Library Operations)
19
Week 13 (Review)
20
Week 14 (Final Exam)
21
Skip to main content
Object Oriented Programming II (Spring 21)
Dashboard
My courses
OOPSPR21ZH
Practice Problems (Week 2)
Write a program to convert Fahrenheit to Celsius or vice versa using functions.
Search

Write a program to convert Fahrenheit to Celsius or vice versa using functions.
Display mode
Display replies in nested form
Write a program to convert Fahrenheit to Celsius or vice versa using functions.
Friday, 8 January 2021, 2:18 PM
Number of replies: 40
Picture of Md. Safiqul Islam Nasim
In reply to First post
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
by Md. Safiqul Islam Nasim - Monday, 25 January 2021, 12:31 PM
Picture of A
def cel(celsius):
ans = float((celsius - 32) / 1.8)
return ans
def fah (fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Choice No 1 for Fahrenheit to Celsius")
print("Choice No 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ",ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
Picture of Siam Ahmed
In reply to First post
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
by Siam Ahmed - Tuesday, 26 January 2021, 11:28 AM
Picture of A
from math import trunc


def celsius(temp):
converted_temp = (temp - 32) * (5 / 9)
return converted_temp


def fahrenheit(temp):
converted_temp = (temp * (9 / 5)) + 32
return converted_temp


print("1. Celsius\n2. Fahrenheit\n")
user_choice = float(input("Enter your choice: "))
answer = 0.00

if user_choice == 1:
temperature = float(input("Enter Temperature(F): "))
answer = celsius(temperature)
elif user_choice == 2:
temperature = float(input("Enter Temperature(C): "))
answer = fahrenheit(temperature)

print("Answer: ", round(answer, 2))
Picture of Md. Ataur Rahman
In reply to First post
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
by Md. Ataur Rahman - Sunday, 31 January 2021, 9:32 AM
Picture of A
def cel(temperature):
Celsius = (temperature - 32.0) * (5.0/9.0)
return Celsius

def fah(temperature):
Fahrenheit = (temperature * (9.0/5.0)) + 32.0
return Fahrenheit


print("Choice Number 1 for convert Fahrenheit to Celsius")
print("Choice Number 2 for convert Celsius to Fahrenheit")
choice = int(input("Choice the number : " ))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("Celsius temperature is: ",c)
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("Fahrenheit temperature is: ", f)
else:
print("Your input number is wrong! please try again... ")

week2problem2(C to F F to C).py
Picture of Hasna Jahan Suborna 192-15-13066
In reply to First post
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
by Hasna Jahan Suborna 192-15-13066 - Sunday, 31 January 2021, 1:05 PM
Picture of A
def Celsius_to_Fahrenheit(c) :

f = float((celsius - 32) / 1.8)

return f

def Fahrenheit_to_Celsius(f) :

c = float(fahrenheit * 1.8) + 32

return c


print("Choice your Numb_1 for convert Fahrenheit to Celsius\nChoice your Numb_2 for convert Celsius to Fahrenheit\n")

choice = int(input("Enter the number which you are choice: "))

if you_are_choice == 1:

c = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("Celsius temperature is: ",c)

elif you_are_choice == 2:

f = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print(""temperature in Fahrenheit: ", f)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Abdullah Ibne Mortuza 192-15-13265 -
def celcious(cel):
number1=(cel* (9/5)) + 32
print(number1)

def fahrenhaiet(fahren):
number2= (fahren - 32) * (5/9)
print(number2)

cel=float(input("Enter a celcious number: "))
celcious(cel)

fahren=float(input("Enter a fahrenhiet number:"))
fahrenhaiet(fahren)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Gazi Shahriar Samrat Hridoy -
void main()
{ float celsius,fahrenheit;
printf("\nEnter temperature in Fahrenheit:"); scanf("%f",&fahrenheit);
// Fahrenheit to celsius conversion formula. celsius=(fahrenheit - 32)*5/9;
// Print the result. printf("\nCelsius = %.3f",celsius); //.3f means correct to 3 decimal places.
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Mahfuzur Rahman(191-15-2638) -
def celcious(cel):
number1=(cel* (9/5)) + 32
print(number1)

def fahrenhaiet(fahren):
number2= (fahren - 32) * (5/9)
print(number2)

cel=float(input("Enter a celcious number "))
celcious(cel)

fahren=float(input("Enter a fahrenhiet number "))
fahrenhaiet(fahren)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Shariar Kabir Nayeem 192-15-2854 -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Sazzad Hossain -
def cel(celsius):
res = float((celsius - 32) / 1.8)
return res

def fah (fahrenheit):
res = float(fahrenheit * 1.8) + 32
return res

print("Choice No 1 for Fahrenheit to Celsius conversion Or Choice No 2 for Celsius to Fahrenheit conversion")

choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
res = float(cel(celsius))
print("temperature in Celsius: ",res)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
res = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", res)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Alif Pranto -
def cel(celsius):
ans = float((celsius - 32) / 1.8)
return ans
def fah (fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Choice No 1 for Fahrenheit to Celsius")
print("Choice No 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ",ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md Ashaduzzaman Maruf 192-15-2803 -
def celcious(cel):
number1=(cel* (9/5)) + 32
print(number1)

def fahrenhaiet(fahren):
number2= (fahren - 32) * (5/9)
print(number2)

cel=float(input("Enter a celcious number "))
celcious(cel)

fahren=float(input("Enter a fahrenhiet number "))
fahrenhaiet(fahren)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Abu Salkin -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Mafia Islam Sinthia 192-15-2815 -
def celcious(cel):
number1=(cel* (9/5)) + 32
print(number1)

def fahrenhaiet(fahren):
number2= (fahren - 32) * (5/9)
print(number2)

cel=float(input("Enter a celcious number "))
celcious(cel)

fahren=float(input("Enter a fahrenhiet number "))
fahrenhaiet(fahren)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md Muhiminul Islam Mahim 192-15-2850 -
def cel(celsius):
ans = float((celsius - 32) / 1.8)
return ans
def fah (fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Choice No 1 for Fahrenheit to Celsius")
print("Choice No 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ",ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Hasiba Ferdous 192-15-2820 -
def getCelsius(celsius):
result = float((celsius - 32) / 1.8)
return result


def getFahrenheit(fahrenheit):
result = float(fahrenheit * 1.8) + 32
return result


print("Choice 1 for Fahrenheit to Celsius")
print("Choice 2 for Celsius to Fahrenheit")
choice = int(input("Enter Choice Your Option"))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
result = float(getCelsius(celsius))
print("Celsius: ", result)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
result = float(getFahrenheit(fahrenheit))
print("Fahrenheit: ", result)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Md. Mehedi Hasan Sakib 192-15-2806 -
def getCelsius(celsius):
result = float((celsius - 32) / 1.8)
return result


def getFahrenheit(fahrenheit):
result = float(fahrenheit * 1.8) + 32
return result


print("Choice 1 for Fahrenheit to Celsius")
print("Choice 2 for Celsius to Fahrenheit")
choice = int(input("Enter Choice Your Option"))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
result = float(getCelsius(celsius))
print("Celsius: ", result)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
result = float(getFahrenheit(fahrenheit))
print("Fahrenheit: ", result)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Al- Maruf 192-15-2821 -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by NAZMUL HASSAN sanim -
ef Celsius_to_Fahrenheit(c) :

f = float((celsius - 32) / 1.8)

return f

def Fahrenheit_to_Celsius(f) :

c = float(fahrenheit * 1.8) + 32

return c


print("Choice your Numb_1 for convert Fahrenheit to Celsius\nChoice your Numb_2 for convert Celsius to Fahrenheit\n")

choice = int(input("Enter the number which you are choice: "))

if you_are_choice == 1:

c = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("Celsius temperature is: ",c)

elif you_are_choice == 2:

f = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print(""temperature in Fahrenheit: ", f)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Shahid Shahriar -
def cel(celsius):
ans = float((celsius - 32) / 1.8)
return ans
def fah (fahrenheit):
ans = float(fahrenheit * 1.8) + 32
return ans

print("Choice No 1 for Fahrenheit to Celsius")
print("Choice No 2 for Celsius to Fahrenheit")
choice = int (input("Enter Your Choice "))

if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
ans = float(cel(celsius))
print("temperature in Celsius: ",ans)
else:
fahrenheit = float(input("Enter temperature in Celsius: "))
ans = float(fah(fahrenheit))
print("temperature in Fahrenheit: ", ans)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Nazmus Sakib Tanim (192-15-2855) -
def cel(temp):
C = (temp - 32.0) * (0.5556)
return C

def fah(temp):
F = (temp * (1.8)) + 32.0
return F

choice = int(input("Press 1 for converting Fahrenheit to Celsius or \nPress 2 for Celsius to Fahrenheit: "))
if choice == 1:
celsius = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("\nTemperature in Celsius is: "+"{:.2f}".format(c))
elif choice == 2:
fahrenheit = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print("\nTemperature in Fahrenheit is: "+"{:.2f}".format(f))
else:
print("\nWrong Input! Please Try again")
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Sumon Bala -
ef Celsius_to_Fahrenheit(c) :

f = float((celsius - 32) / 1.8)

return f

def Fahrenheit_to_Celsius(f) :

c = float(fahrenheit * 1.8) + 32

return c


print("Choice your Numb_1 for convert Fahrenheit to Celsius\nChoice your Numb_2 for convert Celsius to Fahrenheit\n")

choice = int(input("Enter the number which you are choice: "))

if you_are_choice == 1:

c = float(input("Enter temperature in Fahrenheit: "))
c = float(cel(celsius))
print("Celsius temperature is: ",c)

elif you_are_choice == 2:

f = float(input("Enter temperature in Celsius: "))
f = float(fah(fahrenheit))
print(""temperature in Fahrenheit: ", f)
In reply to First post

Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.

by Meherol Hasan -
def Fahrenheit_to_Celsius(Fahrenheit):
celsius=float((Fahrenheit-32)/1.8)
return celsius

def Celsius_to_Fahrenheit(Celsius):
fahrenheit=float((Celsius*1.8)+32)
return fahrenheit

while 1:
x=int(input("Enter 1 for Fahrenheit to Celsius and covert Celsius to Fahrenheit input 2. Any key to exit: "))
if x==1:
Fahrenheit=float(input("Enter a in Fahrenheit: "))
print("Temperature in Celsius:",Fahrenheit_to_Celsius(Fahrenheit))

elif x==2:
Celsius=float(input("Enter a in Celsius: "))
print("Temperature in Fahrenheit:",Celsius_to_Fahrenheit(Celsius))
else: break