Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit c47a76b

Browse files
committed
issue #66 created python script
1 parent c965912 commit c47a76b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
try:
2+
menu = int(input("Choose an option: \n 1. Decimal to binary \n 2. Binary to decimal\n Option: "))
3+
if menu < 1 or menu > 2:
4+
raise ValueError
5+
if menu == 1:
6+
dec = int(input("Input your decimal number:\nDecimal: "))
7+
print("Binary: {}".format(bin(dec)[2:]))
8+
elif menu == 2:
9+
binary = input("Input your binary number:\n Binary: ")
10+
print("Decimal: {}".format(int(binary, 2)))
11+
except ValueError:
12+
print ("please choose a valid option")

0 commit comments

Comments
 (0)