Python Tutorials
Python File Handling
Python Modules
As we learned on the previous page, Python syntax can be done by typing directly into the Command Line:
>>> print("Hello, World!")
Hello, World!
Or by creating a python file on the server, using the .py file extension, and running it in Command Line:
C:\Users\Your Name>python myfile.py
Undo refers to the spaces at the beginning of the code line.
Where in some languages the indent editing code is readable, retrieving in Python is very important.
Python uses indentation to display a code block.
if 5 > 2:
print("Five is greater than two!")
Python will give you an error if you skip over:
Syntax Error:
if 5 > 2:
print("Five is greater than two!")
The number of posts is up to you as an editor, but it should be at least one.
if 5 > 2:
print("Five is greater than two!")
if 5 > 2:
print("Five is greater than two!")
You must use the same number of spaces in the same code block, otherwise Python will give you an error:
Syntax Error:
if 5 > 2:
print("Five is greater than two!")
print("Five is greater than
two!")
In Python, a variable is created when you assign value to it:
Variables in Python:
x = 5
y = "Hello, World!"
Python has no dynamic declaration command.
Python has the ability to comment for coding purposes.
Comments start with #, and Python will provide the whole line as a comment:
Comments in Python:
#This is a comment.
print("Hello, World!")