Python: Meet Python — What It Is & Your First Program
Last updated: 2026-09-22
Just as you get to know the steering wheel, pedals and gearshift before driving a car, you should first understand the tool you're about to use. Python is a powerful yet beginner-friendly programming language — this lesson introduces it to you.
1. What is Python?
Python is a high-level programming language first released in 1991 by the Dutch programmer Guido van Rossum. Its name comes from the British comedy troupe Monty Python — not the snake.
Python's design philosophy emphasizes code readability — code written in Python is easy to guess at a glance, even for people who don't program. Its syntax is concise and expressive: the same feature often takes only one-third to one-fifth as much code in Python as in C++ or Java.
(1) What can Python do?
Python's range of applications is huge — there's almost nothing it can't do:
| Area | Typical Use | Common Tools / Frameworks |
|---|---|---|
| Web Development | Backend, APIs | Django, Flask, FastAPI |
| Data Analysis | Excel, CSV, databases | pandas, NumPy |
| Artificial Intelligence | Machine learning, deep learning | TensorFlow, PyTorch, scikit-learn |
| Automation Scripts | File batch processing, web scraping, email | requests, BeautifulSoup, Selenium |
| Desktop Apps | Small tools, GUI programs | tkinter, PyQt |
| Game Development | Simple 2D games | Pygame |
(2) Interpreted vs compiled languages
Understanding this difference helps you see how Python runs:
- Compiled languages (like C, C++, Go): after writing your code, a compiler first "translates" it into a binary file the machine can execute directly — only then can it run. Like writing a letter → translating it into English → handing it to the other person.
- Interpreted languages (like Python, JavaScript): after writing your code, the interpreter "translates" and executes it line by line, immediately. Like speaking a sentence → an interpreter translates it to the listener on the spot.
Python is an interpreted language. The benefit is that you can test each line as you write it, which speeds up development and makes it great for beginners validating ideas quickly.
(3) Python 2 vs Python 3
Search for Python tutorials online and you'll see two versions: Python 2 and Python 3. In short:
- Python 2 is the old version; official maintenance ended in 2020.
- Python 3 is the current mainstream version. All new projects should use Python 3.
2. Installing Python
(1) Windows
- Open your browser and go to https://www.python.org/downloads/
- Click the yellow "Download Python 3.x.x" button (choose the latest version)
- Run the downloaded installer — make sure to check "Add Python to PATH" at the bottom
- Click "Install Now" and wait for the installation to finish
- Verify: open Command Prompt (press
Win + R, typecmd), then runpython --version
(2) macOS
macOS ships with Python 3, but it may not be the latest version. Installing via Homebrew is recommended:
brew install python
Verify after installing:
python3 --version
(3) Linux (Ubuntu example)
Most Linux distributions already have Python 3 preinstalled. If not, use the system package manager:
sudo apt update
sudo apt install python3
Verify:
python3 --version
python; on macOS/Linux you may need python3. This is for historical reasons — from here on we'll just use python to refer to it.
3. Running Your First Python Program
Python has two ways to run code: interactive mode and script file mode. After this section you'll be able to write and run your own first Python program.
(1) Interactive mode (REPL)
Interactive mode is like having a "conversation" with the Python interpreter — you type a line, it responds immediately.
Open a terminal (or Command Prompt) and type:
python
You'll see a prompt like this:
Python 3.13.0 (main, Oct 7 2025, 10:00:00)
[GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> means Python is waiting for your command. Try typing:
print("Hello, World!")
Press Enter and you'll see:
Hello, World!
print() is a built-in Python function that displays content on the screen. Whatever goes inside the parentheses is what gets shown. We'll use it again and again.
To exit interactive mode: type exit() or press Ctrl + Z (Windows) / Ctrl + D (macOS/Linux).
(2) Script file mode
Writing a program to a file and running it is the "real deal" of programming:
- Create a new file named
hello.py(.pyis the extension for Python files) - Open it with Notepad or VS Code and enter:
print("Hello, World!")
- Save the file and run it in the terminal:
python hello.py
The output is the same:
Hello, World!
Open a terminal → type a command → see the output. That's the standard programming workflow.
▶ Example 1: Python as a Calculator (Difficulty ⭐)
Write a script file calculator.py that does math with print():
Output:
3 + 5 = 8
10 - 4 = 6
7 * 8 = 56
15 / 4 = 3.75
print() can take multiple values at once, separated by commas — Python automatically adds a space between them. "3 + 5 =" is a string, while 3 + 5 is a math expression; Python evaluates it first, then prints the result.
▶ Example 2: Printing a Self-Introduction (Difficulty ⭐)
This example shows more uses of print() — multi-line output and string repetition — so you quickly feel Python's concise expressiveness.
Output:
Hello everyone, I'm learning Python!
Line 1
Line 2
Line 3
====================
Welcome to the world of Python!
====================
A few new things here:
\nis an escape character meaning newline — like pressing Enter in a word processor."=" * 20repeats the equals sign 20 times, producing a divider of 20 equals signs. Python is "clever" here — it knows what it means to multiply a string by a number.
4. Making the Program Talk to You
The programs so far are "I say something, it answers." But if the program can ask the user questions on its own, its interactivity improves a lot. Let's learn that in this section.
(1) Getting input with input()
input() is Python's built-in input function. It shows a prompt on the screen, waits for the user to type, and after Enter is pressed, returns what was typed as a string.
name = input("Hi, what's your name? ")
print("Your name is:", name)
What running it looks like:
Hi, what's your name? Charlie ← user input
Your name is: Charlie
input() always returns a string (text type). Even if the user types a number, it's stored as text. For example, typing 18 gives the string "18", not the number 18.
(2) Converting numbers with int()
Since input() returns a string, how do you do math with it? Use int() to convert it to an integer:
age = "18" # Hardcoded for demo; use input() in practice
age_number = int(age) # Convert to integer 18
print("Next year you'll be", age_number + 1, "years old")
Or in one step:
age = 18 # Hardcoded for demo; use int(input()) in practice
print("Next year you'll be", age + 1, "years old")
int() for strings-to-integers, there's float() for floats (numbers with decimals). For example, float("3.14") gives 3.14.
(3) Embedding variables with f-strings
In the examples above, we joined strings and variables with commas. There's an even cleaner way called an f-string (formatted string):
name = "Charlie"
age = 18
print(f"My name is {name} and I'm {age} years old.")
# Output: My name is Charlie and I'm 18 years old.
Put an f before the string, then wrap variable names in {} inside it — Python replaces them with the variable values. The braces can hold not just variable names but also expressions:
a = 10
b = 3
print(f"{a} + {b} = {a + b}") # Output: 10 + 3 = 13
+ concatenation.
▶ Example 3: A Simple Interactive Program (Difficulty ⭐⭐)
This program "talks" with you, using the input(), int() and f-strings you just learned.
Example run:
Hi, what's your name? Charlie
Welcome, Charlie! Python is fun — let's learn together.
How old are you? 18
In 5 years you'll be 23. By then, you'll be a Python pro!
input() returns a string (text). Even if you type a number, it's stored as text. In the code above we use int() to convert it to an integer so we can do age + 5. If you did "18" + 5 directly, Python would raise an error — you can't add text and numbers. We'll cover this in detail in the next lesson.
5. Common Use Cases
- Automating files with Python: merging thousands of Excel files into one takes a whole day by hand — a few lines of Python finish it in 10 seconds.
- Writing scrapers in Python: automatically grab info from web pages — weather forecasts, product prices, news headlines — and save it to a local database or Excel.
- Building website backends: many well-known sites (like Instagram, Pinterest, Spotify) are backed by Python.
❓ FAQ
python says "'python' is not recognized". What went wrong?C:\Python313\ and C:\Python313\Scripts\) to your system environment variables.if, for, while, import) are English words, and most function names are English too (like print, input, len). You don't need to spell them from memory — you'll remember them from typing them over and over. Look up any unfamiliar word in a dictionary. What matters more is logical thinking; the language is just a tool.📖 Summary
- Python is a high-level, interpreted language emphasizing code readability, suited to everything from web development to AI
- Check "Add Python to PATH" when installing, or the terminal won't find the
pythoncommand - Two ways to run code: interactive mode (
>>>prompt) for quick experiments, script file mode (.pyfiles) for real development print()outputs content,input()gets user input,int()converts strings to integers- f-strings insert variables into strings with
f"xxx{var}"syntax — concise and intuitive
📝 Exercises
-
Beginner (⭐): Use
print()to output your favorite movie quote or poem line. Try\nfor line breaks and"=" * 30to draw a divider. -
Intermediate (⭐⭐): Write a program that asks the user for their name and city, then prints a welcome message containing both. For example:
"Hello, Charlie! Welcome to learning Python in Beijing." -
Challenge (⭐⭐⭐): Using
print(),input()andint(), write an "age calculator": ask the user for their birth year, then calculate and print their current age. Hint: you'll need to hardcode the current year in your code.