Skip to content

Introduction to Python

Explain what Python does, where it is used, and run code in the editor.

7 min read 10 quiz questions

Meet Python

Python is a programming language: a way to give a computer instructions. Its readable style makes it a popular first language.

You can use Python to build websites, analyze data, automate repetitive jobs, make games, work with artificial intelligence, and much more.

Example 1: Your first instruction
print("Python is ready!")

print() asks Python to show text. The words inside the quotes are the text that appears in the output.

How Python runs your code

You write instructions in a file or editor. A Python program called the interpreter reads those instructions from top to bottom and performs them.

In this app, you can edit and run every example right in the page. Change a value, select Run, and see what happens.

Example 2: Code runs in order
message = "I can edit this code"
print(message)

Python first stores the text in message. On the next line, it prints the stored text.

Experiment with code

Example 3: Edit, then run
print("Try changing this sentence.")
print(2 + 3)

The two instructions produce two output lines. Edit either line and run it again to test your own idea.

Key points

  • Python gives computers instructions.
  • Python is used in many kinds of projects.
  • The interpreter runs code from top to bottom.
  • You can edit and run every example in this page.

Worked example

A bookshop in Dhaka wants to greet customers and show the price of a 500-taka book after a 10% discount. Three lines of Python do the whole job.

Example
print("Welcome to Boi Bazar!")
price = 500
discount = price * 10 // 100
print("You pay", price - discount, "taka")

How it works, step by step

  1. print() displays text between quotes exactly as written.
  2. The variable price stores the number 500 for later use.
  3. 10 // 100 keeps integer maths simple: 500 * 10 // 100 is the 50-taka discount.
  4. The last print() mixes text and a calculated value in one line.

References & Further Reading

Related entries from PyLabs's own reference library.

  • print() (Print objects to the text stream file, separated by sep and followed by end.)
  • type() (Find out what type of value an object is.)

Your notes

Sign in to keep private notes alongside this lesson.

Sign in to take notes

Practice exercise

Not passed yet

Use print() to display I am learning Python.

# Write your code below
Want another challenge on this module? More coding practice

Check yourself

Introduction to Python quiz

10 questions. You get instant feedback per question, and the timer starts when you press the button.

Lesson incomplete

Not completed

Create an ID or sign in to save lesson completion across devices.

Create ID to save
Module lesson progress0/5 complete
Module cheat sheet