Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

binary, decimal, hex conversion python

print("
BASE 10 TO BASE 2 TO 16
")

decimal_numbers = [4799, 400]
for number in decimal_numbers:
    binary = bin(number)[2:]
    hexadec = hex(number)[2:]
    print(number, binary, sep=" ==> ")
    print(number, hexadec, sep=" ==> ")


print("
BASE 2 TO BASE 10 AND 16
")

binary_list = ["1111110001001110", "111111"]

for binary in binary_list:

    decimal = int(binary, 2)
    hexa = hex(decimal)[2:]
    print(binary, decimal, sep=" >>>> ")
    print(binary, hexa, sep=" >>>> ")


print("
BASE 16 TO BASE 10 AND 2 NOW
")

hex_numbers = ["3C7D", "FC4E"]
for hexa in hex_numbers:
    decimal_from_hex = int(hexa, 16)
    binary_from_hex = bin(int(hexa, 16))[2:]

    print(hexa, decimal_from_hex, sep="==")
    print(hexa, binary_from_hex, sep="==")

Comment

PREVIOUS NEXT
Code Example
Python :: python run exe 
Python :: python get first character of string 
Python :: check how many times a substring appears in a string 
Python :: excel write in row 
Python :: install different python version debian 
Python :: how to use h5 file in python 
Python :: pyqt menubar example 
Python :: python delete from list 
Python :: pandas dataframe filter 
Python :: django sessions 
Python :: set type of column pandas 
Python :: python obfuscator 
Python :: python 3 custom sort with compare 
Python :: django timezone settings 
Python :: python multiline comment 
Python :: python how to make multiple box plots 
Python :: decode multipart/form-data python 
Python :: flatten image python numpy 
Python :: python random geneator 
Python :: directory path with python argparse 
Python :: what is self in python 
Python :: django add middleware 
Python :: two dimensional array python 
Python :: tuple plot python 
Python :: read excel spark 
Python :: Remove empty strings from the list of strings 
Python :: dropna threshold 
Python :: process rows of dataframe in parallel 
Python :: join dataframe pandas by column 
Python :: python replace line in file 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =