# Practice make perfect...or frustration

#1

I can get the code to run but I want to see what it's doing. So after getting it to work, I attempted to add a simple print statement, and it fails every time. At this point I'm so frustrated I want to quit, but I won't because I REALLY desire to program. Every single exercise I try to do something beyond scope, to see if I'm "getting it" and without exception, I fail. Is this just not for me or were the simple print exercises just not adequate?

``````def cube(number):
#cube(number) = number**3
return number ** 3

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

I've also tried

``````cube(9)
print cube(number)``````

and

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

and this one is really bad.....

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

....and at LEAST 50 other variations thereof.

Any guidance would be greatly appreciated.

Sincerely, Frustrated Inc.

#2

def cube(number):
return number**3

def by_three(number):
if number % 3 ==0:
return cube(number)
else:
return False
print by_three(9)

have to make sure print is in the same indent as def and that you are calling by_three not cube

#4

I've faced the same challenges, believe me, but you're very close. Try, in the first example:

``````def cube(number):
#cube(number) = number**3
return number**3
print cube(9)``````

=> do 'print cube(9)' instead of 'print cube', because 'print cube' just prints the literal memory location of the function cube(number).

=>If you just run 'cube(9)' the correct value is returned, it just has to be accessed.

The extended version:

``````def cube(number):
#cube(number) = number**3
return number ** 3

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

print by_three(9)``````

I've found it helps to run code through this:
http://www.pythontutor.com/visualize.html#mode=edit
When you hit 'Visualize Execution', it shows every step of what the program is doing. Hope this helps!

#5

just curious, where did we get the 9 from? checked again before i asked, and was not in the instructions or hint.