2016-06-25 17:46:29

Has anyone had any experience with Codecademy's Python course?  I've gotten through the first two units with great success, but once I try and use that knowledge and writing my own test scripts with the Python 3.5.1 interpreter, it returns errors every time I run the scripts.

Any info or suggestions for other sites that teach Python would be greatly appreciated.

Thanks,

Luke

What game will hadi.gsf want to play next?

2016-06-25 23:53:52

Unfortunately I do not have any experience with Code Academy's Python courses, though I could perhaps help you debug as to why they are returning error's if you post the code. Alternatively, you could check out some of the available Python books out here if your not already aware of them, such as Learn Python the Hard Way.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2016-06-26 03:27:14

@magurp244,

Thanks for the help.  These are very simple things I'm trying to do just to make sure I'm writing and using them properly.  For example:

from datetime import datetime
now = datetime.now()
print now

Something as simple as that (and even much mor simple) returns errors.  I'm just printing to the screen at this point.  Even without calling to the datetime library, I'm trying to print text which will result in the same outcome.

I find the Codecademy's version is simple, but I like understanding why something works as opposed to just retaining the information.  Some of the vocabulary is outlined in a glossary, but none of those definitions make particular sense unless it is explained in terms of the lessons in the units.

Oh the joys of being a noob.

Thanks,

Luke

What game will hadi.gsf want to play next?

2016-06-26 08:29:46 (edited by stewie 2016-06-26 08:31:57)

I'm pretty sure the problem with that example is that the Codeacademy course is using Python2 whereas you're using Python3. Just change the print line to print(now) and it should work. Print in Python3 is a function, not a keyword so parentheses are required.

Python 2 and 3 do have some significant differences, such as division being integer by default in Python2 and all strings in Python3 using Unicode by default, in Python2 they are just standard.

Deep in the human unconscious is a pervasive need for a logical universe that makes sense. But the real universe is always one step beyond logic.

2016-06-26 15:30:14

I had a hunch it was something as simple as that.

Is there any reason to (or advantages/disadvantages) to using Python 3 over 2?

Thanks,

Luke

What game will hadi.gsf want to play next?

2016-06-26 20:56:34

Python 3 has a number of bug fixes and resolves some underlying flaws in Python 2.x, specifically better Unicode support and cleaner bytes/Unicode separation, among other structural fixes. The problem however is that its not reverse compatible with Python 2.x, which a lot of very useful, even essential, third party libraries depend on, as a result people haven't been in an incredible rush to switch over to Python 3, at least until those API's have a chance to make the transition. So far a number of them have, but support can still be a bit dicey here and there. Also, that book I linked to is also for Python 2.x, just to be clear.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2016-06-26 21:49:09

I'll stick to Python 2, since I've been learning in 2 anyhow.

I'm finding that I'm not a fan of this Codecademy course.  Thanks for the link to the book, I'll give that a shot.  Understanding more than just simply retaining is how I need to learn something like this.  The Codecademy course covers how to make certain things do what, but with little to no understanding as to why or why not.

Luke

What game will hadi.gsf want to play next?

2016-06-27 01:11:55

What do you mean by no understanding of why or why not? Why functions do what they do, or what they are used for?

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2016-06-27 05:49:12

Isn't CodeAcademy supposed to be interactive? I think languages other than Java are created by users.

2016-06-27 10:42:19

It is interactive, and the lessons are written by users, but in some cases the concepts are not explained to make the mechanics of it clear.  Proper spacing and indentation for the interpretter to read, for example, is one such thing unit 1 outlines.  Aside from understanding that it needs to be done for the interpretter to read and handle, the course doesn't offer any further explanation.  I guess for people with very little programming background at all it wouldn't make too much sense to throw so much explanation into every single mechanic of the language, well, at least at first, but I personally would like to know why I should include four blank spaces before starting this or that line.

Luke

What game will hadi.gsf want to play next?

2016-06-27 23:57:46

Ahh, I see. Well, if you have any questions regarding things like that, feel free to ask. Regarding indentation, its one of the particular quirks of the Python syntax, its a way of encapsulating blocks of code to determine what to run and where. To be clear, all languages are like this, but have slightly different ways of going about it. In the C language you would use squiggly brackets instead, so for example:

if (button == 1)
{
printf("button pressed");
}

The brackets tells the computer that when the above If statement is true, it should run the code thats beneath it in between the squiggly brackets. The computer doesn't care what indentation you use, just so long as the code you want to run when the if statement is triggered is between those two squiggly brackets. For some people though this way of writing it can get pretty messy and hard to visually understand, especially if people start writing particularly messy code. Python however uses indentation instead of squiggly brackets  to determine what code belongs where and what code to execute when triggered, which is visually cleaner and easier to read. Using the same example above in Python:

if button == 1:
    print "this code is under this if statement, and will only run when the if statement is true"
print "this code is not! under the if statement, and will run whether its true or not"

When the if statement is triggered the computer will run any code thats indented underneath it, and if theres code thats unevenly indented it will throw an indentation error. This can make it easier to keep track of what code is appart of what and helps make it easier to manage.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2016-06-28 02:15:44

Oh okay, see, that actually makes sense just reading one or two times through.  If I had a choice at this point, I'd prefer using brackets.  Keeping track of the indentations can be annoying, but I also see the reason why the brackets pose to be a nuisance.  Thanks for clearing that up!
big_smile

What game will hadi.gsf want to play next?