0% found this document useful (0 votes)
5 views

Python Getting Started

The document provides a guide for getting started with Python, including installation instructions for Windows, Linux, and Mac. It explains how to write and execute a simple Python program using the command line and introduces an online Python editor for practice. Additionally, it covers how to check the Python version and run Python directly from the command line interface.

Uploaded by

nshansundar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Python Getting Started

The document provides a guide for getting started with Python, including installation instructions for Windows, Linux, and Mac. It explains how to write and execute a simple Python program using the command line and introduces an online Python editor for practice. Additionally, it covers how to check the Python version and run Python directly from the command line interface.

Uploaded by

nshansundar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

3/28/25, 4:13 PM Python Getting Started

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

ADVERTISEMENT

Python Getting Started


❮ Previous Next ❯

Python Install
Many PCs and Macs will have python already installed.

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):

C:\Users\Your Name>python --version

To check if you have python installed on a Linux or Mac, then on linux open the
command line or on Mac open the Terminal and type:

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
https://www.w3schools.com/python/python_getstarted.asp 1/9
3/28/25, 4:13 PM Python Getting Started

Python is an interpreted programming language, this means that as a developer you


 Tutorials
write Python Exercises
 files
(.py) Services
 editor
in a text  files into the python
and then put those Sign Up Log in
interpreter to be executed.
HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
The way to run a python file is like this on the command line:
ADVERTISEMENT

C:\Users\Your Name>python helloworld.py

Where "helloworld.py" is the name of your python file.

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:

C:\Users\Your Name>python helloworld.py

The output should read:

Hello, World!

Congratulations, you have written and executed your first Python program.

ADVERTISEMENT

https://www.w3schools.com/python/python_getstarted.asp 2/9
3/28/25, 4:13 PM Python Getting Started

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

ADVERTISEMENT

 W3Schools' Python Editor 

We have an online Python editor where you can execute your own Python code and see
the result:

Example Get your own Python Server

Try our online Python editor:

print("Hello, World!")

Try it Yourself »

This editor will be used in the entire tutorial to demonstrate the different aspects of
Python.

Python Version
To check the Python version of the editor, you can find it by importing the sys module:

Example
Check the Python version of the editor:

import sys

print(sys.version)

Try it Yourself »

https://www.w3schools.com/python/python_getstarted.asp 3/9
3/28/25, 4:13 PM Python Getting Started

You will learn more about importing modules in our Python Modules chapter.
 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
The Python Command Line
ADVERTISEMENT

To test a short amount of code in python sometimes it is quickest and easiest not to
write the code in a file. This is made possible because Python can be run as a command
line itself.

Type the following on the Windows, Mac or Linux command line:

C:\Users\Your Name>python

Or, if the "python" command did not work, you can try "py":

C:\Users\Your Name>py

From there you can write any python, including our hello world example from earlier in
the tutorial:

C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello, World!")

Which will write "Hello, World!" in the command line:

C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

https://www.w3schools.com/python/python_getstarted.asp 4/9
3/28/25, 4:13 PM Python Getting Started

>>> print("Hello, World!")


 Hello,Tutorials
World! Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

WheneverADVERTISEMENT
you are done in the python command line, you can simply type the following
to quit the python command line interface:

exit()

Video: Python Get Started

❮ Previous Next ❯

https://www.w3schools.com/python/python_getstarted.asp 5/9
3/28/25, 4:13 PM Python Getting Started

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS Track your
JAVASCRIPT SQL progress
PYTHON - it's free!PHP
JAVA HOWUp
Sign TO W3.CSS
Log in C

ADVERTISEMENT

ADVERTISEMENT

https://www.w3schools.com/python/python_getstarted.asp 6/9
3/28/25, 4:13 PM Python Getting Started

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

ADVERTISEMENT

COLOR PICKER



ADVERTISEMENT

ADVERTISEMENT

 

https://www.w3schools.com/python/python_getstarted.asp 7/9
3/28/25, 4:13 PM Python Getting Started

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS
 JAVASCRIPT
PLUS
SQL PYTHON
SPACES
JAVA PHP HOW TO W3.CSS C

ADVERTISEMENT

GET CERTIFIED FOR TEACHERS

FOR BUSINESS CONTACT US

Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
W3.CSS Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial

Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference

Top Examples Get Certified


HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate

https://www.w3schools.com/python/python_getstarted.asp 8/9
3/28/25, 4:13 PM Python Getting Started
XML Examples C# Certificate

 Tutorials  jQuery Examples


Exercises  Services   XML Certificate
Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

ADVERTISEMENT     

FORUM ABOUT ACADEMY


W3Schools is optimized for learning and training. Examples might be simplified to improve
reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot
warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use,
cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.

https://www.w3schools.com/python/python_getstarted.asp 9/9

You might also like