Write a program to find number of bits necessary to represent an integer in binary


Topic: Write a program to find number of bits necessary to represent an integer in binary

Solution

num = int(input("Enter an integer number: "))
bits = num.bit_length()
print("bits required to store ", num, " = ", bits)
print("binary value of ", num, " is = ", bin(num))



List all Python Programs