Previous Next : Your Name
Previous Next : Your Name
❮ PreviousNext ❯
Python Install
To check if you have python installed on a Windows PC, search in the start
bar for Python or run the following on the Command Line (cmd.exe):
python --version
If you find that you do not have Python installed on your computer, then
you can download it for free from the following
website: https://www.python.org/
Python Quickstart
The way to run a python file is like this on the command line:
Let's write our first Python file, called helloworld.py, which can be done in
any text editor.
helloworld.py
print("Hello, World!")
Simple as that. Save your file. Open your command line, navigate to the
directory where you saved your file, and run:
Hello, World!
On this page
Or by creating a python file on the server, using the .py file extension, and
running it in the Command Line:
Python Indentation
if 5 > 2:
print("Five is greater than two!")
Comments
Comments start with a #, and Python will render the rest of the line as a
comment:
Example
Comments in Python:
#This is a comment.
print("Hello, World!")
Python Comments
❮ PreviousNext ❯
Creating a Comment
#This is a comment
print("Hello, World!")
Try it Yourself »
Comments can be placed at the end of a line, and Python will ignore the
rest of the line:
Example
Try it Yourself »
A comment does not have to be text that explains the code, it can also be
used to prevent Python from executing code:
Example
#print("Hello, World!")
print("Cheers, Mate!")
Try it Yourself »
ADVERTISEMENT
Multiline Comments
Example
#This is a comment
#written in
#more than just one line
print("Hello, World!")
Try it Yourself »
Since Python will ignore string literals that are not assigned to a variable,
you can add a multiline string (triple quotes) in your code, and place your
comment inside it:
Example
"""
This is a comment
written in
more than just one line
"""
print("Hello, World!")
Try it Yourself »
As long as the string is not assigned to a variable, Python will read the
code, but then ignore it, and you have made a multiline comment.
Exercise?
'
//
/*
Submit Answer »