Python Introduction

Python · Lesson 1 of 43 6 min read Updated

Python is one of the easiest programming languages to start with, and it is also one that professionals use every day. The same language that prints your first "Hello" can rename a thousand photos, read a sales report or power the back end of a website.

In this lesson you will learn what Python is, what it is used for, which version is current, and you will run your first two Python programs right here in the browser.

What is Python?

Python is a general-purpose programming language. "General-purpose" means it is not tied to one job: you can use it for scripts, websites, data work, games and much more. It was created by Guido van Rossum and first released in 1991. Today it is free and open source, and the Python Software Foundation looks after it.

Python is famous for being readable. Its code looks close to plain English, and it uses indentation (spaces at the start of a line) to group code instead of curly braces. Here is a complete Python program:

PythonRun it yourself
print("Namaste, Python!")
Output
Namaste, Python!

print() is a function: a named piece of code that does a job. The print() function shows whatever you put between its brackets. The text inside the quotes is called a string. Click the button above the code to run it, then change the message and run it again.

What can you build with Python?

Python has a huge standard library (modules that come with Python) and hundreds of thousands of extra packages that other people share for free. That is why it shows up in so many places:

  • Automation: rename files, fill spreadsheets, send reports, clean up folders.
  • Web back ends: frameworks such as Django, Flask and FastAPI run the server side of websites.
  • Data analysis: read CSV and Excel files, calculate totals, draw charts.
  • Machine learning and AI: libraries such as scikit-learn and PyTorch are written for Python.
  • Testing and scripting: small tools that check servers, websites or other programs.

You do not need to learn all of this at once. Every one of these areas uses the same core language that this course teaches.

A slightly bigger program

Real programs store values, repeat work and make decisions. Read this one before you run it. It adds up a grocery bill for a shop in Kochi and gives a discount on big orders.

PythonRun it yourself
items = {"rice": 640, "dal": 180, "oil": 215, "tea": 120}

total = 0
for name, price in items.items():
    print(f"{name:<6} ₹{price}")
    total = total + price

if total > 1000:
    total = total - 50
    print("Discount: ₹50")

print(f"To pay: ₹{total}")
Output
rice   ₹640
dal    ₹180
oil    ₹215
tea    ₹120
Discount: ₹50
To pay: ₹1105

You do not need to understand every line yet, but notice how readable it is:

  • items = {...} stores four products and their prices in a dictionary. You will meet dictionaries in Dictionaries.
  • for name, price in items.items(): repeats the indented lines once for each product. Loops are covered in for Loops.
  • if total > 1000: makes a decision. The two indented lines run only when the total is more than 1,000.
  • f"..." is an f-string, a string that can contain values inside {}. See f-strings & t-strings.

How Python runs your code

You write Python code in a plain text file that ends in .py, such as bill.py. A program called the Python interpreter reads the file and runs it from top to bottom. You do not need a separate "compile" step: write, save, run.

You can also type Python one line at a time in the REPL (Read, Evaluate, Print, Loop), an interactive prompt that answers each line immediately. It is perfect for quick experiments, and you will use it in Install Python & Set Up.

On this site, every example with a "Run it yourself" button runs in your browser. Nothing needs to be installed while you learn the basics.

Which Python version?

Python gets a new version every October. The current version is Python 3.15, released on 9 October 2026. The examples on this site run on Python 3.14 in your browser, which is the same for almost everything a learner writes. Where a lesson uses a 3.15-only feature, it is marked clearly and shown with its output instead of a run button.

Python 2 is a different, older language line that reached its end of life on 1 January 2020. If you find a tutorial that writes print "hello" without brackets, it is Python 2 code. Skip it.

Common mistakes

  • Capital letters in names. Python is case-sensitive. Print("Hi") fails because the function is called print, all lowercase.
  • Missing quotes around text. print(Hello) makes Python look for a variable named Hello. Text needs quotes: print("Hello").
  • Copying Python 2 code. Code like print "Hi" or raw_input() is from Python 2 and does not work in Python 3.

Key points

  • Python is a free, general-purpose language known for code that is easy to read.
  • It is used for automation, web back ends, data analysis, machine learning and much more.
  • print() shows output; text goes inside quotes as a string.
  • The Python interpreter runs .py files from top to bottom; the REPL runs one line at a time.
  • Python 3.15 (October 2026) is the current version; examples here run on 3.14 in the browser.
  • Indentation groups code in Python, so spaces at the start of a line matter.

Exercise

Open the first example in the editor. Change it so it prints three lines: your name, your city, and the language you are learning. Use one print() for each line.

Show solution
Python
print("Meera")
print("Lucknow")
print("I am learning Python")

Each print() call writes one line and then moves to a new line, so three calls give three lines of output.

Quick Quiz

1. Which line correctly prints a message in Python 3?

2. What does Python use to group lines of code into a block?

3. Which version of Python is current in October 2026?

4. What is the REPL?

Learn Python with a mentor

Free lessons get you started. Our Python Programming training adds real projects and code reviews from working developers.

  • Project-based learning
  • Mentor code reviews
  • Free counselling call