аватар question@mail.ru · 01.01.1970 03:00

What does & in Python mean?

Good evening to everyone! Please tell me what the operator & amp; in Python means? (this is not connected with many).
for example, there is a code that calculates whether the user is an integrated number of deuces:

  n =  int  ( input  ())   if  n & amp; (n -  1 ):   print  ( '" this number is not a stove of the two' )   else :   print  ( is the number - the degree of deuces' )     

which in the second line means n & amp; (n-1) ?

аватар answer@mail.ru · 01.01.1970 03:00

for numbers & amp; will define the beaten "" and "" (). In the binary reckoning system 2 ** n is 1, after which there is n zeros, and (2 ** n - 1) - n units. For example, (Dec) 32 = (BIN) 100000 , and (Dec) 31 = (BIN) 11111 . Among all the positive numbers, only the degrees of deuces do not have total units with the previous number. The code contains an error: 0 He considers the degree of deuce.

Latest

Similar