FutureStack ☁️
238 subscribers
1 photo
48 links
AI | Cloud | Coding | Tech Trends
Learn - Build - Grow ❤️

Job Updates: https://t.me/thinkcareers
Download Telegram
DAY 11 – TUPLES (Python Basics)



📌 What is a Tuple? 👉 A tuple is a collection of items stored in a single variable 👉 It is ordered, NOT changeable (immutable), allows duplicates



📌 Example (Create Tuple)
fruits = ("apple", "banana", "mango")
print(fruits)

👉 Output:
('apple', 'banana', 'mango')



📌 Access Tuple Items
fruits = ("apple", "banana", "mango")
print(fruits[0])
print(fruits[1])

👉 Output:
apple
banana
👉 Index starts from 0



📌 Tuple is Immutable
fruits = ("apple", "banana", "mango")
fruits[1] = "orange"

👉 Output:
TypeError: 'tuple' object does not support item assignment
👉 Meaning: Cannot change values in tuple



📌 Tuple Length
fruits = ("apple", "banana", "mango")
print(len(fruits))

👉 Output:
3



📌 Loop Through Tuple
fruits = ("apple", "banana", "mango")

for item in fruits:
print(item)

👉 Output:
apple
banana
mango



📌 Single Item Tuple (Important )
data = ("apple",)
print(type(data))

👉 Output:
<class 'tuple'>
👉 Without comma → it is NOT tuple



🎯 🔥 Example (All Data Types in Tuple)
data = ("apple", 10, 3.5, True)
print(data)

👉 Output:
('apple', 10, 3.5, True)
👉 Meaning: String → “apple” Integer → 10 Float → 3.5 Boolean → True



💡 Summary Same as list but cannot change values Faster than list Used when data should not change



📢 Follow 👉 https://t.me/futurestack45
🔁 Share with friends to grow together 🚀
DAY 12 – DICTIONARIES (Python Basics)





📌 What is a Dictionary?
👉 A dictionary stores data in key : value pairs
👉 Each key is unique
👉 It is ordered & changeable





📌 Example (Create Dictionary)
student = {
"name": "John",
"age": 20,
"marks": 85
}

print(student)

👉 Output:
{'name': 'John', 'age': 20, 'marks': 85}





📌 Access Values (Using Key)
student = {
"name": "John",
"age": 20
}

print(student["name"])
print(student["age"])

👉 Output:
John
20





📌 Change Value
student = {
"name": "John",
"age": 20
}

student["age"] = 25
print(student)

👉 Output:
{'name': 'John', 'age': 25}





📌 Add New Data
student = {
"name": "John"
}

student["marks"] = 90
print(student)

👉 Output:
{'name': 'John', 'marks': 90}





📌 Remove Data
student = {
"name": "John",
"age": 20
}

student.pop("age")
print(student)

👉 Output:
{'name': 'John'}





📌 Loop Through Dictionary
student = {
"name": "John",
"age": 20
}

for key in student:
print(key, student[key])

👉 Output:
name John
age 20





🎯 🔥 Important Example (All Data Types)
data = {
"name": "Alice",
"age": 25,
"height": 5.5,
"is_student": True
}

print(data)

👉 Output:
{'name': 'Alice', 'age': 25, 'height': 5.5, 'is_student': True}





🧠 Simple Understanding
👉 Dictionary = Real-life form 🧾
Name → John
Age → 20





💡 Summary
Stores data in key-value format
Fast access using keys
Used in APIs, JSON, real apps





📢 Follow 👉 https://t.me/futurestack45

🔁 Share with friends to grow together 🚀
Starting Python From basics to learn it in 3 weeks

Plan

🟢 UNIT 1 – BASICS (Foundation)

👉 Day 1 – What is Python + Features
👉 Day 2 – Variables & Data Types
👉 Day 3 – Input & Output
👉 Day 4 – Operators



🟡 UNIT 2 – CONTROL FLOW (Logic Building)

