Write your first program with Python, get to know `print()` and comments — and discover why almost all AI work is done in Python.
Time
12 min
Exercises
1
Challenges
1
Quiz
3 questions
In Simple Terms
Python is a programming language — a way to give instructions to a computer. You write what you want the computer to do in Python, and the computer follows those instructions.
Python's biggest advantage is that it reads almost like ordinary English. That's why it's easy for beginners to learn, while engineers at Google, Meta, and OpenAI use it every day.
Why Do You Need It?
If you want to become an AI Engineer, Python is almost essential. Here's why:
NumPy, Pandas — libraries for working with data
scikit-learn — traditional Machine Learning
PyTorch, TensorFlow — Deep Learning
LangChain, Anthropic SDK, OpenAI SDK — building Generative AI applications
All of these are used with Python. From training an ML model to building an API for production — Python is used everywhere.
Your First Program
Let's see how Python works. Press the Run button to execute the following code:
main.py
print() is a function — whatever you put inside it will be displayed on the screen. To write text, you need to enclose it in quotes ("..." or '...').
Now modify the code yourself! Print your own name, then press Run again. Nothing will break — don't be afraid. Write → Run → Observe → Modify — this is how you learn programming.
Python Can Do Calculations Too
When you provide numbers without quotes, Python performs calculations:
main.py
Notice that the first two produce numerical results, but the third prints the exact text because it is enclosed in quotes.
Comments
A line that starts with # is called a comment. Python doesn't execute comments — they're for humans to understand the code.
main.py
Good engineers write clear comments in their code so that they or someone else can easily understand it six months later.
Don't Be Afraid of Errors
Errors are completely normal in programming. An error message actually tells you where the problem is. Run the following code and see what happens:
main.py
A SyntaxError appears because the quote was opened but never closed. Fix the quote and run the code again.
Exercise
Exercise
First program
+20 points
Use print() to print exactly this line:
Hello, AI!
solution.py
Quiz
0/3 answered
Challenge
Challenge
Introduce yourself
+50 points
Use three separate print() statements to write three lines:
Name: Rahim
University: BUET
Goal: AI Engineer
Also, write a comment at the very top of the code explaining what the program does.
solution.py
Where Is It Used in Real Projects?
print() may look simple, but it's useful every day in real projects too:
During model training, the loss at each epoch is printed to check whether the model is learning.
After loading data, print(df.head()) is used to check what the data looks like.
Printing values in the middle of your code to find bugs is called "print debugging."
Later, we'll learn why logging is used instead of print() in production.
Interview Questions
Beginner: Is Python a compiled or interpreted language? (In short: Python code is first converted into bytecode, which is then executed by the Python interpreter. It is generally described as an interpreted language.)
Intermediate: Python is slow — so why is it used for computationally intensive tasks like ML?
Advanced: Why is an operation in NumPy much faster than a pure Python loop?
What's Next?
Now you can print things on the screen. But where will your program store data? In the next lesson, we'll learn about Variables — the "memory" of a program.