Python Getting Started

Learn how to install Python and set up your development environment.

Python Install

Many PCs and Macs will have Python already installed. To check if you have Python installed on Windows, 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 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

Python is an interpreted programming language, this means that as a developer you write Python (.py) files in a text editor and then put those files into the Python interpreter to be executed.

The way to run a Python file is like this on the command line:

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!

The Python Command Line

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!")
Hello, World!

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

exit()

Four Ways to Run Python

MethodCommandBest for
Run a scriptpython app.pyReal programs
Interactive shell (REPL)pythonQuick experiments
One-linerpython -c "print(2+2)"Tiny tasks / scripts
Run a modulepython -m http.serverBuilt-in tools

On Windows the launcher is often py instead of python (e.g. py --version). On macOS/Linux you may need python3.

The Interactive Shell

Type python to enter the REPL — it evaluates each line and prints the result immediately, perfect for testing ideas. Exit with exit() or Ctrl+Z (Windows) / Ctrl+D (Mac/Linux).

>>> 5 * 3
15
>>> name = "Sam"
>>> f"Hi {name}"
'Hi Sam'

Try It Yourself

Exercise 1: Create a file hello.py that prints Hello, Python! and run it from the terminal.

Show solution
# hello.py
print("Hello, Python!")

# terminal:
# python hello.py

Exercise 2: Use a one-liner (no file) to print the result of 12 * 12.

Show solution
python -c "print(12 * 12)"

Key Takeaways

  • Run scripts with python file.py; experiment in the REPL with python.
  • Use py on Windows and python3 where needed.
  • python -m runs installed modules as tools.

📘 Real-World Deep Dive

Picking the right Python interpreter, virtualenv, and package manager up front prevents the classic "works on my machine" bug. The two-line real-life example below is what almost every production repo starts with.

Real-Life Scenario

Setting up a brand-new project with an isolated environment and a pinned dependency list.

Real-Life Example

# From a fresh checkout, the canonical start-up sequence is:
python3 -m venv .venv
source .venv/bin/activate            # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt
python -c "import sys; print(sys.version)"

Expected Output

3.12.4 (main, Jun 6 2024, 18:26:37) [Clang 15.0.0]

Common mistakes

  • Committing the .venv directory blows up the repo — always add it to .gitignore.
  • Using the system Python instead of the venv's interpreter silently imports the wrong packages.
  • pip install package without a pinned version produces non-reproducible deploys — pin or use uv / poetry.

🚀 Performance & Best Practices

  • uv (from Astral) is 10–100× faster than pip for resolution and install; consider it for new projects.
  • Use python -m pip … rather than bare pip … to guarantee the right interpreter is used.
  • A requirements.txt with hashes blocks supply-chain attacks.

🧪 Try It Yourself

  1. Bootstrap a project with uv init and compare timings against the venv path above.
  2. Add a Makefile target setup that runs the four commands idempotently.
  3. Generate a requirements.txt from an active env with pip freeze.

FAQ: Python Getting Started

Common questions about this page.

What is Python Getting Started?

Python Getting Started is a Python Tutorial lesson that explains python get started in Python. Learn how to install Python and set up your development environment. Copy the samples and run them in the Python editor. It is written for beginners who want a clear definition and working examples.

Should I run python get started examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn python get started in this Python Tutorial Python lesson (Python Getting Started).

How do I use python get started in Python?

To use python get started in Python, follow the examples on this StudyGrid page. Copy a snippet, run it in the browser, then Download and run it locally for better learning. Change the values and compare the output.

What is the syntax of python get started?

This Python Getting Started tutorial shows python get started syntax with short Python examples. Use the code blocks in this lesson for the exact statements, then try them in your editor.

Python Getting Started example for beginners

Yes. This page includes a beginner python get started example you can copy and run. It is designed for searches such as "python get started for beginners", "python get started example", and "how to use python get started".

What are common mistakes with python get started?

Common python get started mistakes include wrong syntax, mixing types, and skipping practice. Work through this Python Tutorial chapter in order, run every example, and check the output before moving on.

Why should I learn python get started?

Python Getting Started is used in real Python work. Learning python get started helps you write clearer programs and continue the Python Tutorial tutorial on StudyGrid.

Is Python Getting Started free to learn online?

Yes. You can learn python get started free on StudyGrid (studygrid.in). This chapter is part of the Python Tutorial path and includes examples, syntax, and next-step links.