Skip to content

Commit d0441f1

Browse files
Menu#2
1 parent cbb0ab5 commit d0441f1

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Conditionals/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,51 @@ def my_menu():
3939
print("Done")
4040
my_menu()
4141
```
42+
43+
### Menu Type 3:
44+
```python
45+
def my_menu():
46+
print("Welcome to the Conversion Calculator which option would you like\
47+
\n a. Miles to Kilometers\
48+
\n b. Gallons To Liters\
49+
\n c. Pounds to Kilograms\
50+
\n d. Inches To Cm\
51+
\n e. Fahrenheight To Celsius")
52+
option= str(input("Which type of conversion are you wishing to perform: "))
53+
if option == 'a' or option == 'A':
54+
print("\n\nYou are converting Miles to Km")
55+
n = float(input("What is amount of miles you wish to convert to km?: "))
56+
print(milesToKm(n))
57+
elif option == 'b' or option == 'B':
58+
print("\n\nYou are converting Gallons to Liters")
59+
g = float(input("\nWhat is amount of gallons you wish to convert to liters?: "))
60+
print(gallonsToLiters(g))
61+
elif option == 'c' or option == 'C':
62+
print("\n\nYou are converting Pounds to Kg")
63+
l = float(input("\nWhat is amount of lb you wish to convert to kg?: "))
64+
print(lbsToKg(l))
65+
elif option == 'D' or option == 'D':
66+
print("\n\nYou are converting Inches to Cm")
67+
c = float(input("\nWhat is amount of Inches you wish to convert to Cm?: "))
68+
print(inchesToCm(c))
69+
elif option == 'e' or option == 'E':
70+
print("\n\nYou are converting Fahrenheight To Celsius")
71+
cels = int(input("\nWhat is the temperature in Fahrenheight you wish to convert to Celsius?: "))
72+
print(fahrenToCels(cels))
73+
elif ValueError:
74+
print("That was a wrong choice")
75+
my_menu()
76+
else:
77+
print("Done")
78+
79+
def milesToKm(miles: int) -> float:
80+
return miles*1.60934
81+
def gallonsToLiters(gallons: float) -> float:
82+
return gallons*3.78541
83+
def lbsToKg(pounds: float) -> float:
84+
return pounds*0.453592
85+
def inchesToCm(inches: float) -> float:
86+
return inches*2.54
87+
def fahrenToCels(fahren: float) -> float:
88+
return((fahren-32)/1.8)
89+
```

0 commit comments

Comments
 (0)