Line 1 – def
cube(number): Line 1 defines a function named cube with an argument named number. It ends with a colon.
Line 2 – return
number **3 Line 2 is indented four spaces and returns the contents
of the variable number cubed.
Line 3 – def
by_three(number): Line three defines a function named by_three with the argument named number. It ends with a colon.
Line 4 – if number %3==0: Line 4 is indented four spaces. Line four is
an if statement that checks to see if the content of the variable number is divisible by three.
The % 3 ==0 is the modulo(%). Modulo divides the contents of number by three and checks for the remainder. If the content of the variable number has a remainder of 0 it will be == to 0 and is divisible by 3. If there is any remainder, the number would not be divisible by 3. The if statement ends with a colon.
Line 5 – return cube(number) Line 5 returns the result of the function named cube created in line 1. It has to be indented an additional 4 spaces.
Line 6 – else: Line 6 creates an else statement.
Line 7 – return False Line 7 will return the word False if the
content of the variable number is not divisible by three.
Line 8 – by_three(4) Line 8 calls the by_three function with the argument 4.
Running the code –
The program starts when the function is called in line 8. It
will place a 4 into the variable named number. Line 4 will replace the content of number
with a 4. Which will result in if 4 %3
==0. Since 4 divided by 3 has a remainder of 1 it is not equal to zero and
the program will move to line 6, the else
statement. Line 7 will print False.
If the content of line 8 was changed to by_three(9) , line 4 will
replace the content of the variable number
with a 9. Which will result in if 9 %3 ==0. Since 9 divided by 3 has a
remainder of 0 it is equal to 0 and the program will move to line 5 which will
call the cube(number) function
created in line 1 and return the cubed number.