baseconverter.py

Created by tracy-pratt-1

Created on October 24, 2025

1.62 KB

This script will take a number in any base (2-16), and convert it to another base (2-16).

Method: First, it converts all numbers (regardless of the goal) to base 10. Then it will either return the base 10 value it that is the goal, or converts to the target base.

Because a crucial part of this script is to convert all numbers to base 10, the script will return the base 10 conversion AND the desired conversion, if base 10 is not the goal nor the initial base.

This script has two functions defined, convert_to_10 and convert_from_10. These two functions are helper functions that do the mathematical computation converting numbers to and from base 10.


During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.