filmov
tv
Binary to Decimal & Decimal to Binary Conversion in Python | #Shorts by OsChannel

Показать описание
Subscribe to OsChannel for more such tutorial videos, tips and tricks.
# About this video:
This video contains a way to convert Decimal Numbers to Binary and then converting back the Binary Numbers to Decimal Format using the bin() and int() functions in Python.
Let's say we have a number x = 15
To convert to Binary format use bin(x) which gives the output 0b1111
the '0b' at the beginning represents binary format number.
To Convert the Binary number back to Decimal format we can use the int() function with a base of 2 as folows int('0b1111', 2) and this gives us the output as 15.
We can use slicing to get rid of the binary representation prefix '0b' like this: bin(x)[2:] and it gives it the binary digits 1111. To convert back these binary digits we can use int() function again with base of 2 as follows: int(1111, 2) and this gives back Decimal Number 15.
# About OsChannel:
# Watch all #Short Videos by Oschannel:
# CHANNEL LINK:
# LINK TO MY WEBSITE:
#Python #Binary #PythonShorts #PythonNumbers
# About this video:
This video contains a way to convert Decimal Numbers to Binary and then converting back the Binary Numbers to Decimal Format using the bin() and int() functions in Python.
Let's say we have a number x = 15
To convert to Binary format use bin(x) which gives the output 0b1111
the '0b' at the beginning represents binary format number.
To Convert the Binary number back to Decimal format we can use the int() function with a base of 2 as folows int('0b1111', 2) and this gives us the output as 15.
We can use slicing to get rid of the binary representation prefix '0b' like this: bin(x)[2:] and it gives it the binary digits 1111. To convert back these binary digits we can use int() function again with base of 2 as follows: int(1111, 2) and this gives back Decimal Number 15.
# About OsChannel:
# Watch all #Short Videos by Oschannel:
# CHANNEL LINK:
# LINK TO MY WEBSITE:
#Python #Binary #PythonShorts #PythonNumbers