Day 29 : How To Solve Swap Two Numbers Problem | 30 Days of Code Challenge
Tutorial Video : - https://youtube.com/shorts/_1CK2vS3ayM
Source Code : - https://github.com/TechbyWebCoder/Python_Problem
Follow For More....!!
Tutorial Video : - https://youtube.com/shorts/_1CK2vS3ayM
Source Code : - https://github.com/TechbyWebCoder/Python_Problem
Follow For More....!!
Day 30 : How To Solve Trimorphic Number Problem | 30 Days of Code Challenge
Tutorial Video : - https://youtube.com/shorts/BV34hO4_Ahc
Source Code : - https://github.com/TechbyWebCoder/Python_Problem
Follow For More....!!
Tutorial Video : - https://youtube.com/shorts/BV34hO4_Ahc
Source Code : - https://github.com/TechbyWebCoder/Python_Problem
Follow For More....!!
Top 10 Python Problem Challenge (For Beginner) | Part 1
Tutorial Video : - https://youtu.be/v5PeqzrW6UE
Follow For More....!!
Tutorial Video : - https://youtu.be/v5PeqzrW6UE
Follow For More....!!
Top 10 Python Problem Challenge (For Beginner) | Part 2
Tutorial Video : - https://youtu.be/xx1mO-OZAYQ
Follow For More....!!
Tutorial Video : - https://youtu.be/xx1mO-OZAYQ
Follow For More....!!
Top 10 Python Problem Challenge (For Beginner) | Part 3
Tutorial Video : - https://youtu.be/UT0NwA4fmhI
Follow For More....!!
Tutorial Video : - https://youtu.be/UT0NwA4fmhI
Follow For More....!!
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 !!
(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)
👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻
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 !!
(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)
👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻👇🏻
Topic :- Python (Top 30 Pattern Program With Source Code)
👍1
🧠 Python MCQ Question
❓What will be the output of the following? >>print(10 // 3)
❓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
📘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)
❓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
🧠 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
✨ 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