-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathvalue_converter.py
More file actions
59 lines (56 loc) · 2.28 KB
/
value_converter.py
File metadata and controls
59 lines (56 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def convert_temperature():
print("\nWhich conversion do you want to choose:-")
print("1. Celsius to Faranheit")
print("2. Faranheit to Celsius")
choice = int(input("Enter your choice: "))
if choice == 1:
temp = float(input("Enter temperature in celsius: "))
print(f"{temp} degree celsius is equal to {(temp*9/5)+32} degree faranheit.\n")
elif choice == 2:
temp = float(input("Enter temperature in faranheit: "))
print(f"{temp} degree faranheit is equal to {(temp-32)*5/9} degree celsius.\n")
else:
print("Invalid input...please try again\n")
def convert_currency():
print("\nWhich conversion do you want to choose:-")
print("1. Dollar to pound")
print("2. Pound to Dollar")
choice = int(input("Enter your choice: "))
if choice == 1:
value = float(input("Enter currency in dollars: "))
print(f"{value} dollars in pounds will be {value*0.73}\n")
elif choice == 2:
value = float(input("Enter currency in pounds: "))
print(f"{value} pounds in dollars will be {value/0.73}\n")
def convert_lengths():
print("\nWhich conversion do you want to choose:-")
print("1. Centimeters to foot and inches")
print("2. Foot and inches to centimeter")
choice = int(input("Enter your choice: "))
if choice == 1:
value = float(input("Enter length in cm: "))
inches = value/2.54
feet = inches/12
print(f"{value} centimeters in equal to {feet} feet and {inches} inch\n")
elif choice == 2:
feet = float(input("Enter length in feet: "))
inches = float(input("Enter length in inches: "))
length = (feet*12 + inches)*2.54
print(f"{feet} feet and {inches} inches in centimeters will be {length}\n")
print("===== Welcome to Value Converter =====")
while 1:
print("Which option would you like to choose:-")
print("1. Convert temperature")
print("2. Convert currency")
print("3. Convert lengths")
print("4. Exit")
choice = int(input("Enter your choice: "))
if choice == 1:
convert_temperature()
elif choice == 2:
convert_currency()
elif choice == 3:
convert_lengths()
elif choice == 4:
print('Exiting...')
exit(0)