02/11/2026
🐍 Python Lessons – Lesson 2: Python Syntax & Basics
Welcome back to our Python learning series! 👨💻
In this lesson, we will explore the fundamental concepts of Python programming. These basics will help you understand how Python code is written and executed.
📘 1. Python Syntax
Python has a simple and readable syntax, making it easy for beginners to learn. Unlike some programming languages, Python usually does not require semicolons at the end of statements. Indentation (spaces) is important because it defines blocks of code.
Example:
print("Hello, Python!")
print("Welcome to Python!")
📘 2. Variables
Variables are used to store information in memory. You can think of a variable as a named container that holds a value. In Python, you do not need to declare the variable type explicitly.
Example:
name = "Student"
age = 20
cgpa = 3.5
📘 3. Input & Output
Python allows us to interact with users through input and output functions.
- "input()" is used to receive information from the user.
- "print()" is used to display information on the screen.
Example:
name = input("Enter your name: ")
print("Hello,", name)
📘 4. Basic Operators
Operators are symbols used to perform operations on values and variables.
Some common arithmetic operators are:
- "+" Addition
- "-" Subtraction
- "*" Multiplication
- "/" Division
- "%" Modulus (remainder)
- "**" Exponentiation (power)
Example:
a = 5
b = 3
print(a + b) # 8
📘 5. Conditional Statements
Conditional statements allow a program to make decisions based on specific conditions.
Python uses "if", "elif", and "else" to control the ex*****on of instructions.
Example:
age = 18
if age >= 18:
print("Adult")
else:
print("Minor")
📘 6. Loops
Loops are used to repeat a block of code multiple times. Python provides two main types of loops: "for" and "while".
Example:
for i in range(5):
print(i)
This program displays numbers from 0 to 4.
🎯 What should you remember?
- Python syntax is simple and easy to read.
- Variables store data.
- Input and output allow interaction with users.
- Operators perform calculations.
- Conditional statements help programs make decisions.
- Loops allow us to repeat instructions.
💡 Keep learning and practicing! Programming skills improve through practice and problem-solving.
📚 Lokman School
Inspiring Minds, Shaping Futures.