Executing Python Code

Saving Progress...

Python code can be typed directly into a python terminal as show below:

print("Hello Server Academy!")

Try it out in this interactive Python console!

Or you can write a series of python commands and save them in a *.py script file which can be executed from your command prompt.

Let's say we create a file called "hello.py" and put the command above inside our users home directory.

When we open command prompt inside the same directory, we can call the script file from our command prompt console as shown below:

python hello.py
Executing Python 3 file from Command Prompt

Saving Progress...

0 0 votes
Lesson Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
profile avatar
Dave Williamson(@davew)
Points: 45
4 months ago

Quick and easy to follow.