======= Convert Decimal to Binary in Python ========
my_int = 10;
#Method 1: using bin
n1 = bin(my_int).replace("0b", "") #1010
or n1 = bin(my_int)[2:]
#Method 2: using format
n2 = "{0:b}".format(my_int)
or n2 = format(my_int, 'b') #1010
a = 10
#this will print a in binary
bnr = bin(a).replace('0b','')
x = bnr[::-1] #this reverses an array
while len(x) < 8:
x += '0'
bnr = x[::-1]
print(bnr)
print(str(1)) # convert number to string
print(int("1")) # convert string to int
print(float(1)) # convert int to float
print(list('hello')) # convert string to list
print(tuple('hello')) # convert string to tuple
print(list((1, 2, 3))) # convert tuple to list
print(tuple([1, 2, 3])) # convert list to tuple
print(bool(1)) # convert a number to boolean
print(bool(0)) # convert a number to boolean
print(bool("")) # convert a string to boolean
print(bool("data")) # convert string to boolean
print(bin(10)) # convert an integer to a binary string
print(hex(10)) # convert an integer to a hex string
print(oct(10)) # convert an integer to an octal string
number = 5
print('The binary equivalent of 5 is:', bin(number))
# output - The binary equivalent of 5 is: 0b101
# "0b" indicates that this is a binary number
# 101 is the number (2**2 * 1) + (2**1 * 0) + (2**0 * 1) = 5