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 shown on the right side of the page.

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

5 1 vote
Lesson Rating
Subscribe
Notify of
profile avatar
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

profile avatar
Dave Williamson(@davew)
Member
2 years ago

Quick and easy to follow.

Saving Progress...

Sign up for free!

Sign up for free and get instant access to this course!.

Python 3 for Beginners

0%

0/1 Lessons

Installing Python on Windows

• 1hr 17min

0 / 4 lessons complete

Python Basics

• 28min

0 / 7 lessons complete

Python Variables

• 41min

0 / 8 lessons complete

Even more Python Variables!

• 41min

0 / 6 lessons complete

Conditional Statements

• 15min

0 / 3 lessons complete

Writing Functions

• 30min

0 / 5 lessons complete

Python Loops

• 23min

0 / 5 lessons complete

Python PIP and Modules

• 18min

0 / 4 lessons complete

RegEx

• 26min

0 / 4 lessons complete

Working with APIs

• 12min

0 / 3 lessons complete

Course Conclusion

• 2min

0 / 1 lessons complete