Saturday, 3 August 2019

Assignment No: 10 Binary to Decimal Conversion

'''
Assignment No: 10
To input binary number from user and convert it into decimal number.
'''

def binaryToDecimal(binary): # function definition
      
    binary1 = binary 
    decimal, i, n = 0, 0, 0
    while(binary != 0): 
        dec = binary % 10
        decimal = decimal + dec * pow(2, i) 
        binary = binary//10
        i += 1
    print(decimal)     
      
  
# Driver code 
if __name__ == '__main__': 
    binaryToDecimal(100) 
    binaryToDecimal(101) 
    binaryToDecimal(1001)

60 comments:

  1. Very nice program and easy to understand

    ReplyDelete
  2. Easy practical and better understanding

    ReplyDelete
  3. Easy to do binary digit in decimal or decimal to binary no.

    ReplyDelete
  4. Binary operation are used in this programme to convert binary to decimal

    ReplyDelete
  5. Students are also convert decimal to hex

    ReplyDelete
  6. Easy to understand 😊😊

    ReplyDelete
  7. Nice sir learn many things from this program

    ReplyDelete
  8. Very simple and easy to understand

    ReplyDelete
  9. It is easy to do decimal numbers into binary or vice versa.

    ReplyDelete
  10. Program are run sir
    I'll understand

    ReplyDelete

Microsoft’s latest Surface Pro X is now available in India

  Microsoft Surface Pro X 2020 is now available in India at a starting price of Rs 1,49,999.  Here's everything you would like to unders...