Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert any base to decimal python

n = int(input());
b = int(input());

def AnyToDec(n,b):
    # Write your code here
    p=1
    res = 0
    while(n>0):
        rem = n%10
        n = int(n/10)
        res = res + p*rem
        p = p * b
    return res    

if __name__ == "__main__":
    res = AnyToDec(n,b)
    print(res)
Comment

PREVIOUS NEXT
Code Example
Python :: how to delete records in pandas before a certain date 
Python :: join two numpy arrays 
Python :: python read text file look for string 
Python :: python emoji 
Python :: savefig resolution 
Python :: how to convert png to pdf with python 
Python :: sqlalchemy create engine PostgreSQL 
Python :: scikit learn svm 
Python :: dataframe change specicf values in column 
Python :: python check if input is between two values 
Python :: python inspect source code 
Python :: UnavailableInvalidChannel error in conda 
Python :: df drop column 
Python :: click button in selenium python 
Python :: append attribute ofpython 
Python :: python check numpy arrays equal 
Python :: python split on first occurrence 
Python :: pygame.key.get_pressed() 
Python :: add rectangle matplotlib 
Python :: python drop axis 
Python :: install django rest_framework 
Python :: sort tuple list python 
Python :: sort value_counts output 
Python :: python cartesian product 
Python :: discord get author slash command 
Python :: python get last key in dict 
Python :: remove character python 
Python :: python - show repeted values in a column 
Python :: get biggest value in array python3 
Python :: if in lambda function python 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =