Skip to Content
Introduction to Bitwise Operators
int()'s Second Parameter

Python has an int() function that you’ve seen a bit of already. It can turn non-integer input into an integer, like this:

int("42") # ==> 42

What you might not know is that the int function actually has an optional second parameter.

int("110", 2) # ==> 6

When given a string containing a number and the base that number is in, the function will return the value of that number converted to base ten.



In the console are several different ways that you can use the int function’s second parameter.On line 7, use int to print the base 10 equivalent of the binary number 11001001.

Folder Icon

Take this course for free

Already have an account?