# Binary to Decimal Converter – Assignment Example

The paper "Crucial Secrets of Reference Checking" is an outstanding example of an assignment on logic and programming. The following python program converts binary numbers to decimal numbers. The program converts both the unsigned and signed values. The program converts the binary number to decimal numbers using the technique of casting. The input is taken from the user information of a string integer.
The output of the program after testing with binary values is as shown in the screenshots below
#Calculates the decimal value (base 10) of an unsigned number
#Calculates the decimal value (base 10) of a signed number using 2s  complement
#The conversion from the Binary to decimal uses a data type casting
#The expected input of the program should be:
# 1. A binary number (a string of 0s and 1s)
# 2. Whether the number is unsigned or 2s complement
while True:
try:  Binary_Number=raw_input("Enter Your Binary Number: ")
#Getting the binary value from the user Decimal_Number=int(Binary_Number,2)
#Converting the binary value to decimal by casting
except ValueError: #Printing an error when the user enters a non-binary number
print "Your Entry is not a binary number, please enter a binary number"
else:
break#Terminating the program
print Decimal_Number#Showing the converted value decimal value to the user