Bitwise Operators

I’m at the bitwise operators lessons now but I have a simple question:

def check_bit4(input):
  mask = 0b1000
  desired = input & mask
  if desired > 0:
    return "on"
    return "off"

What does the parameter input do? It doesn’t have any arguments passed to it as far as I’m aware. So how can it compare with the variable mask ?
(This is my whole code)

we can pass arguments at function call to the parameter, until the function is called the function isn’t executed, so the parameter (input) just acts as placeholder

Yes but the function isn’t called anywhere :smiley: … But the code still returns “on” or “off” … how ?

Edit: typo’s

well, the exercise needs to validate the code, the easiest way to do so is to call the function and compare the returned result. This might cause output in the lesson. Go run on for example, there will be no output

1 Like

Ok yeah it makes sense … I always get confused with parameters.