Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

number system 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 :: how to run .exe from python 
Python :: convert float to int python 
Python :: import csrf_exempt django 
Python :: python open all files of type csv 
Python :: matplotlib savefig size 
Python :: check if there are duplicates in list 
Python :: menubar pyqt 
Python :: how do you write a function in python 
Python :: pd.dataframe initial columns 
Python :: python stack 
Python :: strftime 
Python :: qtablewidget clear python 
Python :: Python t date from a timestamp 
Python :: sklearn support vector machine 
Python :: create requirement .txt 
Python :: open word from python 
Python :: append python 
Python :: select realted for foreign key table in django 
Python :: numpy weighted average 
Python :: django collectstatic 
Python :: python create directory if non existent 
Python :: check if a value is nan pandas 
Python :: how to get the value out of a dictionary python3 
Python :: python read json file array 
Python :: python youtube download mp3 
Python :: how to install python libraries using pip 
Python :: how to convert pdf to word using python 
Python :: how to colour letters in python 
Python :: python check if list contains 
Python :: Python Changing Directory 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =