F YGx 1 NZD Hu PHW Owh
F YGx 1 NZD Hu PHW Owh
🔹 What is Python?
Python is a beginner-friendly and versatile programming language used in fields like data science, web
development, and automation. Known for its clean and readable syntax, Python allows you to focus on
solving problems without getting lost in complicated code. 💻
1. Basic Syntax
To write code in Python, you need to understand some key elements. Let’s dive into the essentials:
i) Identifiers 🏷️
Identifiers are the names you give to variables, functions, or any other items in your code. Here’s how
to create them:
Examples:
my_variable , age_1 , _count
ii) Keywords 🚀
Keywords are special words in Python that are reserved for specific functions. These cannot be used
as variable names!
Example:
if x > 10:
print("x is greater than 10")
Notice how the print statement is indented under the if condition? That's how Python understands
which code belongs together! 🤖
Example:
'''
This is a multi-line comment.
You can add detailed explanations here.
'''
2. Basic Operators & Logical Operators 🔢
Python includes various operators that allow you to perform calculations and comparisons.
Basic Operators
x = 5
y = 3
print(x + y) # Output: 8
Logical Operators
Used to combine conditions:
and , or , not
Example:
x = 5
y = 10
print(x > 3 and y < 15) # Output: True
i) if-else Statements ⚖️
The if statement checks whether a condition is true and executes a block of code. If the condition is
false, it executes the else block.
Example:
num = 10
if num % 2 == 0:
print("Even number")
else:
print("Odd number")
Example:
To Recap 📚
Python is a beginner-friendly programming language.
Identifiers are names you give to variables or functions.
Keywords are reserved words that have special meaning in Python.
Proper indentation is essential to organize code.
Multi-line comments are used for explaining logic in detail.
Operators are used for performing calculations and logical checks.
if-else statements allow you to make decisions in your code.