Skip to content

Commit ce9e3ad

Browse files
authored
Add files via upload
1 parent d0477d0 commit ce9e3ad

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

C_to_F_conversion.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
def C_to_F(x):
2+
'''
3+
This function converts the temperature entered from
4+
5+
Degree Celsius(C) to Degree Fahrenheit(F)
6+
'''
7+
8+
C = (5 * (x - 32))/9
9+
10+
return C
11+
12+
13+
def F_to_C(x):
14+
'''
15+
This function converts the temperature entered from
16+
17+
Degree Fahrenheit(F) to Degree Celsius(C)
18+
'''
19+
20+
F = ((9 * x) / 5) + 32
21+
22+
return F
23+
24+
25+
ans = 'y'
26+
27+
while ans.lower() == 'y':
28+
29+
print("\t\t\tMain Menu\n")
30+
print("1. Degree C to Degree F \n2. Degree F to Degree C\n")
31+
32+
choice = int(input("Enter your choice: "))
33+
34+
print()
35+
temp = float(input("Enter temperature: "))
36+
print()
37+
38+
if choice == 1:
39+
print("The temperature ", temp, 'C to F is: ', C_to_F(temp), 'F')
40+
41+
elif choice == 2:
42+
print("The temperature ", temp, 'F to C is: ', F_to_C(temp), 'C')
43+
44+
else:
45+
print("Option entered is INVALID\n")
46+
47+
ans = input("Do you wish to continue(Y/n): ")

0 commit comments

Comments
 (0)