👉 Day 5 – If / Else Conditions
👉 Day 6 – Nested If + Practice
👉 Day 7 – For Loop
👉 Day 8 – While Loop
👉 Day 9 – Break & Continue



🔵 UNIT 3 – DATA STRUCTURES

👉 Day 10 – Lists
👉 Day 11 – Tuples
👉 Day 12 – Dictionaries


Above are covered 🔥 


—————————————————


👉 Day 13 – Sets



🟣 UNIT 4 – FUNCTIONS & LOGIC

👉 Day 14 – Functions Basics
👉 Day 15 – Function Arguments + Mini Project



🎯 BONUS (OPTIONAL – HIGH VALUE 🔥)

👉 Day 16 – File Handling
👉 Day 17 – Exception Handling
👉 Day 18 – OOP Basics
DAY 13 – SETS (Python Basics)



📌 What is a Set? 👉 A set is a collection of unique items 👉 It is unordered, unchangeable, and does NOT allow duplicates*
(You can add/remove items, but items themselves cannot be changed)



📌 Example (Create Set)
numbers = {1, 2, 3, 4}
print(numbers)

👉 Output:
{1, 2, 3, 4}



📌 Duplicate Values Not Allowed
data = {1, 2, 2, 3, 3}
print(data)

👉 Output:
{1, 2, 3}
👉 Meaning: duplicates are automatically removed



📌 Add Item
numbers = {1, 2, 3}
numbers.add(4)
print(numbers)

👉 Output:
{1, 2, 3, 4}



📌 Remove Item
numbers = {1, 2, 3}
numbers.remove(2)
print(numbers)

👉 Output:
{1, 3}



📌 Loop Through Set
numbers = {1, 2, 3}

for item in numbers:
print(item)

👉 Output:
1
2
3



📌 Set Length
numbers = {1, 2, 3}
print(len(numbers))

👉 Output:
3



🎯 🔥 Example (All Data Types in Set)
data = {"apple", 10, 3.5, True}
print(data)

👉 Output:
{'apple', 10, 3.5, True}



🧠 Simple Understanding 👉 Set = Collection of unique values only 👉 No duplicates allowed 🚫



💡 Summary Stores only unique values Unordered (no index) Useful for removing duplicates



📢 Follow 👉 https://t.me/futurestack45 🔁 Share with friends to grow together 🚀
Most of the Python Basic concepts covered

Will start remaining concepts from tomorrow

Thanks for supporting ❤️🎉

https://t.me/futurestack45
1
📅 Day 14: Functions in Python

🔹 Function Definition:
A function is a block of reusable code that performs a specific task. It helps in organizing code, improving readability, and avoiding repetition.

🔹 Syntax:
def function_name(parameters):
# code
return result

--------------------------------------------------

🔹 Example 1: Simple Function
def greet():
print("Hello, Welcome!")

greet()

Output:
Hello, Welcome!

--------------------------------------------------

🔹 Example 2: Function with Parameters
def add(a, b):
return a + b

result = add(3, 5)
print(result)

Output:
8

--------------------------------------------------

🔹 Example 3: Function with Default Parameter
def greet(name="User"):
print("Hello", name)

greet()
greet("John")

Output:
Hello User
Hello John

--------------------------------------------------

🔹 Example 4: Function with Return Value
def square(n):
return n * n

print(square(4))

Output:
16

--------------------------------------------------

🔹 Types of Functions in Python

1️⃣ Built-in Functions:
Definition: Predefined functions available in Python.
Example:
print("Hello")
len([1,2,3])

--------------------------------------------------

2️⃣ User-defined Functions:
Definition: Functions created by the user using 'def'.
Example:
def multiply(a, b):
return a * b

print(multiply(2,3))

Output:
6

--------------------------------------------------

3️⃣ Anonymous Functions (Lambda):
Definition: Small one-line functions without a name using 'lambda'.
Example:
square = lambda x: x * x
print(square(5))

