Avatar ·

What does & mean in Python?

📁 multitude, Advanced Python Topics, example

Good evening everyone! Please tell me, what does the & operator mean in Python? (it's not related to sets).
For example, there is code that checks whether a number entered by the user is a power of two:

n = int(input())if n & (n - 1):    print('This number is NOT a power of two')else:    print('This number is a power of two')

What does n & (n-1) mean in the second line?

Avatar ·

Very difficult question)

All the same, a person is interviewed by a person who has their own idea of who a Senior is. For some, it's a person who knows how to estimate algorithm complexity and can write several sorting methods on a piece of paper. For others, it's a person who can answer a question like "What is the difference between synchronized, ReentrantLock, and AtomicReference?"

For me, the gradation is roughly like this:

Junior Basic knowledge of core Java (collection types and the difference between them, stopping/starting threads, what generics are, the three "pillars" of OOP). For libraries, questions are purely superficial.

Developer Everything that junior knows + good knowledge of the libraries listed in the resume and that I need. If it's written that a person knows XSLT, but I don't need it now and I know

Log in to leave an answer

Blogs