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

Commit ac976e6

Browse files
authored
Merge pull request #73 from alananayaa/development
Binary to Decimal and viceversa #66
2 parents c965912 + c47a76b commit ac976e6

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)