forked from abhishekdoifode1/Hacktoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnitConverter.py
62 lines (52 loc) · 1.49 KB
/
UnitConverter.py
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
60
61
62
def print_menu():
print('1. Metre')
print('2. Inch')
print('3. Centimetre')
# cm and m
def cm_m():
cm = float(input('Enter Lenth in Centimetre:'))
m = cm/100
print('Lenth in metre:{0}'.format(m))
def m_cm():
m = float(input('Enter Lenth in Metre:'))
cm = m*100
print('Lenth in Centimetre:{0}'.format(cm))
# cm and in
def cm_inch():
cm = float(input('Enter Lenth in Centimetre:'))
inch = cm/2.5400000025908
print('Lenth in Inch:{0}'.format(inch))
def inch_cm():
inch = float(input('Enter Lenth in Inch:'))
cm = inch*2.5400000025908
print('Lenth in Centimetre:{0}'.format(cm))
# m and in
def m_inch():
m = float(input('Enter Lenth in Metre:'))
inch = m*39.3700787
print('Lenth in Inch:{0}'.format(inch))
def inch_m():
inch = float(input('Enter Lenth in Inch:'))
m = inch/39.3700787
print('Lenth in Metre:{0}'.format(m))
if __name__ == "__main__":
while True:
print('SELECT CONVERSION UNITS')
print_menu()
a = input('Enter First Unit:')
b = input('Enter Second Unit:')
if a == '1' and b == '2':
m_inch()
if a == '1' and b == '3':
m_cm()
if a == '2' and b == '1':
inch_m()
if a == '2' and b == '3':
inch_cm()
if a == '3' and b == '1':
cm_m()
if a == '3' and b == '2':
cm_inch()
answer = input('Do You Want to Exit?(y) for Yes:')
if answer == 'y':
break