Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

binary list to decimal

def binarylist_to_decimal(lst):
    power=0
    nb=0
    for i in range(len(lst)-1,0-1,-1):
        nb+=lst[i]*(2**power)
        power+=1
    return nb

bin_lst=[1,1,1,1,1,1,1,1]
power=0
nb=0
print(binarylist_to_decimal(bin_lst))

# 255
Comment

PREVIOUS NEXT
Code Example
Python :: python - caéculate the average based on the level of a second column in a df 
Python :: convert excel workbook to dataframe 
Python :: dataframe python 
Python :: code for test and train split 
Python :: python get index of substring in liast 
Python :: python printing hello world 
Python :: reply to a message discord.py 
Python :: python only decimal part 
Python :: hyperparameters 
Python :: random integer 
Python :: python split string with a seperator 
Python :: exponential python 
Python :: pass args and kwargs to funcitons 
Python :: array in python 
Python :: python find if string contains space 
Python :: create data frame in panda 
Python :: change value in nested dictionary python 
Python :: python hash and unhash string 
Python :: request post python with api key integration 
Python :: python multiply each item in list 
Python :: most common letter in string python 
Python :: use mark down with flask 
Python :: combining strings in python 
Python :: python typing list of possible values 
Python :: pandas difference between two dataframes 
Python :: NumPy flip Syntax 
Python :: how many numbers greater than 100 using pytho 
Python :: range() python 
Python :: how to append data in excel using python 
Python :: python print variable and string 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =