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
IMPORTANT PROBLEM CODE USING PYTHON 📽

(PYTHON PROBLEM PROGRAM)

1. 1 TO 10 PROGRAM
https://youtu.be/v5PeqzrW6UE

2. 11 TO 20 PROGRAM
https://youtu.be/xx1mO-OZAYQ

3. 21 TO 30 PROGRAM
https://youtu.be/UT0NwA4fmhI

FOLLOW FOR MORE !!
Forwarded from TECH BY WEB CODER
Python Function With Ex.pdf
1.8 MB
Important Web Developer And Programming Language Related Notes🔗

👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻

Topic :- Python (Basic To Advance All Functions With Example)
IMPORTANT PATTERN CODE USING PYTHON 📽

(30 INTERVIEW RELATED PATTERN PROGRAM)

1. STAR PATTERN PROGRAM
https://youtu.be/bxen7i1YRJ0?si=0kim8S0bG1Ee3ESl

2. NUMBER PATTERN PROGRAM
https://youtu.be/_5UaekFc2tw?si=efgKy3_AQIDCcYPk

3. ALPHABET PATTERN PROGRAM
https://youtu.be/V-lQ2MJ5KEk?si=mIY6XMMP_Jm4danw

FOLLOW FOR MORE !!
👍1👌1
Forwarded from TECH BY WEB CODER
Python Pattern.pdf
3 MB
Important Web Developer And Programming Language Related Program🔗

👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻

Topic :- Python (Top 30 Pattern Program With Source Code)
👍1
🧠 Python MCQ Question

What will be the output of the following? >>print(10 // 3)
Anonymous Poll
35%
3.33
55%
3
6%
4
4%
Error
Correct Answer: B) 3

📘Explanation:

In Python, // is the floor division operator in Python.
It divides the numbers and returns the integer part (floor value).
So 10 // 3 gives 3, not 3.33.

React ❤️ if you got it Right
2
🧠 Python MCQ Question

What will be the output of the following Python Program? print(5 > 3 and 2 < 1)
Anonymous Poll
40%
True
55%
False
5%
None
0%
Error
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