17/04/2025
*Important Python concepts that every beginner should know*
*1. Variables & Data Types* π§
Variables are like boxes where you store stuff.
Python automatically knows the type of data you're working with!
name = "Alice" # String
age = 25 # Integer
height = 5.6 # Float
is_student = True # Boolean
*2. Conditional Statements* π
Want your program to make decisions?
Use if, elif, and else!
if age > 18:
print("You're an adult!")
else:
print("You're a kid!")
*3. Loops* π
Repeat tasks without writing them 100 times!
For loop β Loop over a sequence
While loop β Loop until a condition is false
for i in range(5):
print(i) # 0 to 4
count = 0
while count < 3:
print("Hello")
count += 1
*4. Functions* βοΈ
Reusable blocks of code. Keeps your program clean and DRY (Don't Repeat Yourself)!
def greet(name):
print(f"Hello, {name}!")
greet("Bob")
*5. Lists, Tuples, Dictionaries, Sets* π¦
List: Ordered, changeable
Tuple: Ordered, unchangeable
Dict: Key-value pairs
Set: Unordered, unique items
my_list = [1, 2, 3]
my_tuple = (4, 5, 6)
my_dict = {"name": "Alice", "age": 25}
my_set = {1, 2, 3}
*6. String Manipulation* βοΈ
Work with text like a pro!
text = "Python is awesome"
print(text.upper()) # PYTHON IS AWESOME
print(text.replace("awesome", "cool")) # Python is cool
*7. Input from User* β¨οΈ
Make your programs interactive!
name = input("Enter your name: ")
print("Hello " + name)
*8. Error Handling* β οΈ
Catch mistakes before they crash your program.
try:
x = 1 / 0
except ZeroDivisionError:
print("You can't divide by zero!")
*9. File Handling* π
Read or write files using Python.
with open("notes.txt", "r") as file:
content = file.read()
print(content)
*10. Object-Oriented Programming (OOP)* π§±
Python lets you model real-world things using classes and objects.
class Dog:
def __init__(self, name):
self.name = name
def bark(self):
print(f"{self.name} says woof!")
my_dog = Dog("Buddy")
my_dog.bark()
React with β€οΈ if you want me to cover each Python concept in detail.