Sort the code

Report a typo

The program below contains the function and one extra line that is not a part of this function. The function performs the following operations:

  1. It takes variable b as an argument.

  2. It uses a keyword to work with variable a.

  3. It prints the remainder of dividing a by b (a % b) .

  4. After that, it changes the value of a to b.

Unfortunately, the lines of code have been mixed. Put them in the correct order and add the necessary indentation.

There is an extra line that is not supposed to be in the program, leave it at the last position outside of the function (i.e., without indentation).

The function is not nested: it is not defined inside any other function.

Tip: Note that remainder() does not take a as its argument but the variable is used inside the function. This means that in the code, the variable is declared either above or below the function. Which keyword should be used so that this variable can be accessed from the inside of the function? Also, this keyword needs to be used before working with a inside the function.

Reorder lines using drag or arrows. Adjust indentation with left buttons
                def remainder(b):
              
                nonlocal a
              
                print(a % b)
              
                global a
              
                a = b
              
___

Create a free account to access the full topic