Skip to content

Commit 92b5ed1

Browse files
Better Formatting
1 parent 97f0af6 commit 92b5ed1

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

Conditionals/README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,32 @@ def my_menu():
5454
print("\n\nYou are converting Miles to Km")
5555
n = float(input("What is amount of miles you wish to convert to km?: "))
5656
s = milesToKm(n)
57-
print("%.2f"%s)
57+
formatted_s = "{:.2f}".format(s)
58+
print(str(n)+" miles is equal to "+ str(formatted_s) + " kilometers.")
5859
elif option == 'b' or option == 'B':
5960
print("\n\nYou are converting Gallons to Liters")
6061
g = float(input("\nWhat is amount of gallons you wish to convert to liters?: "))
6162
b=gallonsToLiters(g)
62-
print("%.2f"%b)
63+
formatted_b="{:.2f}".format(b)
64+
print(str(g)+" gallons is equal to "+ str(formatted_b) + " liters.")
6365
elif option == 'c' or option == 'C':
6466
print("\n\nYou are converting Pounds to Kg")
6567
l = float(input("\nWhat is amount of lb you wish to convert to kg?: "))
6668
c=lbsToKg(l)
67-
print("%.2f"%c)
69+
formatted_c="{:.2f}".format(c)
70+
print(str(l)+" lbs is equal to "+ str(formatted_c) + " kilograms.")
6871
elif option == 'D' or option == 'D':
6972
print("\n\nYou are converting Inches to Cm")
7073
d = float(input("\nWhat is amount of Inches you wish to convert to Cm?: "))
7174
e = inchesToCm(d)
72-
print("%.2f"%e)
75+
formatted_e = "{:.2f}".format(e)
76+
print(str(d)+" inches is equal to "+ str(formatted_e) + " centimeters.")
7377
elif option == 'e' or option == 'E':
7478
print("\n\nYou are converting Fahrenheight To Celsius")
75-
cels = int(input("\nWhat is the temperature in Fahrenheight you wish to convert to Celsius?: "))
79+
cels = float(input("\nWhat is the temperature in Fahrenheight you wish to convert to Celsius?: "))
7680
h = fahrenToCels(cels)
77-
print("%.2f"%h)
81+
formatted_h = "{:.2f}".format(h)
82+
print(str(cels)+" degrees Fahrenheight is equal to "+str(formatted_h)+ " degrees Celsius")
7883
elif ValueError:
7984
print("That was a wrong choice")
8085
my_menu()

0 commit comments

Comments
 (0)