Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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))
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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... ")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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()
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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... ")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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))
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
Celsius = (Fahrenheit - 32) * 5.0/9.0
print ("Temperature:", Fahrenheit, "Fahrenheit = ", Celsius, " C")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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))
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
return (n*1.8)+32
n = 20
print(int(Fah_to_Cel(n)))
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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))
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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))
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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"
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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))
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
{ 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.
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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")
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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)
Re: Write a program to convert Fahrenheit to Celsius or vice versa using functions.
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