Skip to content

Commit 97f0af6

Browse files
Formatted Menu To Output to two decimal Places
1 parent d0441f1 commit 97f0af6

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

Conditionals/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,28 @@ def my_menu():
5353
if option == 'a' or option == 'A':
5454
print("\n\nYou are converting Miles to Km")
5555
n = float(input("What is amount of miles you wish to convert to km?: "))
56-
print(milesToKm(n))
56+
s = milesToKm(n)
57+
print("%.2f"%s)
5758
elif option == 'b' or option == 'B':
5859
print("\n\nYou are converting Gallons to Liters")
5960
g = float(input("\nWhat is amount of gallons you wish to convert to liters?: "))
60-
print(gallonsToLiters(g))
61+
b=gallonsToLiters(g)
62+
print("%.2f"%b)
6163
elif option == 'c' or option == 'C':
6264
print("\n\nYou are converting Pounds to Kg")
6365
l = float(input("\nWhat is amount of lb you wish to convert to kg?: "))
64-
print(lbsToKg(l))
66+
c=lbsToKg(l)
67+
print("%.2f"%c)
6568
elif option == 'D' or option == 'D':
6669
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))
70+
d = float(input("\nWhat is amount of Inches you wish to convert to Cm?: "))
71+
e = inchesToCm(d)
72+
print("%.2f"%e)
6973
elif option == 'e' or option == 'E':
7074
print("\n\nYou are converting Fahrenheight To Celsius")
7175
cels = int(input("\nWhat is the temperature in Fahrenheight you wish to convert to Celsius?: "))
72-
print(fahrenToCels(cels))
76+
h = fahrenToCels(cels)
77+
print("%.2f"%h)
7378
elif ValueError:
7479
print("That was a wrong choice")
7580
my_menu()
@@ -86,4 +91,5 @@ def inchesToCm(inches: float) -> float:
8691
return inches*2.54
8792
def fahrenToCels(fahren: float) -> float:
8893
return((fahren-32)/1.8)
94+
my_menu()
8995
```

0 commit comments

Comments
 (0)