Skip to content

Module 1 · Introduction to Python — topic 1 of 14

What is Python?

Python is a general-purpose programming language designed to be easy to read and write. This lesson explains what that means and what a Python program looks like.

Beginner 12 min read·Lesson 1 of 306 in Python Programming

Learning objectives

  • Explain in plain words what a programming language is
  • Describe Python as a general-purpose, high-level, interpreted language
  • Read and run a three-line Python program

Definition

Python is a general-purpose programming language designed to be easy to read and write. This lesson explains what that means and what a Python program looks like.

Introduction

A computer only follows instructions. A programming language is a precise way of writing those instructions so that both people and the computer can understand them. Python is one of those languages, and it is famous for looking close to ordinary English.

When you write Python you create a text file full of instructions such as “show this message” or “add these two numbers”. A program called the Python interpreter reads the file and carries out each instruction in order.

Why it matters

Python lets a beginner focus on solving problems instead of fighting with punctuation. The same language is then used by professionals to build websites, analyse data, automate office work and train machine-learning models, so the time you invest keeps paying off.

Because Python reads like a description of the task, it is also easier to come back to your own code weeks later and still understand it. Readable code has fewer hidden mistakes.

Detailed explanation

Python is a high-level language. “High-level” means you describe what you want in terms close to the problem, and Python handles details such as memory and processor instructions for you. Low-level languages, such as assembly, make you manage those details yourself.

Python is general-purpose: it is not tied to one kind of job. The same language can read a spreadsheet, send an email, run a web server or control a robot. Extra abilities come from libraries, which are collections of ready-made code you can reuse.

Python is interpreted. Instead of turning the whole program into a separate executable file first, the interpreter reads your source code and runs it straight away. This makes it quick to try an idea, see the result and adjust.

Python the language vs python the program

“Python” is the language (the rules). “python” or “python3” is the interpreter program installed on your computer that runs code written in that language.

Syntax

Python
print("message to show")
  • print is a built-in function that displays text.
  • The parentheses hold what you want to show.
  • Text is written inside quotation marks; this is called a string.
  • Each line is one instruction; no semicolon is needed at the end.

Code examples

A greeting

Python
print("Hello, Python!")
Output
Hello, Python!

One instruction, one line of output.

Python can calculate

Python
print(7 + 5)
print(7 * 5)
Output
12
35

Numbers are written without quotes, and Python works out the arithmetic before printing.

More examples

A tiny shopping bill

Python
item = "Notebook"
price = 45
quantity = 3
print(item, "x", quantity, "=", price * quantity, "rupees")
Output
Notebook x 3 = 135 rupees

Step-by-step explanation

  • item = "Notebook" stores the text Notebook under the name item, so it can be used later.
  • price = 45 and quantity = 3 store two whole numbers.
  • price * quantity multiplies the stored numbers to get 135.
  • print shows all the values on one line, separated by single spaces.

Expected output

Running “A tiny shopping bill” prints exactly:

TextOutput
Notebook x 3 = 135 rupees

Practical applications

  • Instagram’s backend and many Django websites are written in Python.
  • Data analysts use Python with pandas to clean and summarise spreadsheets.
  • Scientists use Python to process experiment data and draw graphs.
  • System administrators write short Python scripts to automate repetitive tasks.

Best practices

  • Write one instruction per line so programs read top to bottom.
  • Run your code often; small steps make mistakes easy to find.
  • Use clear names such as price instead of p from your very first program.

Common mistakes

Forgetting quotation marks around text

Avoid

print(Hello)

Prefer

print("Hello")

Without quotes Python thinks Hello is the name of something you created earlier and raises a NameError.

Capitalising print

Avoid

Print("Hi")

Prefer

print("Hi")

Python is case-sensitive. print and Print are different names, and only print exists.

Key takeaways

  • Python is a high-level, general-purpose, interpreted programming language.
  • The interpreter reads source code and runs it line by line.
  • print() displays values; text goes inside quotes, numbers do not.

Try it yourself

  1. 1
    Write a program that prints your name on one line and your city on the next line.
    Show hint

    Use two print() calls.

  2. 2
    Print the result of 125 multiplied by 8 without working it out yourself.
    Show hint

    Put the calculation inside print().

Finished reading? Mark it complete to update your dashboard.

Suggested practice

1 question test this exact topic. Answers and explanations are revealed after you submit.

  • BeginnerPython is best described as which kind of language?
Practise this topic