From d0441f16981f0098df4e74cd5d05db4fe22b7baf Mon Sep 17 00:00:00 2001 From: Omar Belkady <31806568+omarbelkady@users.noreply.github.com> Date: Sun, 4 Apr 2021 21:11:16 +0100 Subject: [PATCH] Menu#2 --- Conditionals/README.md | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Conditionals/README.md b/Conditionals/README.md index 371f102..248d405 100644 --- a/Conditionals/README.md +++ b/Conditionals/README.md @@ -39,3 +39,51 @@ def my_menu(): print("Done") my_menu() ``` + +### Menu Type 3: +```python +def my_menu(): + print("Welcome to the Conversion Calculator which option would you like\ + \n a. Miles to Kilometers\ + \n b. Gallons To Liters\ + \n c. Pounds to Kilograms\ + \n d. Inches To Cm\ + \n e. Fahrenheight To Celsius") + option= str(input("Which type of conversion are you wishing to perform: ")) + if option == 'a' or option == 'A': + print("\n\nYou are converting Miles to Km") + n = float(input("What is amount of miles you wish to convert to km?: ")) + print(milesToKm(n)) + elif option == 'b' or option == 'B': + print("\n\nYou are converting Gallons to Liters") + g = float(input("\nWhat is amount of gallons you wish to convert to liters?: ")) + print(gallonsToLiters(g)) + elif option == 'c' or option == 'C': + print("\n\nYou are converting Pounds to Kg") + l = float(input("\nWhat is amount of lb you wish to convert to kg?: ")) + print(lbsToKg(l)) + elif option == 'D' or option == 'D': + print("\n\nYou are converting Inches to Cm") + c = float(input("\nWhat is amount of Inches you wish to convert to Cm?: ")) + print(inchesToCm(c)) + elif option == 'e' or option == 'E': + print("\n\nYou are converting Fahrenheight To Celsius") + cels = int(input("\nWhat is the temperature in Fahrenheight you wish to convert to Celsius?: ")) + print(fahrenToCels(cels)) + elif ValueError: + print("That was a wrong choice") + my_menu() + else: + print("Done") + +def milesToKm(miles: int) -> float: + return miles*1.60934 +def gallonsToLiters(gallons: float) -> float: + return gallons*3.78541 +def lbsToKg(pounds: float) -> float: + return pounds*0.453592 +def inchesToCm(inches: float) -> float: + return inches*2.54 +def fahrenToCels(fahren: float) -> float: + return((fahren-32)/1.8) +```