Programming languages like Python are formal languages with strict syntax rules. But those rules can change over time with newer versions of the programming language. Your textbook covers Python 3, but you may only have access to Python 2.
Download and install a working Python environment, preferably Python 3, or get an account with PythonAnywhere. Refer to the Software Requirements/Installation section of the course syllabus for details.
Type the statements below into your Python interpreter. For each statement, copy the output into your Discussion Assignment and explain the output. Compare it with any similar examples in the textbook, and describe what it means about your version of Python.
>>> print 'Hello, World!'
>>> 1/2
>>> type(1/2)
>>> print(01)
>>> 1/(2/3)
print 'Hello World!'
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
1/2
0.5
type(1/2)
float
print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted;
use an 0o prefix for octal integers
1/(2/3)
1.5
Comments
Leave a comment