The int() function in Python converts a string to an integer. But this function has the second default parameter: base. The base can be between 2 (you need to have at least 2 different values) and 36 (numbers + letters). The default value is 10.
Both examples return the same result:
This means, by how many elements the value will be represented. Look at the following table to see how it works.
|Base||available numbers and letters|
Now, take a look at the following examples:
All of these lines return the same result, which is 9999.
If you want to convert an integer to binary (2), octal (8), hex (16) or any other base between 2 and 36, you can use the following function.
Now use the following code to display values.
It will return the following result.