Introduction to Python
Explain what Python does, where it is used, and run code in the editor.
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.
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.
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
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.
print("Welcome to Boi Bazar!")
price = 500
discount = price * 10 // 100
print("You pay", price - discount, "taka")
How it works, step by step
- print() displays text between quotes exactly as written.
- The variable price stores the number 500 for later use.
- 10 // 100 keeps integer maths simple: 500 * 10 // 100 is the 50-taka discount.
- The last print() mixes text and a calculated value in one line.
References & Further Reading
Related entries from PyLabs's own reference library.
Practice exercise
Not passed yetUse print() to display I am learning Python.
# Write your code below
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 completedCreate an ID or sign in to save lesson completion across devices.