Tech Python
239 subscribers
120 photos
10 files
179 links
Python Programming Hub | Learn & Master Python

Welcome to the perfect channel to learn Python Programming โ€” from beginner to advanced!

For promotions & collaborations:
techbywedcoder@gmail.com

Join now and accelerate your Python journey!
Download Telegram
๐Ÿ PYTHON โ€“ DAY 1 STUDY MATERIAL
โœจ Topic: Introduction to Python & Installation

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is Python?

Python is a high-level, interpreted, and general-purpose programming language.
It is easy to learn and widely used in web development, data science, artificial intelligence, automation, and scripting.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Why Learn Python?

โœ… Easy to read and write
โœ… Beginner-friendly syntax
โœ… Huge library support
โœ… Platform independent
โœ… Used by top companies like Google, Netflix, Instagram

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โš™๏ธ Features of Python

โœ” Interpreted Language
โœ” High-Level Language
โœ” Object-Oriented
โœ” Dynamically Typed
โœ” Portable (Windows, Linux, Mac)
โœ” Open Source and Free

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”ข Python Versions

โŒ Python 2 โ€“ Deprecated
โœ… Python 3 โ€“ Recommended
๐Ÿ‘‰ Always use Python 3

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ’ป How to Install Python (Windows)

1๏ธโƒฃ Visit ๐Ÿ‘‰ https://www.python.org
2๏ธโƒฃ Download Python 3.x
3๏ธโƒฃ Select โ˜‘ Add Python to PATH
4๏ธโƒฃ Click Install
5๏ธโƒฃ Verify installation using:
python --version

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿš€ Python Execution Modes

๐Ÿ”น Interactive Mode
print("Hello Python")

๐Ÿ”น Script Mode
Create file: hello.py
print("Hello Python")

Run using command:
python hello.py

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ‘‹ First Python Program

print("Hello World")

๐Ÿ–จ Output:
Hello World

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿง  Python Syntax Rules

โ€ข Python is case-sensitive
โ€ข Indentation is mandatory
โ€ข No semicolon required

Example:

if True:
print("Python is easy")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ’ฌ Comments in Python

๐Ÿ”น Single-line comment
This is a comment

๐Ÿ”น Multi-line comment
"""
This is
a multi-line
comment
"""
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 1

โœ” Install Python
โœ” Run Python in interactive mode
โœ” Write your first Python program
โœ” Print your name using Python

Example:
print("My name is Soham")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 1 Goal

โœ” Understand Python basics
โœ” Install Python successfully
โœ” Run your first Python program

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 2
๐Ÿ”ฅ Variables & Data Types
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder


React โค๏ธ If You Got It Right
โค3
๐Ÿ PYTHON โ€“ DAY 2 STUDY MATERIAL
โœจ Topic: Variables & Data Types

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is a Variable?
A variable is a name given to a memory location used to store data in a program.
Python variables do not need data type declaration.

Example:
x = 10
name = "Python"

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿง  Rules for Naming Variables

โœ” Must start with a letter (aโ€“z, Aโ€“Z) or underscore (_)
โœ” Can contain letters, numbers, and underscore
โŒ Cannot start with a number
โŒ Cannot use keywords

Valid:
my_var, _count, total1

Invalid:
1total, my-var, class

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โš™๏ธ Dynamic Typing in Python

Python automatically decides the data type based on the value.

Example:
x = 10
x = "Hello"

Same variable, different data type โœ”

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”ข Data Types in Python

๐Ÿ“ Integer (int)
Stores whole numbers
Example:
a = 25

๐Ÿ“ Float (float)
Stores decimal numbers
Example:
b = 10.5

๐Ÿ“ String (str)
Stores text or characters
Example:
name = "Python"

๐Ÿ“ Boolean (bool)
Stores True or False
Example:
is_active = True

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Check Data Type

Use type() function

Example:
x = 10
print(type(x))

Output:
<class 'int'>

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Type Conversion (Type Casting)

๐Ÿ“Œ Convert to Integer
int(10.5) โ†’ 10

