๐ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
โจ 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
๐ PYTHON โ DAY 21 STUDY MATERIAL
โจ Topic: Revision + Practice (Week Review)
โโโโโโโโโโโโโโโโโโโ
๐ Topics Covered (Day 1 โ Day 20)
โ Python Introduction & Installation
โ Variables & Data Types
โ Operators
โ Conditional Statements
โ while Loop & for Loop
โ break, continue, pass
โ Pattern Programs
โ Functions & Arguments
โ Recursion
โ Strings & String Methods
โ Lists & List Methods
โ Tuples
โ Sets
โ Dictionaries & Nested Dictionary
โโโโโโโโโโโโโโโโโโโ
๐ง Quick Revision Points
๐น Variables are dynamically typed
๐น Indentation is mandatory in Python
๐น Lists are mutable, tuples are immutable
๐น Sets store unique values
๐น Dictionaries store key-value pairs
๐น Functions reduce code repetition
โโโโโโโโโโโโโโโโโโโ
๐งช Practice Programs โ Day 21
1๏ธโฃ Check whether a number is even or odd
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")
โโโโโโโโโโโโโโโโโโโ
2๏ธโฃ Find sum of elements in a list
nums = [10, 20, 30]
print(sum(nums))
โโโโโโโโโโโโโโโโโโโ
3๏ธโฃ Reverse a string
text = input("Enter string: ")
print(text[::-1])
โโโโโโโโโโโโโโโโโโโ
4๏ธโฃ Count frequency using dictionary
text = "python"
freq = {}
for ch in text:
freq[ch] = freq.get(ch, 0) + 1
print(freq)
โโโโโโโโโโโโโโโโโโโ
โญ Challenge Tasks
โ Print star pyramid
โ Create simple calculator using functions
โ Remove duplicates from list
โ Store student data using dictionary
โโโโโโโโโโโโโโโโโโโ
๐ฏ Day 21 Goal
โ Revise all fundamentals
โ Identify weak topics
โ Build confidence in basics
โโโโโโโโโโโโโโโโโโโ
๐ Next Topic โ Day 22
๐ฅ File Handling in Python
โจ Stay Connected | Keep Coding
๐ TechByWebCoder
โจ Topic: Revision + Practice (Week Review)
โโโโโโโโโโโโโโโโโโโ
๐ Topics Covered (Day 1 โ Day 20)
โ Python Introduction & Installation
โ Variables & Data Types
โ Operators
โ Conditional Statements
โ while Loop & for Loop
โ break, continue, pass
โ Pattern Programs
โ Functions & Arguments
โ Recursion
โ Strings & String Methods
โ Lists & List Methods
โ Tuples
โ Sets
โ Dictionaries & Nested Dictionary
โโโโโโโโโโโโโโโโโโโ
๐ง Quick Revision Points
๐น Variables are dynamically typed
๐น Indentation is mandatory in Python
๐น Lists are mutable, tuples are immutable
๐น Sets store unique values
๐น Dictionaries store key-value pairs
๐น Functions reduce code repetition
โโโโโโโโโโโโโโโโโโโ
๐งช Practice Programs โ Day 21
1๏ธโฃ Check whether a number is even or odd
num = int(input("Enter number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")
โโโโโโโโโโโโโโโโโโโ
2๏ธโฃ Find sum of elements in a list
nums = [10, 20, 30]
print(sum(nums))
โโโโโโโโโโโโโโโโโโโ
3๏ธโฃ Reverse a string
text = input("Enter string: ")
print(text[::-1])
โโโโโโโโโโโโโโโโโโโ
4๏ธโฃ Count frequency using dictionary
text = "python"
freq = {}
for ch in text:
freq[ch] = freq.get(ch, 0) + 1
print(freq)
โโโโโโโโโโโโโโโโโโโ
โญ Challenge Tasks
โ Print star pyramid
โ Create simple calculator using functions
โ Remove duplicates from list
โ Store student data using dictionary
โโโโโโโโโโโโโโโโโโโ
๐ฏ Day 21 Goal
โ Revise all fundamentals
โ Identify weak topics
โ Build confidence in basics
โโโโโโโโโโโโโโโโโโโ
๐ Next Topic โ Day 22
๐ฅ File Handling in Python
โจ Stay Connected | Keep Coding
๐ TechByWebCoder