Learning Python but Online course different than Book

dave343

[H]ard|Gawd
Joined
Oct 17, 2000
Messages
1,869
A while back I signed up to codeacademy.com to learn Python and JS. I did the JS, then moved onto Python and got about halfway done the course when I came across a book that I thought I could read and do on the go. The book is by Jason Cannon entitled "Python Programming for Beginners", and since it had over 100 reviews and 5 stars I thought I'd give it a try. It uses version 2.7/3.0, as for Codeacademy I'm not sure what version they teach? I would assume the same.

The problem I ran into was that the book, the syntax that was being taught was different from codeacademy's. I'll have to post examples later as I don't have the book on me, but simple things like typing variables, and the use of quotation marks, they were completely different.

The book seems very good, and the author does a good job of teaching, but since codeacademy is teaching it with different syntax, I don't know which one is right and which one to proceed with.
Does anyone have experience using codeacademy and are they usually on the money teaching coding right? Thanks,

316qnmr.jpg
 
I haven't gone through the code academy courses at all but if you're referring to the quotes you put at the start and end of string literals, you can pretty much use either a single or double quote interchangeably.

String literals can be enclosed in matching single quotes (') or double quotes ("). They can also be enclosed in matching groups of three single or double quotes (these are generally referred to as triple-quoted strings). The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character. String literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and use different rules for interpreting backslash escape sequences. A prefix of 'u' or 'U' makes the string a Unicode string. Unicode strings use the Unicode character set as defined by the Unicode Consortium and ISO 10646. Some additional escape sequences, described below, are available in Unicode strings. A prefix of 'b' or 'B' is ignored in Python 2; it indicates that the literal should become a bytes literal in Python 3 (e.g. when code is automatically converted with 2to3). A 'u' or 'b' prefix may be followed by an 'r' prefix.
https://docs.python.org/2/reference/lexical_analysis.html#strings
 
The Python 2.x -> 3.x transition has been going on for years, and is somewhat of a holy war. Both/either are fine to learn and use- 2.x is not going anywhere. Just pick one for now and try not to get mixed up.
 
Back
Top