Executing Python Code

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

0 0 votes
Lesson Rating
Notify of
Inline Feedbacks
View all comments