Python program to convert any base to decimal by using int() method
Given a number and its base, the task is to convert the given number into its corresponding decimal number. The base of number can be anything like digits between 0 to 9 and A to Z. Where the value of A is 10, value of B is 11, value of C is 12 and so on.
Input : '1011'
base = 2
Output : 11
Input : '1A'
base = 16
Output : 26
Input : '12345'
base = 8
Output : 5349
- Given number in string form and base
- Now call the builtin function int(‘number’, base) by passing the two parameters any base number in String form and base of that number and store the value in temp
- Print the value temp
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!