Python is a programming language built to be easy for people to read, with short lines and very little punctuation. Many students begin their coding journey with it, and the very same language runs data analysis, machine learning, web servers and office automation at large companies.
In this lesson you will learn
- What Python is and what people build with it
- How the Python interpreter runs your code
- How Python differs from C, which you may already know from our C course
- Why indentation is part of Python’s grammar
- How to write and run your first three small programs
What Is Python?
Python is a high-level, interpreted and dynamically typed language. Each of those words tells you something useful:
- High-level means you describe what you want done, and Python looks after memory, pointers and other machine details for you.
- Interpreted means you do not compile a separate executable first. You hand your file to the Python interpreter and it starts working through it straight away.
- Dynamically typed means a variable gets its type from the value you put in it. You never write
intorfloatin front of a name.
Guido van Rossum started Python in the late 1980s and released the first version in 1991. The language is open source, free to use for any purpose, and maintained today by the Python Software Foundation together with a large volunteer community.
Why Learn Python?
A language is worth learning when it opens doors. Python opens quite a few of them:
| Field | What Python does there | Popular tools |
|---|---|---|
| Data analysis | Cleans spreadsheets, summarises sales, draws charts | pandas, Matplotlib |
| Machine learning and AI | Trains and tests prediction models | scikit-learn, PyTorch, TensorFlow |
| Web back ends | Handles logins, databases and APIs behind a website | Django, Flask, FastAPI |
| Automation | Renames hundreds of files, fills forms, sends reports | os, pathlib, Selenium |
| Education and research | Models experiments and solves maths problems | NumPy, SciPy, Jupyter |
Because the syntax is small, you spend your early weeks learning how to think like a programmer instead of fighting punctuation. That habit carries over to every language you learn afterwards.
Your First Python Program
The built-in print() function shows text on the screen. Text goes inside quotation marks. Each print() call writes one line.
print("Hello from Dhaka!")
print("Learning Python on Core Tech ED")
Output
Hello from Dhaka!
Learning Python on Core Tech ED
Compare this with C, where the same result needs #include <stdio.h>, a main() function, semicolons and a compile step. In Python, two lines are the whole program.
How Python Runs Your Code
When you type python3 hello.py in a terminal, three things happen behind the scenes:
- The interpreter reads your
.pyfile and checks that the grammar is valid. - It translates the source into bytecode, a compact set of instructions meant for Python’s own virtual machine rather than for your CPU.
- The Python virtual machine carries out those instructions from top to bottom. If it meets an error on line 8, lines 1 to 7 have already run.
You never see the bytecode step unless you go looking for it, which is why Python feels instant: save the file, run it, read the result.
Python and C Side by Side
| Point | C | Python |
|---|---|---|
| How it runs | Compiled to machine code before running | Translated to bytecode and run by an interpreter |
| Variable types | Declared by you: int age = 20; | Taken from the value: age = 20 |
| Code blocks | Curly braces { } | Indentation (usually 4 spaces) |
| Memory | You call malloc() and free() | Managed automatically |
| Speed | Very fast | Slower for raw loops, but fast libraries close the gap |
| Best for | Operating systems, embedded devices, drivers | Data work, AI, scripting, web back ends |
A Small Practical Program
Programs become interesting once they calculate something. This one estimates a rickshaw fare: a fixed charge for the first kilometre plus a rate for each kilometre after that.
# Rickshaw fare estimator
base_fare = 30 # taka for the first kilometre
per_km = 15 # taka for each extra kilometre
distance = 4
fare = base_fare + (distance - 1) * per_km
print("Distance:", distance, "km")
print("Estimated fare:", fare, "taka")
Output
Distance: 4 km
Estimated fare: 75 taka
Notice three ideas you will meet again soon. Names like base_fare are variables. Text after # is a comment that Python ignores. And print() accepts several values separated by commas, putting a space between each.
Indentation Is Part of the Grammar
In most languages, spaces at the start of a line are only for looks. In Python they decide which lines belong together. Every line inside a loop or an if must be pushed in by the same amount.
marks = [72, 85, 64, 90]
for m in marks:
if m >= 80:
print(m, "-> A+")
else:
print(m, "-> keep practising")
Output
72 -> keep practising
85 -> A+
64 -> keep practising
90 -> A+
The for line ends with a colon, and everything indented beneath it repeats for each mark. The if and else lines sit one level deeper, so they run inside the loop. Remove the indentation and Python stops with an IndentationError before running anything.
Which Python Version Should You Use?
Always learn Python 3. Python 2 reached its official end of life on 1 January 2020 and no longer receives fixes. Any recent 3.x release works for every lesson in this course. You can check your version with python3 --version.
Common Beginner Mistakes
- Mixing tabs and spaces. Pick spaces (four per level) and let your editor insert them for you.
- Forgetting the colon. Lines that start a block, such as
if,for,whileanddef, must end with:. - Writing
Printinstead ofprint. Python is case-sensitive, so the capitalised version is an unknown name. - Missing quotes around text.
print(Hello)looks for a variable namedHello;print("Hello")prints the word. - Running the file with Python 2. On some systems
pythonstill points to an old version. Usepython3to be sure.
Good Habits From Day One
- Give variables descriptive names in lowercase with underscores, such as
total_marks. - Keep one idea per line. Short lines are easier to debug.
- Write a comment when the reason for a line is not obvious, not to repeat what the code already says.
- Run your program often. Small steps make errors easy to find.
Practice Exercises
Exercise 1. Write a program that prints your name on the first line and your city on the second line.
Show answer
print("Arif")
print("Chattogram")
Exercise 2. The line below has one error. Find it and fix it.
print("Python is fun)
Show answer
The closing quotation mark is missing. The fixed line is print("Python is fun").
Exercise 3. Change the rickshaw program so the distance is 7 km. What fare does it print?
Show answer
30 + (7 − 1) × 15 = 30 + 90 = 120 taka.
Frequently Asked Questions
Is Python good for complete beginners?
Yes. Its short syntax lets you focus on problem solving rather than on brackets and type declarations, and the skills transfer to other languages later.
Do I need to learn C before Python?
No. You can start with either. Knowing C helps you understand what Python hides from you, such as memory and types, but it is not required.
Is Python too slow for real projects?
Plain Python loops are slower than C, but heavy work is usually handed to libraries written in C or C++, such as NumPy. Large companies run Python in production every day.
What do I need to install to follow this course?
Only Python 3 and a text editor. The next lesson walks you through installing both on Windows, macOS and Linux.
Summary
- Python is a high-level, interpreted, dynamically typed language released in 1991.
- It is used for data analysis, machine learning, web back ends and automation.
- The interpreter turns your file into bytecode and runs it line by line.
- Indentation is required in Python; it marks which lines belong to a block.
- Always use Python 3.