Output:
25

--------------------------------------------------

4️⃣ Recursive Functions:
Definition: A function that calls itself.
Example:
def factorial(n):
if n == 1:
return 1
return n * factorial(n-1)

print(factorial(5))

Output:
120

--------------------------------------------------

5️⃣ Function with Multiple Arguments (*args):
Definition: Allows passing multiple non-keyword arguments.
Example:
def add_all(*numbers):
return sum(numbers)

print(add_all(1,2,3,4))

Output:
10

--------------------------------------------------

6️⃣ Function with Keyword Arguments (**kwargs):
Definition: Allows passing multiple keyword arguments.
Example:
def display(**data):
print(data)

display(name="John", age=25)

Output:
{'name': 'John', 'age': 25}

--------------------------------------------------

Summary:
- Functions help reuse code
- Can take inputs (parameters)
- Can return outputs
- Different types improve flexibility
Day 15 – Lambda Functions & Map / Filter
🔹 Definition: Lambda is a small anonymous (one-line) function used for short operations without using def.



🔹 Example:
square = lambda x: x * x
print(square(5))

Output:
25


🔹 Lambda with Multiple Arguments:
add = lambda a, b: a + b
print(add(3, 7))
Output:
10
 


🔹 Using map() 👉 Applies function to all elements
nums = [1, 2, 3, 4]
result = list(map(lambda x: x*2, nums))
print(result)

Output:
[2, 4, 6, 8]



🔹 Using filter() 👉 Filters elements based on condition
nums = [1, 2, 3, 4, 5, 6]
result = list(filter(lambda x: x % 2 == 0, nums))
print(result)

Output:
[2, 4, 6]



🔹 map + filter Together:
nums = [1, 2, 3, 4, 5]

result = list(map(lambda x: x*2,
filter(lambda x: x % 2 == 0, nums)))

print(result)

Output:
[4, 8]



Common Mistake:
square = lambda x: x * x
print(square)

Output:
<function <lambda>>
Forgot to pass value



Summary: Lambda = one-line function No need of ‘def’ Best for quick operations Works with map() & filter() 🚀


📢 Follow 👉 https://t.me/futurestack45
🔁 Share with friends to grow together 🚀
2
Day 16 – File Handling in Python
🔹 Definition: File handling is used to read, write, and manage files in Python.



🔹 Opening a File:
file = open("test.txt", "r")
print(file.read())
file.close()

👉 Modes:
"r" → Read
"w" → Write (overwrite)
"a" → Append
"x" → Create



🔹 Reading a File:
file = open("test.txt", "r")
print(file.read())
file.close()

Output:
(Displays file content)



🔹 Writing to a File:
file = open("test.txt", "w")
file.write("Hello Python")
file.close()

👉 Output: File will contain → Hello Python



🔹 Appending to a File:
file = open("test.txt", "a")
file.write("\nWelcome")
file.close()

👉 Output: Adds content without deleting old data



🔹 Using with (Best Practice):
with open("test.txt", "r") as file:
print(file.read())

👉 No need to close file manually



🔹 Read Line by Line:
with open("test.txt", "r") as file:
for line in file:
print(line)




Common Mistake:
file = open("test.txt", "r")
print(file.read())

File not closed



Summary: Used to handle files Modes: r, w, a, x Use with for safety Always close file or use with 🚀

📢 Follow 👉 https://t.me/futurestack45
🚀 Learn something new every day
💡 Upgrade your skills step by step
Day 17 – OOP (Object-Oriented Programming) Basics
🔹 Definition: OOP is a programming approach that organizes code using classes and objects, making it easier to structure, reuse, and manage.



🔹 Class (Blueprint) 👉 A class is a template used to create objects
class Student:
pass




🔹 Object (Instance) 👉 An object is an instance created from a class
class Student:
pass

s1 = Student()
print(type(s1))

Output:
<class '__main__.Student'>



