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.


Related Built-in Functions:float() input() print() exit() import int() while len for if

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.

💡 Tip: "High-level" means the language is closer to human language — not that it is "better" or "more advanced". The opposite is "low-level" languages (like assembly), which talk directly to hardware and are hard to read and write.

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

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:

💡 Tip: Learn Python 3 directly — the latest stable release is Python 3.13 (released in 2025). Don't touch Python 2 unless you're maintaining a legacy system from a decade ago.



2. Installing Python

(1) Windows

  1. Open your browser and go to https://www.python.org/downloads/
  2. Click the yellow "Download Python 3.x.x" button (choose the latest version)
  3. Run the downloaded installer — make sure to check "Add Python to PATH" at the bottom
  4. Click "Install Now" and wait for the installation to finish
  5. Verify: open Command Prompt (press Win + R, type cmd), then run python --version

(2) macOS

macOS ships with Python 3, but it may not be the latest version. Installing via Homebrew is recommended:

BASH
brew install python

Verify after installing:

BASH
python3 --version

(3) Linux (Ubuntu example)

Most Linux distributions already have Python 3 preinstalled. If not, use the system package manager:

BASH
sudo apt update
sudo apt install python3

Verify:

BASH
python3 --version
💡 Tip: On Windows type 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:

BASH
python

You'll see a prompt like this:

TEXT 📖 Display only
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:

PYTHON
print("Hello, World!")

Press Enter and you'll see:

TEXT 📖 Display only
Hello, World!
⚠️ Note: 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:

  1. Create a new file named hello.py (.py is the extension for Python files)
  2. Open it with Notepad or VS Code and enter:
PYTHON
print("Hello, World!")
  1. Save the file and run it in the terminal:
BASH
python hello.py

The output is the same:

TEXT 📖 Display only
Hello, World!

Open a terminal → type a command → see the output. That's the standard programming workflow.

💡 Tip: VS Code is a great editor for Python — it highlights syntax automatically and points out errors. If you don't have it, download it from code.visualstudio.com and install the Python extension.


▶ Example 1: Python as a Calculator (Difficulty ⭐)

Write a script file calculator.py that does math with print():

▶ Try it Yourself

Output:

TEXT 📖 Display only
3 + 5 = 8
10 - 4 = 6
7 * 8 = 56
15 / 4 = 3.75
💡 Tip: 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.

▶ Try it Yourself

Output:

TEXT 📖 Display only
Hello everyone, I'm learning Python!
Line 1
Line 2
Line 3
====================
Welcome to the world of Python!
====================

A few new things here:



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.

PYTHON
name = input("Hi, what's your name? ")
print("Your name is:", name)

What running it looks like:

TEXT 📖 Display only
Hi, what's your name? Charlie  ← user input
Your name is: Charlie
⚠️ Note: 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:

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

PYTHON
age = 18  # Hardcoded for demo; use int(input()) in practice
print("Next year you'll be", age + 1, "years old")
💡 Tip: Besides 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):

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

PYTHON
a = 10
b = 3
print(f"{a} + {b} = {a + b}")   # Output: 10 + 3 = 13
💡 Tip: f-strings were introduced in Python 3.6 and are now the mainstream way to format strings — clearer and less error-prone than commas or + concatenation.


▶ Example 3: A Simple Interactive Program (Difficulty ⭐⭐)

This program "talks" with you, using the input(), int() and f-strings you just learned.

▶ Try it Yourself

Example run:

TEXT 📖 Display only
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!
⚠️ Note: 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


Related Built-in Functions:float() input() print() exit() import int() while len for if

❓ FAQ

Q Is Python "better" than Java or C++?
A There's no "better" — each has its own strengths. Python's advantages are a quick learning curve and high development productivity, making it great for data analysis, AI and automation scripts. Java dominates enterprise backends. C++ sits closer to hardware with extreme performance, suited to game engines and operating systems. As a first language, Python is the friendliest choice.
Q I installed Python, but typing python says "'python' is not recognized". What went wrong?
A This is the most common installation issue — you didn't check "Add Python to PATH". PATH is the operating system's "address book" for finding executables. Fix: uninstall Python, reinstall, and check that option this time. Or manually add Python's install folder (like C:\Python313\ and C:\Python313\Scripts\) to your system environment variables.
Q Can I write Python with Notepad, or do I need VS Code?
A Notepad can absolutely write Python code — but it's like using a power drill as a hammer: possible, just not pleasant. VS Code is free and does a lot for you: syntax highlighting (see at a glance whether it's correct), autocomplete (less typing), instant error hints (tells you the moment you're wrong), and an integrated terminal (no window switching to run). Use VS Code — beginners save a lot of hassle.
Q Do I need good English to learn Python?
A No, but you do need to recognize basic English words. Python's keywords (like 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


📝 Exercises

  1. Beginner (⭐): Use print() to output your favorite movie quote or poem line. Try \n for line breaks and "=" * 30 to draw a divider.

  2. 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."

  3. Challenge (⭐⭐⭐): Using print(), input() and int(), 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.

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