๐Ÿ“Œ Convert to Float
float(5) โ†’ 5.0

๐Ÿ“Œ Convert to String
str(100) โ†’ "100"

Example:
x = int("20")
y = float(5)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ฅ User Input in Python

Python takes input as string by default.

Example:
name = input("Enter your name: ")
print(name)
Input with type conversion:
age = int(input("Enter age: "))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿงฎ Multiple Assignment

Example:
a, b, c = 10, 20, 30
Same value assignment:
x = y = z = 5

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 2

โœ” Create variables of different data types
โœ” Use type() to check data type
โœ” Take user input for name and age
โœ” Convert string input to integer

Example Program:
name = input("Enter name: ")
age = int(input("Enter age: "))
print(name, age)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 2 Goal

โœ” Understand variables
โœ” Learn Python data types
โœ” Take user input confidently

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 3
๐Ÿ”ฅ Operators in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder

React โค๏ธ If You Got It Right
๐Ÿ PYTHON โ€“ DAY 3 STUDY MATERIAL
โœจ Topic: Operators in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What are Operators?
Operators are symbols used to perform operations on variables and values.

Example:
a = 10
b = 5
c = a + b

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โž• Arithmetic Operators

Addition
Subtraction
Multiplication
/ Division
% Modulus
** Exponent
// Floor Division

Example:
a = 10
b = 3
print(a + b) # 13
print(a % b) # 1
print(a ** b) # 1000
print(a // b) # 3

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŸฐ Assignment Operators

= Assign
+= Add and assign
-= Subtract and assign
*= Multiply and assign
/= Divide and assign

Example:
x = 10
x += 5
print(x) # 15

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Comparison Operators

== Equal to
!= Not equal
Greater than
< Less than
= Greater than or equal
<= Less than or equal

Example:
a = 10
b = 5
print(a > b) # True
print(a == b) # False

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿง  Logical Operators

and โ†’ True if both conditions are True
or โ†’ True if any condition is True
not โ†’ Reverses the result

Example:

a = 10
print(a > 5 and a < 20)
print(a > 5 or a > 20)
print(not(a > 5))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”— Membership Operators

in โ†’ True if value is present
not in โ†’ True if value is not present

Example:
nums = [1, 2, 3, 4]
print(3 in nums)
print(5 not in nums)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ†” Identity Operators

is โ†’ True if both refer to same object
is not โ†’ True if different objects

Example:
a = 10
b = 10
print(a is b)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 3

โœ” Perform all arithmetic operations
โœ” Compare two numbers
โœ” Use logical operators with conditions
โœ” Check membership in a list

Example Program:
a = int(input("Enter a number: "))
b = int(input("Enter another number: "))
print(a > b)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 3 Goal

โœ” Understand all Python operators
โœ” Use operators in real programs

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 4
๐Ÿ”ฅ Conditional Statements (if, if-else)
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder

React โค๏ธ If You Got It Right
๐Ÿ PYTHON โ€“ DAY 4 STUDY MATERIAL
โœจ Topic: Conditional Statements (if, if-else)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What are Conditional Statements?
Conditional statements are used to make decisions in a program based on conditions.
Python executes code only if the condition is True.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น if Statement
Used to execute a block of code when a condition is True.

Syntax:
if condition:
statement

Example:
age = 18
if age >= 18:
print("Eligible to vote")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น if-else Statement
Used when two conditions are possible.

Syntax:
if condition:
statement
else:
statement

Example:
num = 5
if num % 2 == 0:
print("Even number")
else:
print("Odd number")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Indentation in Python

Indentation defines code blocks in Python.
Incorrect indentation causes errors.

Correct:
if True:
print("Python")

Wrong:
if True:
print("Python")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Relational Operators with if
You can use comparison operators inside conditions.

Example:
a = 10
b = 20
if a < b:
print("b is greater")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Multiple Conditions using Logical Operators

Example:
age = 25
if age >= 18 and age <= 60:
print("Eligible")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 4

โœ” Check whether a number is positive or negative
โœ” Check even or odd number
โœ” Check voting eligibility
โœ” Compare two numbers

Example Program:
num = int(input("Enter a number: "))
if num >= 0:
print("Positive number")
else:
print("Negative number")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 4 Goal

โœ” Understand decision making in Python
โœ” Use if and if-else confidently

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 5
๐Ÿ”ฅ if-elif-else & Nested Conditions
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder

React โค๏ธ If You Got It Right
โค1
๐Ÿ PYTHON โ€“ DAY 5 STUDY MATERIAL
โœจ Topic: if-elif-else & Nested Conditions

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is if-elif-else?

The if-elif-else statement is used when multiple conditions need to be checked.
Python checks conditions from top to bottom and executes the first True block.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น if-elif-else Syntax

if condition1:
statement
elif condition2:
statement
elif condition3:
statement
else:
statement

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Example: Grade System

marks = 85
if marks >= 90:
print("Grade A")
elif marks >= 75:
print("Grade B")
elif marks >= 60:
print("Grade C")
else:
print("Fail")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Nested if Statement
An if inside another if is called nested if.

Example:
age = 20
if age >= 18:
if age <= 60:
print("Eligible")
else:
print("Over age limit")
else:
print("Not eligible")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Logical Operators with Conditions
Logical operators can reduce nested conditions.

Example:
age = 25
if age >= 18 and age <= 60:
print("Eligible")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Common Mistakes

โŒ Using wrong indentation
โŒ Missing colon (:)
โŒ Wrong condition order

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 5

โœ” Create a grade calculator
โœ” Check eligibility using nested if
โœ” Find largest of three numbers
โœ” Convert nested if into logical condition

Example Program:
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
if a > b and a > c:
print("a is largest")
elif b > c:
print("b is largest")
else:
print("c is largest")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 5 Goal

โœ” Handle multiple conditions
โœ” Write clean conditional logic

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 6
๐Ÿ”ฅ while Loop in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder

React โค๏ธ If You Got It Right
๐Ÿ PYTHON โ€“ DAY 6 STUDY MATERIAL
โœจ Topic: while Loop in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is a Loop?
A loop is used to repeat a block of code multiple times until a condition becomes False.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” What is while Loop?

The while loop executes a block of code as long as the condition is True.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Syntax of while Loop

while condition:
statement
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Example: Print Numbers 1 to 5

i = 1
while i <= 5:
print(i)
i = i + 1
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Example: Sum of Numbers

i = 1
sum = 0
while i <= 5:
sum = sum + i
i = i + 1
print(sum)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Infinite Loop
A loop that never ends is called an infinite loop.

Example (Avoid this):
while True:
print("Python")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Common Mistakes in while Loop

โŒ Forgetting to update loop variable
โŒ Wrong condition
โŒ Infinite loop

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 6

โœ” Print numbers from 1 to 10
โœ” Print even numbers using while loop
โœ” Find factorial of a number
โœ” Reverse a number

Example Program:
num = int(input("Enter a number: "))
rev = 0
while num > 0:
digit = num % 10
rev = rev * 10 + digit
num = num // 10
print("Reverse:", rev)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 6 Goal

โœ” Understand repetition using while loop
โœ” Avoid infinite loops

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 7
๐Ÿ”ฅ for Loop in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 7 STUDY MATERIAL
โœจ Topic: for Loop in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is for Loop?
The for loop is used to iterate over a sequence such as a list, tuple, string, or range.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Syntax of for Loop
for variable in sequence:
statement

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Using range() Function

range() generates a sequence of numbers.
range(start, stop, step)

Example:
for i in range(1, 6):
print(i)

Output:
1 2 3 4 5

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Example: Print Even Numbers

for i in range(2, 11, 2):
print(i)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Looping Through a String
for ch in "Python":
print(ch)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ”น Nested for Loop
A for loop inside another for loop.

Example:
for i in range(1, 4):
for j in range(1, 4):
print(i, j)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Difference Between for and while Loop

โ€ข for loop is used when number of iterations is known
โ€ข while loop is used when condition is unknown

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 7

โœ” Print numbers from 1 to 10
โœ” Print multiplication table
โœ” Print characters of a string
โœ” Create star pattern using nested loop

Example Program:
for i in range(1, 6):
print("*" * i)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 7 Goal
โœ” Master iteration using for loop
โœ” Use range() confidently

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 8
๐Ÿ”ฅ break, continue & pass Statements
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 8 STUDY MATERIAL
โœจ Topic: break, continue & pass Statements
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ Control Statements in Python

Control statements are used to change the normal flow of loops.
Python provides three control statements:

โ€ข break
โ€ข continue
โ€ข pass

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ›‘ break Statement

The break statement is used to terminate the loop immediately when a condition is met.

Example:
for i in range(1, 10):
if i == 5:
break
print(i)
Output:
1 2 3 4

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โญ continue Statement

The continue statement skips the current iteration and moves to the next one.

Example:
for i in range(1, 6):
if i == 3:
continue
print(i)
Output:
1 2 4 5

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โธ pass Statement

The pass statement is used as a placeholder where a statement is required but no action is needed.

Example:
for i in range(1, 5):
if i == 2:
pass
print(i)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Difference Between break, continue & pass

โ€ข break โ†’ Stops loop completely
โ€ข continue โ†’ Skips current iteration
โ€ข pass โ†’ Does nothing, avoids error

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 8

โœ” Stop loop when number equals 7
โœ” Skip printing number 5
โœ” Use pass inside empty if block
โœ” Combine loop with break & continue

Example Program:
for i in range(1, 11):
if i == 5:
continue
if i == 8:
break
print(i)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 8 Goal
โœ” Control loop execution
โœ” Understand loop flow clearly

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 9
๐Ÿ”ฅ Pattern Programs (Stars & Numbers)
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder


React โค๏ธ If You Got It Right
๐Ÿ PYTHON โ€“ DAY 9 STUDY MATERIAL
โœจ Topic: Pattern Programs (Stars & Numbers)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What are Pattern Programs?

Pattern programs use loops and logic to print designs using stars (*) or numbers.
They help improve loop control and logical thinking.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โญ Star Pattern โ€“ Right Triangle

Code:
for i in range(1, 6):
print("*" * i)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โญ Star Pattern โ€“ Inverted Triangle

Code:
for i in range(5, 0, -1):
print("*" * i)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โญ Pyramid Star Pattern

Code:
n = 4
for i in range(n):
print(" " * (n - i - 1) + "*" * (2 * i + 1))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”ข Number Pattern โ€“ Increasing Numbers

1
12
123
1234

Code:
for i in range(1, 5):
for j in range(1, i + 1):
print(j, end="")
print()
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”ข Number Pattern โ€“ Same Number

1
22
333
4444

Code:
for i in range(1, 5):
print(str(i) * i)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ’ก Logic Tips for Pattern Programs

โœ” Outer loop โ†’ rows
โœ” Inner loop โ†’ columns
โœ” Spaces control alignment
โœ” Practice regularly

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 9

โœ” Print hollow star rectangle
โœ” Print number pyramid
โœ” Print reverse number pattern
โœ” Create your own pattern

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 9 Goal
โœ” Master nested loops
โœ” Improve logical thinking

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 10
๐Ÿ”ฅ Functions in Python (Basics)
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 10 STUDY MATERIAL
โœจ Topic: Functions in Python (Basics)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is a Function?

A function is a block of reusable code that performs a specific task.
Functions help reduce code repetition and improve readability.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Why Use Functions?

โœ” Code reusability
โœ” Better organization
โœ” Easy debugging
โœ” Saves time and effort

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿงฉ Syntax of a Function

def function_name():
statement

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Example: Simple Function

def greet():
print("Hello Python")
greet()
Output:
Hello Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Function with Parameters
Parameters are values passed to a function.

Example:
def greet(name):
print("Hello", name)
greet("Soham")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Function with Return Value

The return statement sends a value back to the caller.

Example:
def add(a, b):
return a + b
result = add(10, 20)
print(result)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Function Call

Calling a function means executing it.
Example:
add(5, 3)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โš ๏ธ Important Points

โ€ข Function name should be meaningful
โ€ข Use indentation properly
โ€ข return ends the function execution

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 10

โœ” Create a function to print your name
โœ” Create a function to add two numbers
โœ” Create a function to find square of a number
โœ” Create a function to check even or odd

Example Program:
def square(n):
return n * n
print(square(5))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 10 Goal
โœ” Understand function basics
โœ” Write reusable code

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 11
๐Ÿ”ฅ Function Arguments (Types)
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
โค1
๐Ÿ PYTHON โ€“ DAY 11 STUDY MATERIAL
โœจ Topic: Function Arguments (Types)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What are Function Arguments?

Arguments are values passed to a function when it is called.
They allow functions to work with different inputs.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น 1. Positional Arguments

Arguments are passed in the same order as parameters.

Example:
def add(a, b):
print(a + b)
add(10, 5)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น 2. Keyword Arguments

Arguments are passed using parameter names, order does not matter.

Example:
def greet(name, msg):
print(msg, name)
greet(msg="Hello", name="Soham")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น 3. Default Arguments

Default values are used when no argument is passed.

Example:
def greet(name="User"):
print("Hello", name)
greet()
greet("Python")
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ”น 4. Variable-Length Arguments (*args)

Used when number of arguments is unknown.

Example:
def total(*nums):
print(sum(nums))
total(10, 20, 30)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น 5. Keyword Variable-Length Arguments

Used to pass key-value pairs.

Example:
def details(**info):
print(info)
details(name="Soham", age=20)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โš ๏ธ Important Notes

โ€ข Positional arguments come first
โ€ข Default arguments should be last
โ€ข *args โ†’ tuple
โ€ข **kwargs โ†’ dictionary

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 11

โœ” Use positional & keyword arguments
โœ” Create function with default value
โœ” Create function using *args
โœ” Create function using **kwargs

Example Program:
def marks(*m):
print(sum(m))
marks(60, 70, 80)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 11 Goal
โœ” Understand all types of function arguments
โœ” Write flexible functions

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 12
๐Ÿ”ฅ Recursion in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 12 STUDY MATERIAL
โœจ Topic: Recursion in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is Recursion?

Recursion is a technique where a function calls itself to solve a problem.
It is useful for problems that can be broken into smaller sub-problems.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Two Important Parts of Recursion

1๏ธโƒฃ Base Condition โ€“ Stops recursion
2๏ธโƒฃ Recursive Call โ€“ Function calls itself
Without base condition โ†’ infinite recursion โŒ

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Syntax of Recursive Function

def function_name():
if base_condition:
return value
return function_name(smaller_problem)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”ข Example: Factorial using Recursion

def factorial(n):
if n == 1:
return 1
return n * factorial(n - 1)
print(factorial(5))

Output:
120

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Example: Fibonacci Series

def fib(n):
if n <= 1:
return n
return fib(n - 1) + fib(n - 2)
print(fib(6))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โš ๏ธ Important Notes

โ€ข Always define a base case
โ€ข Recursive calls increase memory usage
โ€ข Not suitable for very large problems

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 12

โœ” Find factorial of a number
โœ” Print Fibonacci series
โœ” Calculate sum of digits using recursion
โœ” Reverse a number using recursion

Example Program:
def sum_digits(n):
if n == 0:
return 0
return n % 10 + sum_digits(n // 10)
print(sum_digits(123))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 12 Goal
โœ” Understand recursive thinking
โœ” Write correct recursive functions

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 13
๐Ÿ”ฅ Strings in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 13 STUDY MATERIAL
โœจ Topic: Strings in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is a String?

A string is a sequence of characters enclosed in single (' ') or double (" ") quotes.

Example:
name = "Python"
msg = 'Hello'

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”ข String Indexing

Each character in a string has an index number, starting from 0.

Example:
text = "Python"
text[0] โ†’ P
text[1] โ†’ y
text[-1] โ†’ n

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โœ‚๏ธ String Slicing
Used to extract a portion of a string.

Syntax:
string[start:end]

Example:
text = "Python"
print(text[0:3]) # Pyt
print(text[2:]) # thon
print(text[:4]) # Pyth

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” String Looping

Example:
for ch in "Python":
print(ch)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿงฎ String Length
Use len() to find string length.

Example:
text = "Python"
print(len(text))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”’ Strings are Immutable

Strings cannot be changed once created.

Example:
text = "Python"
text[0] = 'J' โŒ Error

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 13

โœ” Print each character of a string
โœ” Reverse a string
โœ” Find length of a string
โœ” Extract substring

Example Program:
text = input("Enter a string: ")
print(text[::-1])

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 13 Goal
โœ” Understand string basics
โœ” Use indexing and slicing confidently

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 14
๐Ÿ”ฅ String Methods
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 14 STUDY MATERIAL
โœจ Topic: String Methods in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What are String Methods?

String methods are built-in functions used to manipulate and format strings.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”ค Common String Methods

๐Ÿ”น upper() โ€“ Converts string to uppercase

Example:
text = "python"
print(text.upper())

๐Ÿ”น lower() โ€“ Converts string to lowercase
print(text.lower())

๐Ÿ”น title() โ€“ Capitalizes first letter of each word
print("hello world".title())

๐Ÿ”น capitalize() โ€“ Capitalizes first character
print("python".capitalize())

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โœ‚๏ธ Trim Methods

๐Ÿ”น strip() โ€“ Removes spaces from both sides
๐Ÿ”น lstrip() โ€“ Removes left spaces
๐Ÿ”น rstrip() โ€“ Removes right spaces

Example:
text = " python "
print(text.strip())

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Replace & Split

๐Ÿ”น replace() โ€“ Replaces part of string
print("hello python".replace("python", "world"))

๐Ÿ”น split() โ€“ Splits string into list
print("a,b,c".split(","))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Search Methods

๐Ÿ”น find() โ€“ Returns index of substring
print("python".find("t"))

๐Ÿ”น count() โ€“ Counts occurrences
print("banana".count("a"))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โ“ Check Methods

๐Ÿ”น isalpha() โ€“ Checks alphabets
๐Ÿ”น isdigit() โ€“ Checks digits
๐Ÿ”น isalnum() โ€“ Checks alphanumeric

Example:
print("Python123".isalnum())

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 14
โœ” Convert string to uppercase
โœ” Count vowels in string
โœ” Replace a word in sentence
โœ” Split full name into first and last name

Example Program:
text = input("Enter text: ")
print(text.upper())

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 14 Goal
โœ” Master common string methods
โœ” Manipulate strings effectively

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 15
๐Ÿ”ฅ Lists in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 15 STUDY MATERIAL
โœจ Topic: Lists in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is a List?

A list is a collection of items stored in a single variable.
Lists are ordered, mutable (changeable) and allow duplicate values.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Creating a List

Example:
nums = [10, 20, 30, 40]
names = ["Python", "Java", "C"]

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”ข List Indexing

Example:
nums = [10, 20, 30]
nums[0] โ†’ 10
nums[-1] โ†’ 30

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โœ‚๏ธ List Slicing

Example:
nums = [1, 2, 3, 4, 5]
print(nums[1:4]) # [2, 3, 4]

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โœ๏ธ Modify List Elements

Example:
nums = [10, 20, 30]
nums[1] = 25
print(nums)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Looping Through List

Example:
for n in nums:
print(n)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿงฎ List Length

Example:
print(len(nums))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 15

โœ” Create a list of numbers
โœ” Access elements using index
โœ” Change list elements
โœ” Print all list elements using loop

Example Program:
nums = [5, 10, 15, 20]
for n in nums:
print(n)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 15 Goal
โœ” Understand list basics
โœ” Use lists confidently

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 16
๐Ÿ”ฅ List Methods
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 16 STUDY MATERIAL
โœจ Topic: List Methods in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What are List Methods?

List methods are built-in functions used to add, remove, and manage list elements.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โž• Adding Elements

๐Ÿ”น append() โ€“ Adds element at the end
Example:
nums = [1, 2, 3]
nums.append(4)

๐Ÿ”น insert() โ€“ Adds element at specific index
nums.insert(1, 10)

๐Ÿ”น extend() โ€“ Adds multiple elements
nums.extend([5, 6])

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โž– Removing Elements

๐Ÿ”น remove() โ€“ Removes specific value
nums.remove(10)

๐Ÿ”น pop() โ€“ Removes element by index
nums.pop()
nums.pop(1)

๐Ÿ”น clear() โ€“ Removes all elements
nums.clear()
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”„ Other Useful List Methods

๐Ÿ”น sort() โ€“ Sorts list
nums.sort()

๐Ÿ”น reverse() โ€“ Reverses list
nums.reverse()

๐Ÿ”น count() โ€“ Counts occurrence
nums.count(2)

๐Ÿ”น index() โ€“ Returns index of value
nums.index(3)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿง  List Copy

๐Ÿ”น copy() โ€“ Creates shallow copy
new_list = nums.copy()

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โš ๏ธ Important Notes

โ€ข Lists are mutable
โ€ข sort() changes original list
โ€ข Use sorted() to keep original list

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 16

โœ” Add elements using append & insert
โœ” Remove elements using pop & remove
โœ” Sort a list
โœ” Reverse a list

Example Program:
nums = [4, 2, 1, 3]
nums.sort()
print(nums)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 16 Goal
โœ” Master list operations
โœ” Manage list data efficiently

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 17
๐Ÿ”ฅ Tuples in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 17 STUDY MATERIAL
โœจ Topic: Tuples in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is a Tuple?

A tuple is a collection of items stored in a single variable.
Tuples are ordered and immutable (cannot be changed).

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Creating a Tuple

Example:
t = (10, 20, 30)
names = ("Python", "Java", "C")
Single element tuple:
x = (10,) โœ” comma is required

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”ข Tuple Indexing

Example:
t = (10, 20, 30)
t[0] โ†’ 10
t[-1] โ†’ 30

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โœ‚๏ธ Tuple Slicing

Example:
t = (1, 2, 3, 4, 5)
print(t[1:4])

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Looping Through Tuple

Example:
for item in t:
print(item)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”’ Tuple Immutability
Tuple elements cannot be modified.

Example:
t = (10, 20, 30)
t[0] = 5 โŒ Error

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿงฎ Tuple Methods

๐Ÿ”น count() โ€“ Counts occurrence
๐Ÿ”น index() โ€“ Returns index

Example:
t = (1, 2, 2, 3)
print(t.count(2))
print(t.index(3))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”„ Convert Tuple to List

Example:
t = (1, 2, 3)
lst = list(t)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 17

โœ” Create tuple of numbers
โœ” Access elements using index
โœ” Loop through tuple
โœ” Convert tuple to list

Example Program:
t = (5, 10, 15)
for i in t:
print(i)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 17 Goal
โœ” Understand tuple basics
โœ” Know difference between list & tuple

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 18
๐Ÿ”ฅ Sets in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 18 STUDY MATERIAL
โœจ Topic: Sets in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is a Set?

A set is a collection of unique elements stored in a single variable.
Sets are unordered and do not allow duplicate values.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Creating a Set

Example:
s = {10, 20, 30}
names = {"Python", "Java", "C"}
Duplicate values are removed automatically:
s = {1, 2, 2, 3}
Output โ†’ {1, 2, 3}

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โž• Add Elements to Set

๐Ÿ”น add() โ€“ Adds single element
s.add(40)

๐Ÿ”น update() โ€“ Adds multiple elements
s.update([50, 60])
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โž– Remove Elements from Set

๐Ÿ”น remove() โ€“ Removes element (error if not found)
s.remove(20)

๐Ÿ”น discard() โ€“ Removes element (no error)
s.discard(100)

๐Ÿ”น pop() โ€“ Removes random element
s.pop()

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”„ Set Operations

๐Ÿ”น union() โ€“ Combines sets
๐Ÿ”น intersection() โ€“ Common elements
๐Ÿ”น difference() โ€“ Remaining elements

Example:
a = {1, 2, 3}
b = {3, 4, 5}
print(a.union(b))
print(a.intersection(b))
print(a.difference(b))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿงฎ Check Membership

Example:
print(2 in a)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 18

โœ” Create a set
โœ” Add and remove elements
โœ” Perform union & intersection
โœ” Remove duplicate values from list using set

Example Program:
lst = [1, 2, 2, 3, 4]
s = set(lst)
print(s)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 18 Goal
โœ” Understand set properties
โœ” Perform set operations

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 19
๐Ÿ”ฅ Dictionaries in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 19 STUDY MATERIAL
โœจ Topic: Dictionaries in Python

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ What is a Dictionary?

A dictionary stores data in keyโ€“value pairs.
Dictionaries are unordered, mutable, and keys must be unique.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”น Creating a Dictionary

Example:
student = {
"name": "Soham",
"age": 20,
"course": "Python"
}

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ”‘ Access Dictionary Values

Example:
print(student["name"])
print(student.get("age"))

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โœ๏ธ Modify Dictionary

Example:
student["age"] = 21
student["city"] = "Pune"

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โŒ Remove Dictionary Items

๐Ÿ”น pop() โ€“ Removes specific key
student.pop("city")

๐Ÿ”น popitem() โ€“ Removes last item
student.popitem()

๐Ÿ”น clear() โ€“ Removes all items
student.clear()

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Loop Through Dictionary

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

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿงฎ Dictionary Methods

๐Ÿ”น keys() โ€“ Returns all keys
๐Ÿ”น values() โ€“ Returns all values
๐Ÿ”น items() โ€“ Returns key-value pairs

Example:
print(student.keys())
print(student.values())

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 19

โœ” Create student dictionary
โœ” Add and update values
โœ” Loop through dictionary
โœ” Delete a key

Example Program:
student = {"name": "Amit", "age": 22}
for k, v in student.items():
print(k, v)

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 19 Goal
โœ” Understand key-value storage
โœ” Use dictionaries effectively

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 20
๐Ÿ”ฅ Dictionary Methods & Nested Dictionary
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 20 STUDY MATERIAL
โœจ Topic: Dictionary Methods & Nested Dictionary

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“Œ Important Dictionary Methods

๐Ÿ”น update() โ€“ Adds or updates key-value pairs

Example:
student = {"name": "Soham"}
student.update({"age": 21})

๐Ÿ”น get() โ€“ Returns value of key
print(student.get("name"))

๐Ÿ”น setdefault() โ€“ Returns value, adds key if not present
student.setdefault("city", "Pune")

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

โŒ Removing Dictionary Data

๐Ÿ”น del โ€“ Deletes key
del student["age"]

๐Ÿ”น clear() โ€“ Removes all data
student.clear()

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿงฉ Nested Dictionary

A dictionary inside another dictionary is called a nested dictionary.

Example:
students = {
1: {"name": "Amit", "age": 20},
2: {"name": "Soham", "age": 21}
}
Access nested value:
print(students[1]["name"])

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ” Loop Through Nested Dictionary

Example:
for id, info in students.items():
print(id, info["name"], info["age"])

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿงฎ Copy Dictionary

๐Ÿ”น copy() โ€“ Creates shallow copy
new_dict = student.copy()

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“ Practice Tasks โ€“ Day 20

โœ” Use update() and setdefault()
โœ” Create nested dictionary
โœ” Access and print nested values
โœ” Loop through nested dictionary

Example Program:
data = {1: {"name": "Raj", "marks": 80}}
print(data[1]["marks"])

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐ŸŽฏ Day 20 Goal
โœ” Master dictionary methods
โœ” Work with nested dictionaries

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ“… Next Topic โ€“ Day 21
๐Ÿ”ฅ Revision + Practice (Week Review)
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder