Introduction to Python
What Python is, what it's used for, how to install it and how to run your first program.
What is Python?
Python is a general-purpose programming language. It was created by Guido van Rossum and first released in 1991.
Its core idea is that code should read almost like plain English. That’s why it’s one of the most popular languages for learning to program, and also one of the most used in the industry.
print("Hello, world!")That single line is already a complete Python program.
What is it used for?
You can build almost anything with Python. The most common uses:
- Web development: the code that runs on the server behind a website or an API.
- Automation: scripts that rename files, fill in reports or send emails for you.
- Data and artificial intelligence: analysis, charts, machine learning.
- Databases: reading, changing and connecting information.
- Fast prototyping: testing an idea in hours instead of weeks.
Companies like Instagram, Spotify, Netflix and NASA use Python in their systems.
Why learn Python?
- It runs everywhere: Windows, macOS, Linux, even a Raspberry Pi.
- Simple syntax: it looks like English and takes fewer lines than other languages to do the same thing.
- It’s interpreted: code runs line by line as soon as you write it, with no compile step. That makes trying things out very fast.
- Several styles: you can write procedural (step by step), object-oriented or functional code.
Python 3
This course uses Python 3, the current version. Python 2 stopped receiving support in 2020, so if you find tutorials with print "hello" (no parentheses), they’re for the old version.
Installing Python
- Go to python.org/downloads and download the latest version for your system.
- On Windows, check the “Add Python to PATH” box before clicking install.
- On macOS and Linux it’s often preinstalled, but it may be an old version. Install the latest one anyway.
To check that it’s installed, open a terminal (on Windows: Command Prompt or PowerShell) and type:
python --versionPython 3.13.0If it doesn't work
On macOS and Linux the command is sometimes python3 instead of python. Try python3 --version. If Windows says it doesn’t recognize the command, reinstall and check “Add Python to PATH”.
Your first program
Python programs are text files with a .py extension. You can write them in any editor; we recommend Visual Studio Code, which is free.
- Create a folder for the course, for example
python-course. - Inside it, create a file called
hello.pywith this content:
print("Hello, world!")
print("I'm learning Python")- In the terminal, go to that folder and run it:
cd python-course
python hello.pyHello, world!
I'm learning PythonInteractive mode
You can also type Python straight into the terminal, without creating a file. Type python (or python3) and press Enter. You’ll see the >>> prompt, which means Python is waiting for an instruction:
>>> print("Hello from the terminal")
Hello from the terminal
>>> 2 + 3
5
>>> exit()This mode is great for quick experiments. Type exit() to leave. For programs longer than a few lines, use a .py file.
Tip
You can also check the version from code: import sys and then print(sys.version).
Test what you learned
Challenge
Create a file about_me.py that prints three lines: your name, your city and why you want to learn Python. Run it from the terminal.
See a solution
print("My name is Carlos")
print("I live in Guadalajara")
print("I want to automate the reports at my job")