🔹 Constructor (__init__) 👉 A special method that initializes object data when created
class Student:
def __init__(self, name):
self.name = name

s1 = Student("Mani")
print(s1.name)

Output:
Mani



🔹 Method (Function inside class) 👉 Defines behavior of an object
class Car:
def start(self):
print("Car started")

c1 = Car()
c1.start()

Output:
Car started



🔹 Inheritance 👉 A class can inherit properties and methods from another class
class Animal:
def sound(self):
print("Animal sound")

class Dog(Animal):
pass

d = Dog()
d.sound()

Output:
Animal sound



🔹 Encapsulation 👉 Restricts direct access to data and protects it
class Bank:
def __init__(self):
self.__balance = 1000

def show(self):
print(self.__balance)

b = Bank()
b.show()

Output:
1000



🔹 Polymorphism 👉 Same method name behaves differently for different objects
class Dog:
def sound(self):
print("Bark")

class Cat:
def sound(self):
print("Meow")

for animal in (Dog(), Cat()):
animal.sound()

Output:
Bark
Meow



Common Mistake:
class Test:
def show():
print("Hello")

t = Test()
t.show()

Missing self



Summary: Class = Blueprint Object = Instance init = Initializes data Method = Defines behavior Inheritance = Code reuse Encapsulation = Data protection Polymorphism = Multiple behavior 🚀



📢 Follow 👉 https://t.me/futurestack45 🔁 Share with friends to grow together 🚀
Day 18 – Exception Handling in Python
🔹 Definition: Exception handling is used to handle runtime errors so that the program does not crash and runs smoothly.



🔹 What is an Exception?
👉 An error that occurs during program execution
Example:
print(10 / 0)
Output: ZeroDivisionError



🔹 try & except
👉 Used to handle errors
try:
print(10 / 0)
except:
print("Error occurred")

Output: Error occurred



🔹 Handling Specific Exception
try:
num = int("abc")
except ValueError:
print("Invalid input")




🔹 Multiple Exceptions
try:
a = int(input("Enter number: "))
print(10 / a)
except ValueError:
print("Enter valid number")
except ZeroDivisionError:
print("Cannot divide by zero")




🔹 else Block
👉 Runs if no error occurs
try:
print(10 / 2)
except:
print("Error")
else:
print("Success")




🔹 finally Block
👉 Always runs (error or not)
try:
print(10 / 2)
except:
print("Error")
finally:
print("Execution completed")




🔹 Raising Exception
👉 Manually create error
age = -1

if age < 0:
raise ValueError("Age cannot be negative")




🔹 Custom Exception
class MyError(Exception):
pass

raise MyError("Custom error occurred")
 



Common Mistakes
🚫 Using only except: (not specific) 🚫 Ignoring errors instead of handling 🚫 Not using finally for cleanup



Summary
try → test code except → handle error else → runs if no error finally → always runs raise → create error
Day 19 – Modules & Packages in Python
🔹 What is a Module?
👉 A module is a file that contains Python code (functions, variables, classes) which can be reused.
👉 Example:
If you create a file math_operations.py, it becomes a module.





🔹 Creating a Module
📄 math_operations.py
def add(a, b):
return a + b

def sub(a, b):
return a - b





🔹 Importing a Module
import math_operations

print(math_operations.add(5, 3))





🔹 Import Specific Functions
from math_operations import add

print(add(10, 5))





🔹 Import with Alias
import math_operations as mo

print(mo.sub(10, 3))





🔹 Built-in Modules
👉 Python already provides many modules
Examples:
math
random
datetime
os
import math
print(math.sqrt(16))





🔹 What is a Package?
👉 A package is a collection of multiple modules organized in folders.
📁 Example Structure:
my_package/
__init__.py
module1.py
module2.py





🔹 Import from Package
from my_package import module1

module1.function_name()





🔹
init.py File
👉 Marks a folder as a package
👉 Can be empty or contain initialization code





🔹 dir() Function
👉 Shows all functions/variables in a module
import math
print(dir(math))





