-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython_code_number_conversion_app.py
More file actions
69 lines (59 loc) · 1.8 KB
/
python_code_number_conversion_app.py
File metadata and controls
69 lines (59 loc) · 1.8 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
60
61
62
63
64
65
66
67
68
69
'''
to_do:
1->define function :decimal_to_hexa(),decimal_to_octa() & vise-versa
2->check all errors and list them
3->change the upper() method to something else
4->examine time & space complexity
advanced:
1->use Tkinter for GUI
2->use CSS
done:
1->check box,decimal_to_binary()
'''
import sys
def main_menu():
while(1):
print("\npress 1: decimal to binary\npress 2: decimal to hexadecimal\npress 3: decimal to octadecimal\npress 0: Quit".upper())
button = int(input("\nenter your choice: ".upper()))
if button == 1:
print(decimal_to_binary())
check()
elif button == 2:
print(decimal_to_hexa())
check()
elif button == 3:
print(decimal_to_octa())
check()
elif button == 0:
print("\n!exit sucessfully!".upper())
exit(0)
else:
print("\nwrong choice!\ntry again!".upper())
else:
print("\n!exi:wq
t sucessfully!".upper())
exit(0)
def decimal_to_binary():
number = int(input("enter the number: ".upper()))
binary = format(number, 'b')
return("Decimal to Binary Conversion is: {}".format(binary))
def decimal_to_hexa():
pass
def decimal_to_octa():
pass
def check():
while(1):
ck = input("\ndo you want to continue?(y/n)\n".upper())
if ck == 'y':
return 1
elif ck == 'n':
return 2
else:
print("\nwrong choice!\ntry again!".upper())
print("\n😁😁!welcome to number conversion app!😁😁".upper())
while(1):
try:
main_menu()
except(ValueError):
print("\nsomething went wrong!!\nenter input correctly!".upper())
continue