d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Looking For Alittle Help > Code Academy
Add Reply New Topic New Poll
Member
Posts: 8,078
Joined: Apr 17 2007
Gold: 5,023.00
May 20 2015 09:56pm
I'm trying to learn Python/coding on Code Academy and I've been doing ok so far. But For some reason I cannont figure out what I am suppose to do.. I've tried so many different things but I get the same error. "cube(1) returned None"

I'm very new to coding so sorry If this is a noob question, but any help would be much appreciated it and I'm trying to move on and learn but I've been stuck on this for the past day. I guess it doesen't help I suck at math too lol.

Just need to know what am I doing wrong? Is the entire code off or am I jsut missing something simple? I tried a bunch of dif stuff after return under cube(number) but nothign seems to work =[

Thanks.

Here a pic if this helps.



here's a link if the pic is too small to read: http://i139.photobucket.com/albums/q287/4Slim2Jim0/jsphelp.png

Thanks in advance!
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 20 2015 10:02pm
1) your cube function isn't do what it's supposed to be doing.
2) your cube function isn't returning anything in the if clause, nor in the missing else clause
3) your by_three function doesnt accept a param
Member
Posts: 8,078
Joined: Apr 17 2007
Gold: 5,023.00
May 20 2015 10:06pm
Quote (carteblanche @ May 20 2015 11:02pm)
1) your cube function isn't do what it's supposed to be doing.
2) your cube function isn't returning anything in the if clause, nor in the missing else clause
3) your by_three function doesnt accept a param


would you be able to show me how it's suppose to look so i can learn from it? cause honstly i'm so confused atm. still trying to comprehend everything and honestly surprised ive made it this far.

I found this online and it worked.

def cube(num):
return num**3

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

This post was edited by Complete420 on May 20 2015 10:10pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 20 2015 10:09pm
of the three i listed, which one is confusing you?

/edit: the code you found looks correct. which part did you not understand?

This post was edited by carteblanche on May 20 2015 10:15pm
Member
Posts: 8,078
Joined: Apr 17 2007
Gold: 5,023.00
May 20 2015 10:23pm
I looked online and got the correct code and kind of dissected what i meant. I'm just bad a math and the codes associated with them so #2 on the instructions didnt make much sense to me, cause I didn't know what code n such to use.

Do you recommend any place to help me learn coding? trying to learn a lot cause me and some friends wanna mess around n try n make an 8-bit game. so just trying to learn it for that, and I've always wanted to learn it in general.

This post was edited by Complete420 on May 20 2015 10:25pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 20 2015 10:28pm
my tip for you is to worry a bit less about syntax and worry about the logic more.

in pseudocode, i think this is pretty clear from #1 and #2 in the instructions:

Code
def cube(number):
#return cube of number


i expect you 100% to get that far.

then once you have that, you can google "python multiply" and turn your pseudocode into code:

Code
def cube(number):
return number * number * number


as for #3 and #4, you should have this much pseudo code simply by following the instructions
Code
def by_three(number):
# if number is divisible by 3
# then call cube(number)
# otherwise
# then return false


a lot of beginners copy/paste shit they dont understand and try desperately to modify it until it runs and does what they want. that looks like what you did from the hint. don't do that. start with the logic so that you understand exactly what it's supposed to do, then slowly translate your ideas into code.

This post was edited by carteblanche on May 20 2015 10:37pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 20 2015 10:29pm
Quote (Complete420 @ May 21 2015 12:23am)
Do you recommend any place to help me learn coding? trying to learn a lot cause me and some friends wanna mess around n try n make an 8-bit game. so just trying to learn it for that, and I've always wanted to learn it in general.


Do not even think about making games. it will take you months before you have a decent enough grasp on programming. wait until then before you consider games at all.
Member
Posts: 8,078
Joined: Apr 17 2007
Gold: 5,023.00
May 20 2015 10:36pm
were not making the game for awhile. I'm just learning it now because thats our goal.

This post was edited by Complete420 on May 20 2015 10:36pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll