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
Correct Answer: B) False

🧠 Explanation :

5 > 3 → True

2 < 1 → False

True and False → False

📌 Rule: and returns True only if both conditions are True.

React ❤️ if you got it Right
🐍 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