Common Mistakes
🚫 Wrong file path
🚫 Module name conflict (same as built-in module)
🚫 Forgetting init.py in package





Summary
Module → single Python file
Package → collection of modules
import → use module
from → import specific items
alias → rename module
built-in modules → ready to use
Day 20 – Lambda, Map, Filter & Reduce in Python
These are very important for interviews + real-world coding.



🔹 1. Lambda Functions
👉 Anonymous (no-name) functions 👉 Used for short, one-line operations
square = lambda x: x * x
print(square(5))

Output:
25
👉 Multiple arguments:
add = lambda a, b: a + b
print(add(3, 4))




🔹 2. map() Function
👉 Applies a function to all elements in a list
nums = [1, 2, 3, 4]

result = list(map(lambda x: x * 2, nums))
print(result)

Output:
[2, 4, 6, 8]



🔹 3. filter() Function
👉 Filters elements based on condition
nums = [1, 2, 3, 4, 5]

result = list(filter(lambda x: x % 2 == 0, nums))
print(result)

Output:
[2, 4]



🔹 4. reduce() Function
👉 Reduces list to single value
from functools import reduce

nums = [1, 2, 3, 4]

result = reduce(lambda x, y: x + y, nums)
print(result)

Output:
10



🔹 Difference Between Them
Function
lambda: Create small function
map: Transform data
filter: Select data
reduce: Combine data



🔹 Real-Time Example
nums = [10, 15, 20, 25]

# Step 1: filter even
evens = list(filter(lambda x: x % 2 == 0, nums))

# Step 2: square them
squares = list(map(lambda x: x * x, evens))

print(squares)

Output:
[100, 400]



Common Mistakes
🚫 Forgetting list() around map/filter 🚫 Not importing reduce 🚫 Using lambda for complex logic (avoid)



Summary
lambda → one-line function map → apply function filter → condition check reduce → single output
🎉 200 Members Completed!
Thank you all for the support 🙏
🥰1👏1🎉1
Day 21 – List Comprehension & *args / **kwargs
🔹 Definition:
List comprehension is a short and powerful way to create lists in a single line.





🔹 Basic Example:
nums = [1, 2, 3, 4]

squares = [x*x for x in nums]
print(squares)

Output:
[1, 4, 9, 16]





🔹 With Condition:
nums = [1, 2, 3, 4, 5, 6]

evens = [x for x in nums if x % 2 == 0]
print(evens)

Output:
[2, 4, 6]





🔹 Normal Loop vs List Comprehension
Normal Way:
nums = [1, 2, 3]
result = []

for x in nums:
result.append(x*x)

print(result)

Short Way:
result = [x*x for x in [1,2,3]]
print(result)






🔹 *args (Multiple Arguments)
👉 Allows function to accept multiple values
Example:
def add(*nums):
return sum(nums)

print(add(1, 2, 3, 4))

Output:
10





🔹 **kwargs (Keyword Arguments)
👉 Accepts data in key-value format
Example:
def info(**data):
print(data)

info(name="Ram", age=20)

Output:
{'name': 'Ram', 'age': 20}





🔹 Combining args and kwargs
def show(*args, **kwargs):
print(args)
print(kwargs)

show(1, 2, 3, name="Mani", age=25)

Output:
(1, 2, 3)
{'name': 'Mani', 'age': 25}





Common Mistakes:
🚫 Forgetting brackets in list comprehension
🚫 Confusing *args with list
🚫 Using kwargs without key=value format





Summary:
List comprehension → short & clean list creation
*args → multiple values
**kwargs → key-value inputs
Improves code readability 🚀





📢 Follow 👉 https://t.me/futurestack45
🔁 Share with friends to grow together 🚀
Day 22 – Decorators & Generators in Python
🔹 Definition (Decorator): A decorator is used to modify or extend the behavior of a function without changing its code.



🔹 Basic Example (Decorator):
def my_decorator(func):
def wrapper():
print("Before function")
func()
print("After function")
return wrapper

@my_decorator
def greet():
print("Hello!")

greet()

Output:
Before function
Hello!
After function



🔹 Without @ Syntax (Understanding)
def greet():
print("Hello!")

greet = my_decorator(greet)
greet()




🔹 Why Use Decorators?
👉 Add extra functionality 👉 Code reuse 👉 Used in frameworks (Django, Flask)



🔹 Definition (Generator):
A generator is a function that returns values one by one using yield instead of returning all at once.



🔹 Basic Example (Generator):
def count():
for i in range(3):
yield i

for num in count():
print(num)

Output:
0
1
2



🔹 Difference: return vs yield
return
Ends function
Uses more memory
Returns one value
yield
Pauses function
Memory efficient
Returns multiple values


🔹 Generator Example (Real Use)
def even_numbers(n):
for i in range(n):
if i % 2 == 0:
yield i

print(list(even_numbers(10)))

Output:
[0, 2, 4, 6, 8]



Common Mistakes:
🚫 Forgetting yield in generator 🚫 Confusing decorator with normal function 🚫 Not using @ syntax properly



Summary:
Decorator → modifies function behavior @ → used to apply decorator Generator → produces values one by one yield → key for generators Saves memory 🚀



📢 Follow 👉 https://t.me/futurestack45 🔁 Share with friends to grow together 🚀
Day 23 – JSON, Regex & DateTime in Python
🔹 These are very important for real-world projects (APIs, data handling, validation)



🔹 1. JSON in Python
🔹 Definition: JSON (JavaScript Object Notation) is used to store and exchange data.



🔹 Convert JSON → Python
import json

data = '{"name": "Mani", "age": 22}'
result = json.loads(data)

print(result)

Output:
{'name': 'Mani', 'age': 22}



🔹 Convert Python → JSON
import json

data = {"name": "Mani", "age": 22}
result = json.dumps(data)

print(result)

Output:
{"name": "Mani", "age": 22}



🔹 2. Regular Expressions (Regex)
🔹 Definition: Regex is used to search and match patterns in text.



🔹 Basic Example
import re

text = "My number is 9876543210"
result = re.findall(r'\d+', text)

print(result)

Output:
['9876543210']



🔹 Check Email Pattern
import re

email = "test@gmail.com"

if re.match(r'^\S+@\S+\.\S+$', email):
print("Valid Email")
else:
print("Invalid Email")




🔹 3. Date & Time
🔹 Definition: Used to work with date and time in Python.



🔹 Current Date & Time
from datetime import datetime

now = datetime.now()
print(now)




🔹 Format Date
from datetime import datetime

now = datetime.now()
print(now.strftime("%d-%m-%Y"))

Output:
10-07-2026



Common Mistakes:
🚫 Forgetting to import modules 🚫 Wrong regex patterns 🚫 Confusing loads() and dumps()



Summary:
JSON → data exchange loads() → JSON to Python dumps() → Python to JSON Regex → pattern matching datetime → date & time handling



📢 Follow 👉 https://t.me/futurestack45 🔁 Share with friends to grow together 🚀
1
Day 24 – Mini Project (Putting It All Together)
🔹 Definition: A mini project helps you apply all the concepts you learned (functions, loops, JSON, etc.) in a real-world scenario.



🔹 Project: Student Record Manager
👉 Features: Add student View students Save data (JSON)



🔹 Step 1: Import Module
import json




🔹 Step 2: Create Functions
def add_student(data):
name = input("Enter name: ")
age = input("Enter age: ")

data.append({"name": name, "age": age})
return data




🔹 Step 3: View Data
def view_students(data):
for student in data:
print(student)




🔹 Step 4: Save Data to File
def save_data(data):
with open("students.json", "w") as file:
json.dump(data, file)




🔹 Step 5: Load Data
def load_data():
try:
with open("students.json", "r") as file:
return json.load(file)
except:
return []




