Need help on this lesson

# 6. Practice makes perfect, answer?

this is my code , i don't know how to multiply three times , i tried * & ** but got refused

def cube(n):

return n**3

def by_three(n):

if n%3 == 0 :

return cube(n)

else :

return False

n = raw_input

spacing

[def cube(n):

tab cubed = n**3

tab return cubed

def by_three(n):

tab if n%3 == 0 :

tab tab return cube(n)

tab else :

tab tab return False

n = raw_input

**vmtech**#8

i am not sure this is correct chipjumper

return False

n = raw_input

because you need to define the value for function cube

so i believe should be something similar to

cube(10) cube(9) or what ever number you like within ()

but i might be wrong as i am not experienced

**teramaster90805**#10

I need help. This is my code:

def cube(n):

cubed=n**3

return cubed

def by_three(n):

if n%3 == 0:

print "n is divisible by 3"

return cube(n)

else :

print "n is not"

return False

n=raw_input

I get a error message saying that the "d" in cubed on the second line is an expected an indented block.

**zeziba**#11

I think your indention is off, should be more like

```
def cube(n):
cubed=n**3
return cubed
def by_three(n):
if n%3 == 0:
print "n is divisible by 3"
return cube(n)
else :
print "n is not"
return False
n=raw_input # Why is this in your program?
```

**lhtorres**#12

def cube(number):

return number ** 3

def by_three(number):

if number % 3 == 0:

return cube(number)

else:

return False

That's what I have and it passed. Although I notice I returned and modified the argument all in one step. Is that still correct (againit passes) and is it 'better' to cube number then call the function 'cube' on a new line?

**teramaster90805**#14

Thx, it worked! I dont really know what the "n=raw_input" was. I just saw that someone else had that in their code and it worked for them n i thought i should give it a try

**_heizenburg**#15

I guess this was highly confusing for most of us :

```
def cube(number):
cubed = number**3
return cubed
def by_three(number):
if number % 3 == 0:
return cube(number)
else:
return False
```

cube is not a returned statement, but rather cubed (It is assigned first though).

The second function is defined by

`by_three`

, whilst the argument is "still"`number`

.The rest is history rather

`

**_heizenburg**#17

The argument `number`

to the power of `3`

( number ^3 ) or in python terms `number**3`

is a `cubed`

"cube" .

Logically it represents the argument `number`

`cubed`

And to answer your question diligently we `return`

whatever is defined within the function which in this case is the variable `cubed`

.

More help How is returning the output of a function different than printing it?

**microsolver51793**#19

You have to do this because the "%" is basically a dividation symbol but instead of the answer being how many times the number goes into a number then whats left is the answer, so 5%3==2 and the == symbol is used for the code to check if both sides match up, so 3%3==0 3 goes into three with no remainder so its zero

**tpoltorak**#20

This is what I really don't get: if the value of the variable **number** is not specified anywhere in the code then how can it return anything? Yet the code worked.

**sgtmike70**#21

that 'if' statement is checking to see if the number is divisible by 3 and no remainder, it uses the modulus (%) to do this and since you are not assigning a value but are testing to see if it's true, you use '=='