Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
convert from F to C and vice versa
  • Loading branch information
izikdepth authored Apr 14, 2023
1 parent 3667c9a commit 52734a3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions temperature.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

def celsius_to_fahrenheit(celsius):
return (celsius * 9/5) + 32

def fahrenheit_to_celsius(fahrenheit):
return (fahrenheit - 32) * 5/9

temp = float(input("Enter temperature: "))
unit = input("Enter temperature unit (C or F): ")

if unit == "C".lower():
converted_temp = celsius_to_fahrenheit(temp)
print("{:.2f}C is equivalent to {:.2f}F".format(temp, converted_temp))

elif unit == "F".lower():
converted_temp = fahrenheit_to_celsius(temp)
print("{:.2f}F is equivalent to {:.2f}C".format(temp, converted_temp ))

else:
print("Error : invalid unit entered, please enter C or F")

0 comments on commit 52734a3

Please sign in to comment.