🔹 Step 6: Main Program
data = load_data()

while True:
print("\n1. Add Student")
print("2. View Students")
print("3. Exit")

choice = input("Enter choice: ")

if choice == "1":
data = add_student(data)
elif choice == "2":
view_students(data)
elif choice == "3":
save_data(data)
break
else:
print("Invalid choice")




👉 Output Example:
1. Add Student
2. View Students
3. Exit
Enter choice: 1
Enter name: Mani
Enter age: 22




Common Mistakes:
🚫 Not saving data before exit 🚫 File not found error 🚫 Wrong JSON format



Summary:
Uses functions Uses loops Uses JSON Real-world logic building Great for beginners 🚀



📢 Follow 👉 https://t.me/futurestack45 🔁 Share with friends to grow together 🚀
Day 25 – String Methods in Python
🔹 Definition: Strings are sequences of characters, and Python provides built-in methods to manipulate them.



🔹 Basic Example
text = "hello world"
print(text.upper())

Output:
HELLO WORLD



🔹 Common String Methods
🔹 1. upper() – Convert to uppercase
text = "python"
print(text.upper())

Output:
PYTHON



🔹 2. lower() – Convert to lowercase
text = "PYTHON"
print(text.lower())
Output:
python



🔹 3. title() – First letter capital
text = "hello world"
print(text.title())

Output:
Hello World



🔹 4. strip() – Remove spaces
text = "  hello  "
print(text.strip())

Output:
hello



🔹 5. replace() – Replace text
text = "I like Java"
print(text.replace("Java", "Python"))

Output:
I like Python



🔹 6. split() – Convert string to list
text = "apple,banana,grapes"
print(text.split(","))

Output:
['apple', 'banana', 'grapes']



🔹 7. find() – Find position
text = "hello"
print(text.find("e"))

Output:
1



🔹 8. count() – Count occurrences
text = "banana"
print(text.count("a"))

Output:
3



🔹 9. startswith() / endswith()
text = "python.py"
print(text.startswith("python"))
print(text.endswith(".py"))

Output:
True
True



Common Mistakes:
🚫 Strings are immutable (cannot change directly) 🚫 Forgetting case sensitivity 🚫 Using wrong method names



Summary:
Strings → text data Many built-in methods Immutable (cannot modify directly) Used in almost every program 🚀



📢 Follow 👉 https://t.me/futurestack45 🔁 Share with friends to grow together 🚀
1
Day 26 – Lists in Python
🔹 Definition:
A list is a collection of multiple items stored in a single variable.





🔹 Creating a List
numbers = [1, 2, 3, 4]
print(numbers)

Output:
[1, 2, 3, 4]





🔹 Accessing Elements
nums = [10, 20, 30]

print(nums[0]) # first element
print(nums[-1]) # last element

Output:
10
30





🔹 Adding Elements
nums = [1, 2]

nums.append(3)
print(nums)

Output:
[1, 2, 3]





🔹 Insert at Position
nums = [1, 3]

nums.insert(1, 2)
print(nums)

Output:
[1, 2, 3]





🔹 Remove Elements
nums = [1, 2, 3]

nums.remove(2)
print(nums)

Output:
[1, 3]





🔹 Loop Through List
nums = [1, 2, 3]

for x in nums:
print(x)






🔹 List Length
nums = [1, 2, 3, 4]

print(len(nums))

Output:
4





🔹 List Slicing
nums = [1, 2, 3, 4, 5]

print(nums[1:4])

Output:
[2, 3, 4]





🔹 List with Different Data Types
data = [1, "Python", True]
print(data)






Common Mistakes:
🚫 Index out of range
🚫 Confusing remove() and pop()
🚫 Modifying list while looping





Summary:
List → collection of items
Ordered & changeable
Supports different data types
Very important for logic building 🚀





📢 Follow 👉 https://t.me/futurestack45
🔁 Share with friends to grow together 🚀