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

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

For promotions & collaborations:
techbywedcoder@gmail.com

Join now and accelerate your Python journey!
Download Telegram
๐Ÿ PYTHON โ€“ DAY 26 STUDY MATERIAL
โœจ Topic: Modules in Python

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

๐Ÿ“Œ What is a Module?

A module is a file containing Python code (functions, variables, classes) that can be reused in another program.
It helps in code reusability and organization.

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

๐Ÿ“ฆ Importing a Module

Syntax:
import module_name

Example:
import math
print(math.sqrt(25))

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

๐Ÿ”น Import Specific Function

Syntax:
from module_name import function_name

Example:
from math import sqrt
print(sqrt(16))

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

๐Ÿ”น Import with Alias

Example:
import math as m
print(m.pi)

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

๐Ÿงฎ Common Built-in Modules

๐Ÿ”น math โ€“ Mathematical operations
๐Ÿ”น random โ€“ Random number generation
๐Ÿ”น datetime โ€“ Date & time handling
๐Ÿ”น os โ€“ Operating system functions

Example (random):
import random
print(random.randint(1, 10))

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

๐Ÿ›  Creating User-Defined Module

Step 1: Create file mymodule.py
def greet():
print("Hello from module")

Step 2: Import in another file
import mymodule
mymodule.greet()

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

โš ๏ธ Important Points

โ€ข Module file must be in same folder
โ€ข Avoid naming conflict with built-in modules
โ€ข Use alias for shorter names

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

๐Ÿ“ Practice Tasks โ€“ Day 26

โœ” Use math module
โœ” Generate random number
โœ” Create your own module
โœ” Import specific function

Example Program:
from random import randint
print(randint(1, 100))

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

๐ŸŽฏ Day 26 Goal
โœ” Understand module usage
โœ” Create reusable code files

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

๐Ÿ“… Next Topic โ€“ Day 27
๐Ÿ”ฅ OOP โ€“ Class & Object
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 27 STUDY MATERIAL
โœจ Topic: OOP โ€“ Class & Object

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

๐Ÿ“Œ What is OOP?

OOP (Object Oriented Programming) is a programming concept based on objects and classes.

It helps in:
โœ” Code reusability
โœ” Data security
โœ” Real-world modeling

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

๐Ÿท What is a Class?
A class is a blueprint for creating objects.

Syntax:
class ClassName:
pass

Example:
class Student:
pass

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

๐Ÿ‘ค What is an Object?
An object is an instance of a class.

Example:
s1 = Student()
Here, s1 is an object.

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

๐Ÿ”น Class with Attributes

Example:
class Student:
name = "Soham"
age = 20
obj = Student()
print(obj.name)

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

๐Ÿ”น init Constructor Method

Used to initialize object data.

Example:
class Student:
def init(self, name, age):
self.name = name
self.age = age
s1 = Student("Rahul", 22)
print(s1.name)

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

๐Ÿ”น Instance Method

Example:
class Student:
def init(self, name):
self.name = name
def greet(self):
print("Hello", self.name)
s1 = Student("Amit")
s1.greet()

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

๐Ÿง  Understanding self Keyword

โ€ข self refers to the current object
โ€ข It must be the first parameter in class methods

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

๐Ÿ“ Practice Tasks โ€“ Day 27

โœ” Create class Car with attributes
โœ” Create object of Car
โœ” Use constructor
โœ” Create method inside class

Example Program:
class Car:
def init(self, brand):
self.brand = brand
def show(self):
print("Brand:", self.brand)
c1 = Car("BMW")
c1.show()

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

๐ŸŽฏ Day 27 Goal
โœ” Understand class & object
โœ” Use constructor and methods

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

๐Ÿ“… Next Topic โ€“ Day 28
๐Ÿ”ฅ OOP โ€“ Encapsulation
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 28 STUDY MATERIAL
โœจ Topic: OOP โ€“ Encapsulation

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

๐Ÿ“Œ What is Encapsulation?
Encapsulation means binding data (variables) and methods (functions) together in a single unit (class) and restricting direct access to some data.

It helps in:
โœ” Data protection
โœ” Better security
โœ” Controlled access

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

๐Ÿ”’ Access Modifiers in Python

Python does not have strict private/public like other languages, but it follows naming conventions:

๐Ÿ”น Public โ†’ Accessible anywhere
๐Ÿ”น Protected โ†’ Single underscore (_)
๐Ÿ”น Private โ†’ Double underscore (__)

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

๐Ÿ”น Public Variable Example

class Student:
def init(self):
self.name = "Soham"
obj = Student()
print(obj.name)

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

๐Ÿ”น Protected Variable Example

class Student:
def init(self):
self._age = 20
obj = Student()
print(obj._age)
(Note: Still accessible, but should not be accessed directly)

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

๐Ÿ” Private Variable Example

class Student:
def init(self):
self.__marks = 85
obj = Student()
print(obj.__marks) โŒ Error
To access private variable:
print(obj._Student__marks)

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

๐Ÿ”น Getter and Setter Methods
Used to access and modify private data safely.

Example:
class Student:
def init(self):
self.__marks = 0
def set_marks(self, m):
self.__marks = m

def get_marks(self):
return self.__marks
s1 = Student()
s1.set_marks(90)
print(s1.get_marks())

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

๐Ÿ“ Practice Tasks โ€“ Day 28

โœ” Create class with private variable
โœ” Create getter & setter
โœ” Try accessing private variable directly
โœ” Understand name mangling

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

๐ŸŽฏ Day 28 Goal
โœ” Understand data hiding
โœ” Use getter & setter properly

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

๐Ÿ“… Next Topic โ€“ Day 29
๐Ÿ”ฅ OOP โ€“ Inheritance
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 29 STUDY MATERIAL
โœจ Topic: OOP โ€“ Inheritance

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

๐Ÿ“Œ What is Inheritance?

Inheritance allows one class to reuse the properties and methods of another class.

โœ” Code Reusability
โœ” Reduces redundancy
โœ” Improves maintainability
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

๐Ÿ‘จโ€๐Ÿ‘ฆ Parent & Child Class

๐Ÿ”น Parent Class โ†’ Base Class
๐Ÿ”น Child Class โ†’ Derived Class

Syntax:
class Parent:
pass
class Child(Parent):
pass

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

๐Ÿ”น Basic Inheritance Example

class Person:
def greet(self):
print("Hello from Parent")
class Student(Person):
pass
s1 = Student()
s1.greet() # Inherited method

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

๐Ÿ”น Inheritance with Constructor

class Person:
def init(self, name):
self.name = name
class Student(Person):
def display(self):
print("Name:", self.name)
s1 = Student("Rahul")
s1.display()

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

๐Ÿ”น Using super() Function

Used to call parent class constructor.
class Person:
def init(self, name):
self.name = name
class Student(Person):
def init(self, name, age):
super().init(name)
self.age = age
def display(self):
print(self.name, self.age)
s1 = Student("Amit", 21)
s1.display()

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

๐Ÿ”น Types of Inheritance in Python

1๏ธโƒฃ Single Inheritance
2๏ธโƒฃ Multiple Inheritance
3๏ธโƒฃ Multilevel Inheritance
4๏ธโƒฃ Hierarchical Inheritance
5๏ธโƒฃ Hybrid Inheritance

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

๐Ÿง  Multilevel Inheritance Example

class A:
def methodA(self):
print("Class A")
class B(A):
def methodB(self):
print("Class B")
class C(B):
def methodC(self):
print("Class C")
obj = C()
obj.methodA()
obj.methodB()
obj.methodC()

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

๐Ÿ“ Practice Tasks โ€“ Day 29

โœ” Create Parent class Vehicle
โœ” Create Child class Car
โœ” Use super()
โœ” Try multilevel inheritance

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

๐ŸŽฏ Day 29 Goal
โœ” Understand Parent & Child relationship
โœ” Use super() correctly
โœ” Practice different inheritance types

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

๐Ÿ“… Next Topic โ€“ Day 30
๐Ÿ”ฅ OOP โ€“ Polymorphism
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 30 STUDY MATERIAL
โœจ Topic: OOP โ€“ Polymorphism

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

๐Ÿ“Œ What is Polymorphism?

Polymorphism means โ€œmany formsโ€.
In Python, it allows the same function name to behave differently depending on the object.

โœ” Increases flexibility
โœ” Improves readability
โœ” Makes code scalable

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

๐Ÿ”น Method Overriding (Runtime Polymorphism)

When a child class provides a different implementation of a method from the parent class.

Example:
class Animal:
def sound(self):
print("Animal makes sound")
class Dog(Animal):
def sound(self):
print("Dog barks")
obj = Dog()
obj.sound()

Output:
Dog barks

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

๐Ÿ”น Polymorphism with Multiple Classes

class Cat:
def sound(self):
print("Meow")
class Dog:
def sound(self):
print("Bark")
def make_sound(animal):
animal.sound()
make_sound(Cat())
make_sound(Dog())
Same function โ†’ Different behavior

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

๐Ÿ”น Operator Overloading

Python allows operators to behave differently for different data types.

Example:
print(5 + 3) # 8
print("Hi " + "All") # Hi All
โ€œ+โ€ works for numbers and strings differently.

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

๐Ÿ”น Method Overloading in Python?

Python does NOT support traditional method overloading like Java.

But we can simulate it using default arguments:
class Calculator:
def add(self, a, b=0, c=0):
return a + b + c
obj = Calculator()
print(obj.add(5))
print(obj.add(5, 3))
print(obj.add(5, 3, 2))

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

๐Ÿง  Real Life Example

Think about a โ€œPaymentโ€ system:
โœ” Credit Card Payment
โœ” UPI Payment
โœ” Net Banking

All use a method like pay(), but the implementation is different.

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

๐Ÿ“ Practice Tasks โ€“ Day 30

โœ” Create class Shape with method area()
โœ” Override area() in Circle & Rectangle
โœ” Create common function to call area()

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

๐ŸŽฏ Day 30 Goal
โœ” Understand Method Overriding
โœ” Understand Dynamic Polymorphism
โœ” Practice real-life examples

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

๐Ÿ“… Next Topic โ€“ Day 31
๐Ÿ”ฅ OOP โ€“ Abstraction
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 31 STUDY MATERIAL
โœจ Topic: OOP โ€“ Abstraction

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

๐Ÿ“Œ What is Abstraction?

Abstraction means hiding implementation details and showing only essential features.
Example in real life ๐Ÿš—
You drive a car without knowing how the engine works internally.

โœ” Hides complexity
โœ” Improves security
โœ” Focus on what, not how

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

๐Ÿ”น How to Achieve Abstraction in Python?

Using the abc (Abstract Base Class) module
We import:
from abc import ABC, abstractmethod

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

๐Ÿ”น Creating an Abstract Class

Example:
from abc import ABC, abstractmethod
class Animal(ABC):
@abstractmethod
def sound(self):
pass
This class cannot be instantiated directly.

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

๐Ÿ”น Implementing Abstract Method in Child Class

from abc import ABC, abstractmethod
class Animal(ABC):
@abstractmethod
def sound(self):
pass
class Dog(Animal):
def sound(self):
print("Dog barks")
obj = Dog()
obj.sound()
If we donโ€™t implement sound(), it gives error โŒ

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

๐Ÿ”น Why Use Abstraction?

โœ” To enforce method implementation
โœ” To create standard structure
โœ” To design scalable applications

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

๐Ÿง  Real World Example

Payment System:
class Payment(ABC):
@abstractmethod
def pay(self):
pass
class UPI(Payment):
def pay(self):
print("Paid using UPI")
class Card(Payment):
def pay(self):
print("Paid using Card")

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

๐Ÿ“ Practice Tasks โ€“ Day 31

โœ” Create abstract class Shape
โœ” Create area() abstract method
โœ” Implement in Circle & Rectangle
โœ” Try creating object of abstract class (see error)

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

๐ŸŽฏ Day 31 Goal
โœ” Understand abstraction
โœ” Use abc module
โœ” Implement abstract methods

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

๐Ÿ“… Next Topic โ€“ Day 32
๐Ÿ”ฅ OOP โ€“ Special (Magic/Dunder) Methods
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
Forwarded from Tech by WebCoder
๐ŸŽ‰ ANNOUNCEMENT ๐ŸŽ‰

๐Ÿš€ TOP 10 LOGIN PAGE VIDEO CHALLENGE! ๐Ÿ”ฅ


HEY EVERYONE! ๐Ÿ‘‹

Iโ€™m super excited to announce a brand-new Login Page Design Challenge on my YouTube channel โ€œ TECHBYWEBCODER โ€!

๐Ÿ“… STARTING FROM: 22 FEBRUARY 2026

๐Ÿ•’ 1 LOGIN PAGE DESIGN EVERY DAY (FOR 10 DAYS)
๐Ÿ“Œ COVERING:
โœ… HTML, CSS & JavaScript
โœ… Modern & Responsive Login Pages
โœ… Glassmorphism & Neumorphism UI
โœ… Animated Login Forms
โœ… Password Show/Hide Feature
โœ… Validation & Error Messages
โœ… Beginner to Advanced Designs
โœ… Real Project Style Layouts
โœ… Clean Code + Full Explanation
โœ… Interview & Portfolio Ready Designs
Whether youโ€™re a beginner in web development or want to improve your UI design skills, this challenge will help you master login page creation step by step.

๐Ÿ”” SUBSCRIBE & TURN ON NOTIFICATIONS so you donโ€™t miss any challenge video!

๐Ÿ‘‰ https://yt.openinapp.co/nz63a

๐Ÿ’ฌ Letโ€™s build stunning login pages together and level up our web development skills โ€” one design at a time! ๐Ÿ’ป๐Ÿ”ฅ
๐Ÿ PYTHON โ€“ DAY 32 STUDY MATERIAL
โœจ Topic: OOP โ€“ Special (Magic / Dunder) Methods

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

๐Ÿ“Œ What are Magic (Dunder) Methods?

Magic methods are special methods that start and end with double underscores:

Example:
init
str
len

They allow us to define behavior for built-in operations.
โ€œDunderโ€ = Double Under ( __ )

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

๐Ÿ”น init Method
Constructor method
Automatically called when object is created.

Example:
class Student:
def init(self, name):
self.name = name
s1 = Student("Rahul")

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

๐Ÿ”น str Method

Used to define what gets printed when we print an object.

Example:
class Student:
def init(self, name):
self.name = name
def str(self):
return f"Student Name: {self.name}"
s1 = Student("Amit")
print(s1)
Without str โ†’ It prints object memory address
With str โ†’ Custom readable output โœ…

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

๐Ÿ”น len Method
Defines behavior for len() function.

Example:
class MyList:
def init(self, items):
self.items = items
def len(self):
return len(self.items)
obj = MyList([1,2,3,4])
print(len(obj))

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

๐Ÿ”น Operator Overloading using Magic Methods

Example: add
class Number:
def init(self, value):
self.value = value
def add(self, other):
return self.value + other.value
n1 = Number(5)
n2 = Number(10)
print(n1 + n2)

Now + works for custom objects ๐Ÿ”ฅ

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

๐Ÿ”น Common Magic Methods

โœ” init โ†’ Constructor
โœ” str โ†’ String representation
โœ” len โ†’ Length
โœ” add โ†’ Addition
โœ” sub โ†’ Subtraction
โœ” mul โ†’ Multiplication
โœ” eq โ†’ Equality

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

๐Ÿ“ Practice Tasks โ€“ Day 32

โœ” Create class Book
โœ” Implement str
โœ” Overload + operator
โœ” Try implementing len

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

๐ŸŽฏ Day 32 Goal
โœ” Understand dunder methods
โœ” Customize built-in operations
โœ” Practice operator overloading

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

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

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

๐Ÿ“Œ What is Exception?
An exception is an error that occurs during program execution.

Examples:
โŒ Division by zero
โŒ Invalid input
โŒ File not found
Without handling โ†’ Program crashes
With handling โ†’ Program continues safely โœ…

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

๐Ÿ”น Basic try-except Syntax

try:
risky code
except:
handle error

Example:
try:
num = 10 / 0
except:
print("Error occurred!")

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

๐Ÿ”น Handling Specific Exceptions

try:
num = int(input("Enter number: "))
print(10 / num)
except ZeroDivisionError:
print("Cannot divide by zero")
except ValueError:
print("Invalid input")

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

๐Ÿ”น Using else Block
Runs if no exception occurs.

try:
num = int(input("Enter number: "))
except ValueError:
print("Invalid input")
else:
print("You entered:", num)

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

๐Ÿ”น Using finally Block
Always executes (whether error occurs or not).

try:
print(10 / 2)
except:
print("Error")
finally:
print("Execution completed")

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

๐Ÿ”น Raising Custom Exception
We can create our own error using raise.

Example:
age = 15
if age < 18:
raise ValueError("Age must be 18 or above")

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

๐Ÿ”น Creating Custom Exception Class

class MyError(Exception):
pass
raise MyError("Custom error occurred")

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

๐Ÿง  Why Exception Handling is Important?

โœ” Prevent program crash
โœ” Improve user experience
โœ” Handle unexpected situations
โœ” Make code professional

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

๐Ÿ“ Practice Tasks โ€“ Day 33

โœ” Handle ZeroDivisionError
โœ” Handle ValueError
โœ” Use finally block
โœ” Create custom exception

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

๐ŸŽฏ Day 33 Goal
โœ” Understand try-except
โœ” Handle multiple exceptions
โœ” Create custom errors

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

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

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

๐Ÿ“Œ What is File Handling?

File handling allows us to create, read, write, and update files.
โœ” Store data permanently
โœ” Read existing data
โœ” Modify data

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

๐Ÿ”น Opening a File

Syntax:
file = open("filename.txt", "mode")

Modes:
"r" โ†’ Read
"w" โ†’ Write (overwrites file)
"a" โ†’ Append
"x" โ†’ Create new file
"rb" โ†’ Read binary

Example:
file = open("demo.txt", "r")

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

๐Ÿ”น Reading a File

file = open("demo.txt", "r")
print(file.read())
file.close()
Other read methods:
file.readline()
file.readlines()

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

๐Ÿ”น Writing to a File

file = open("demo.txt", "w")
file.write("Hello Python")
file.close()

โš  "w" mode overwrites existing data.

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

๐Ÿ”น Appending to a File

file = open("demo.txt", "a")
file.write("\nNew Line Added")
file.close()

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

๐Ÿ”น Using with Statement (Best Practice)

Automatically closes file.
with open("demo.txt", "r") as file:
data = file.read()
print(data)
No need to call close() โœ…

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

๐Ÿ”น Checking if File Exists

import os
if os.path.exists("demo.txt"):
print("File exists")
else:
print("File not found")

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

๐Ÿง  Why File Handling is Important?

โœ” Store user data
โœ” Save reports
โœ” Manage logs
โœ” Work with databases & APIs

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

๐Ÿ“ Practice Tasks โ€“ Day 34

โœ” Create a file
โœ” Write your name into file
โœ” Append new line
โœ” Read entire file
โœ” Use with statement

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

๐ŸŽฏ Day 34 Goal
โœ” Understand file modes
โœ” Perform read & write operations
โœ” Use with statement

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

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

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

๐Ÿ“Œ What is a CSV File?

CSV = Comma Separated Values
Used to store tabular data like:
โœ” Excel data
โœ” Student records
โœ” Sales reports

Example CSV file:
name,age,city
Rahul,22,Pune
Amit,21,Mumbai

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

๐Ÿ”น Importing CSV Module

Python provides built-in module:
import csv

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

๐Ÿ”น Reading CSV File

import csv
with open("data.csv", "r") as file:
reader = csv.reader(file)
for row in reader:
print(row)
Each row is returned as a list.

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

๐Ÿ”น Writing to CSV File

import csv
with open("data.csv", "w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["Name", "Age", "City"])
writer.writerow(["Soham", 20, "Pune"])

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

๐Ÿ”น Appending Data to CSV

with open("data.csv", "a", newline="") as file:
writer = csv.writer(file)
writer.writerow(["Amit", 22, "Mumbai"])

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

๐Ÿ”น Using DictReader (Advanced Reading)

import csv
with open("data.csv", "r") as file:
reader = csv.DictReader(file)
for row in reader:
print(row["Name"], row["City"])
Reads CSV as dictionary ๐Ÿ”ฅ

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

๐Ÿ”น Using DictWriter

with open("data.csv", "w", newline="") as file:
fieldnames = ["Name", "Age"]
writer = csv.DictWriter(file, fieldnames=fieldnames)
writer.writeheader()
writer.writerow({"Name": "Rahul", "Age": 22})

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

๐Ÿง  Why CSV is Important?

โœ” Used in Data Science
โœ” Used in Excel integration
โœ” Used in reporting systems
โœ” Used in real-world projects

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

๐Ÿ“ Practice Tasks โ€“ Day 35

โœ” Create student.csv file
โœ” Add 5 student records
โœ” Read and print specific column
โœ” Use DictReader

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

๐ŸŽฏ Day 35 Goal
โœ” Understand CSV module
โœ” Perform read & write operations
โœ” Work with structured data

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

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

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

๐Ÿ“Œ What is JSON?

JSON = JavaScript Object Notation
โœ” Lightweight data format
โœ” Used in APIs
โœ” Used in Web & Mobile Apps
โœ” Human readable

Example JSON:
{ "name": "Soham", "age": 20, "city": "Pune" }

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ”น Import JSON Module

Python provides built-in module:
import json

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

๐Ÿ”น Convert Python โ†’ JSON (Serialization)

import json
data = { "name": "Rahul", "age": 22 }
json_data = json.dumps(data)
print(json_data)
dumps() โ†’ Convert dictionary to JSON string

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

๐Ÿ”น Convert JSON โ†’ Python (Deserialization)

import json
json_string = '{"name": "Amit", "age": 21}'
data = json.loads(json_string)
print(data["name"])
loads() โ†’ Convert JSON string to dictionary

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

๐Ÿ”น Writing JSON to File

import json
data = {"name": "Soham", "age": 20}
with open("data.json", "w") as file:
json.dump(data, file)
dump() โ†’ Write JSON to file

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

๐Ÿ”น Reading JSON from File

import json
with open("data.json", "r") as file:
data = json.load(file)
print(data)
load() โ†’ Read JSON from file

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

๐Ÿ”น Pretty Printing JSON

print(json.dumps(data, indent=4))
indent โ†’ Makes JSON readable

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

๐Ÿง  Why JSON is Important?

โœ” Used in REST APIs
โœ” Used in Web Development
โœ” Used in Data Exchange
โœ” Used in Backend Systems

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

๐Ÿ“ Practice Tasks โ€“ Day 36

โœ” Create dictionary
โœ” Convert to JSON
โœ” Save in file
โœ” Read from file
โœ” Pretty print output

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

๐ŸŽฏ Day 36 Goal
โœ” Understand serialization & deserialization
โœ” Work with JSON files
โœ” Prepare for API integration

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

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

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

๐Ÿ“Œ What is a Module?

A module is a Python file (.py) containing functions, variables, or classes.

โœ” Helps organize code
โœ” Enables code reuse
โœ” Improves readability

Example:
math.py โ†’ custom module

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

๐Ÿ”น Using Built-in Modules

Python provides many built-in modules:
โœ” math
โœ” random
โœ” datetime
โœ” os
โœ” sys

Example:
import math
print(math.sqrt(16))
print(math.pi)

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

๐Ÿ”น Importing Specific Function
from math import sqrt
print(sqrt(25))

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

๐Ÿ”น Import with Alias
import math as m
print(m.pi)

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

๐Ÿ”น Creating Your Own Module

Step 1: Create file mymodule.py
def greet(name):
print("Hello", name)

Step 2: Use it in another file
import mymodule
mymodule.greet("Soham")

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

๐Ÿ“ฆ What is a Package?

A package is a folder containing multiple modules.
It must contain a special file:
init.py

Example structure:

mypackage/
โ”‚โ”€โ”€ init.py
โ”‚โ”€โ”€ module1.py
โ”‚โ”€โ”€ module2.py

Import example:
from mypackage import module1

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

๐Ÿ”น Using name Variable

Every Python file has a special variable:
print(name)
If file is run directly โ†’ main
If imported โ†’ module name

Example:
if name == "main":
print("Run directly")

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

๐Ÿง  Why Modules & Packages?

โœ” Large project management
โœ” Code reusability
โœ” Professional coding practice
โœ” Used in real-world applications

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

๐Ÿ“ Practice Tasks โ€“ Day 37

โœ” Use math module
โœ” Create custom module
โœ” Import with alias
โœ” Create simple package

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

๐ŸŽฏ Day 37 Goal
โœ” Understand modular programming
โœ” Create and use custom modules
โœ” Understand package structure

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

๐Ÿ“… Next Topic โ€“ Day 38
๐Ÿ”ฅ Virtual Environment & pip
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 38 STUDY MATERIAL
โœจ Topic: Virtual Environment & pip

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

๐Ÿ“Œ What is pip?

pip is Pythonโ€™s package manager.

It is used to:
โœ” Install packages
โœ” Upgrade packages
โœ” Remove packages
โœ” Manage project dependencies
Check pip version:
pip --version

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ”น Installing a Package

Example:
pip install requests
Install specific version:
pip install requests==2.31.0

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ”น Upgrading a Package

pip install --upgrade requests

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ”น Uninstalling a Package

pip uninstall requests

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ“ฆ What is Virtual Environment?

A virtual environment creates an isolated Python environment for each project.

Why important?

โœ” Avoid version conflicts
โœ” Separate project dependencies
โœ” Professional development practice

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

๐Ÿ”น Creating Virtual Environment

Step 1:
python -m venv myenv

Step 2: Activate it
Windows:
myenv\Scripts\activate
Mac/Linux:
source myenv/bin/activate
After activation โ†’ (myenv) will appear in terminal โœ…

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

๐Ÿ”น Deactivating Virtual Environment
deactivate


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

๐Ÿ”น requirements.txt File
Used to store project dependencies.

Create file:
pip freeze > requirements.txt
Install from file:
pip install -r requirements.txt

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

๐Ÿง  Why This is Important?

โœ” Used in real-world projects
โœ” Required in Django/Flask
โœ” Required for deployment
โœ” Used in teamwork

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

๐Ÿ“ Practice Tasks โ€“ Day 38

โœ” Create virtual environment
โœ” Install any package
โœ” Freeze requirements
โœ” Deactivate environment

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

๐ŸŽฏ Day 38 Goal
โœ” Understand pip
โœ” Create virtual environment
โœ” Manage dependencies professionally

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

๐Ÿ“… Next Topic โ€“ Day 39
๐Ÿ”ฅ Introduction to Web Requests & APIs
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 39 STUDY MATERIAL
โœจ Topic: Introduction to Web Requests & APIs

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ“Œ What is an API?

API = Application Programming Interface
It allows applications to communicate with each other.

Example:
โœ” Weather App โ†’ Gets data from weather

API
โœ” Payment App โ†’ Connects to bank server
โœ” Instagram โ†’ Connects to backend server

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐ŸŒ What is HTTP Request?

When your program communicates with a server, it sends:
โœ” GET โ†’ Fetch data
โœ” POST โ†’ Send data
โœ” PUT โ†’ Update data
โœ” DELETE โ†’ Remove data

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

๐Ÿ“ฆ Using requests Library

First install:
pip install requests
Then import:
import requests

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

๐Ÿ”น Making a GET Request

import requests
response = requests.get("https://api.github.com๏ฟฝ")
print(response.status_code)
print(response.text)

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

๐Ÿ”น Getting JSON Response

import requests
response = requests.get("https://api.github.com๏ฟฝ")
data = response.json()
print(data)
.json() converts response into dictionary ๐Ÿ”ฅ

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

๐Ÿ”น Making a POST Request

import requests
data = {"name": "Soham"}
response = requests.post("https://httpbin.org/post๏ฟฝ", json=data)
print(response.json())

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

๐Ÿ”น Checking Response Status

200 โ†’ Success โœ…
404 โ†’ Not Found โŒ
500 โ†’ Server Error โš 

Example:
if response.status_code == 200:
print("Request successful")

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

๐Ÿง  Why APIs Are Important?

โœ” Used in Web Development
โœ” Used in Mobile Apps
โœ” Used in Automation
โœ” Used in Data Science

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

๐Ÿ“ Practice Tasks โ€“ Day 39

โœ” Install requests
โœ” Make GET request
โœ” Print JSON response
โœ” Check status code
โœ” Try POST request

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

๐ŸŽฏ Day 39 Goal
โœ” Understand API concept
โœ” Make HTTP requests
โœ” Work with JSON responses aa

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

๐Ÿ“… Next Topic โ€“ Day 40
๐Ÿ”ฅ Mini Project โ€“ Weather App using API
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 40 STUDY MATERIAL
โœจ Mini Project: Weather App using API

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ“Œ Project Goal

Create a simple Weather App that:
โœ” Takes city name as input
โœ” Fetches weather data from API
โœ” Displays temperature & condition

Real-world concept:
API Integration + JSON Handling + User Input

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

๐ŸŒ Step 1: Install Required Library

pip install requests

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

๐Ÿ”‘ Step 2: Get API Key

You can use free weather API like:
https://openweathermap.orgโ ๏ฟฝ
(Create free account โ†’ Generate API key)

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

๐Ÿง  Step 3: Basic Weather App Code

import requests
api_key = "YOUR_API_KEY"
city = input("Enter city name: ")
url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric"
response = requests.get(url)
data = response.json()
if response.status_code == 200:
temp = data["main"]["temp"]
desc = data["weather"][0]["description"]
print("City:", city)
print("Temperature:", temp, "ยฐC")
print("Condition:", desc)
else:
print("City not found โŒ")

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

๐Ÿ“Š How It Works?

โœ” User enters city
โœ” API sends request
โœ” Server returns JSON
โœ” Python extracts temperature & description

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

๐Ÿ” Error Handling Improvement

Add try-except:
try:
response = requests.get(url)
data = response.json()
except Exception as e:
print("Error:", e)

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

๐ŸŽจ Bonus Improvements

โœ” Add emoji based on weather โ˜€๐ŸŒงโ„
โœ” Use formatted output
โœ” Add loop for multiple searches
โœ” Add GUI using Tkinter

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

๐Ÿ“ Practice Tasks โ€“ Day 40

โœ” Create weather app
โœ” Handle invalid city
โœ” Add loop option
โœ” Improve output formatting

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

๐ŸŽฏ Day 40 Goal
โœ” Integrate API
โœ” Handle JSON
โœ” Build mini project

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

๐Ÿ“… Next Topic โ€“ Day 41
๐Ÿ”ฅ Introduction to Tkinter (GUI Programming)
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 41 STUDY MATERIAL
โœจ Topic: Introduction to Tkinter (GUI Programming)

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

๐Ÿ“Œ What is Tkinter?

Tkinter is Pythonโ€™s built-in GUI (Graphical User Interface) library.

It allows you to create:
โœ” Desktop Applications
โœ” Forms
โœ” Buttons & Labels
โœ” Mini Software Projects

No installation required โœ… (Built-in with Python)

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

๐Ÿ–ฅ๏ธ Creating First GUI Window

import tkinter as tk
root = tk.Tk()
root.title("My First App")
root.geometry("400x300")
root.mainloop()
This creates a simple window ๐Ÿ”ฅ

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

๐Ÿ”น Adding a Label

import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="Hello Python GUI")
label.pack()
root.mainloop()

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

๐Ÿ”น Adding a Button

import tkinter as tk
def click():
print("Button Clicked!")
root = tk.Tk()
btn = tk.Button(root, text="Click Me", command=click)
btn.pack()
root.mainloop()

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

๐Ÿ”น Adding Entry (Input Box)

import tkinter as tk
def show():
print(entry.get())
root = tk.Tk()
entry = tk.Entry(root)
entry.pack()
btn = tk.Button(root, text="Submit", command=show)
btn.pack()
root.mainloop()

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

๐Ÿ“ Layout Methods

โœ” pack() โ†’ Simple layout
โœ” grid() โ†’ Table layout
โœ” place() โ†’ Custom position

Example (grid):
label.grid(row=0, column=0)

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

๐Ÿง  Why Tkinter?

โœ” Build Desktop Apps
โœ” Create Login Forms
โœ” Build Calculator
โœ” Create Management Systems

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

๐Ÿ“ Practice Tasks โ€“ Day 41

โœ” Create window
โœ” Add label
โœ” Add button
โœ” Take user input
โœ” Try grid layout

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

๐ŸŽฏ Day 41 Goal
โœ” Create basic GUI
โœ” Add widgets
โœ” Understand event handling

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

๐Ÿ“… Next Topic โ€“ Day 42
๐Ÿ”ฅ Building Calculator using Tkinter
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 42 STUDY MATERIAL
โœจ Mini Project: Calculator using Tkinter
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ“Œ Project Goal

Create a simple calculator that:
โœ” Takes two numbers
โœ” Performs addition, subtraction, multiplication, division
โœ” Displays result on screen
Concepts Used:
โœ” Tkinter GUI
โœ” Functions
โœ” Event Handling

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

๐Ÿ–ฅ๏ธ Basic Calculator Code

import tkinter as tk
def calculate(operation):
num1 = float(entry1.get())
num2 = float(entry2.get())
if operation == "+":
result = num1 + num2
elif operation == "-":
result = num1 - num2
elif operation == "*":
result = num1 * num2
elif operation == "/":
result = num1 / num2

result_label.config(text="Result: " + str(result))
root = tk.Tk()
root.title("Calculator")
root.geometry("300x250")
tk.Label(root, text="Enter First Number").pack()
entry1 = tk.Entry(root)
entry1.pack()
tk.Label(root, text="Enter Second Number").pack()
entry2 = tk.Entry(root)
entry2.pack()
tk.Button(root, text="Add", command=lambda: calculate("+")).pack()
tk.Button(root, text="Subtract", command=lambda: calculate("-")).pack()
tk.Button(root, text="Multiply", command=lambda: calculate("*")).pack()
tk.Button(root, text="Divide", command=lambda: calculate("/")).pack()
result_label = tk.Label(root, text="Result: ")
result_label.pack()
root.mainloop()

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

โš  Improvement: Add Error Handling

Add try-except inside calculate():
try:
num1 = float(entry1.get())
num2 = float(entry2.get())
except ValueError:
result_label.config(text="Invalid Input โŒ")

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

๐ŸŽจ Bonus Improvements

โœ” Add clear button
โœ” Use grid layout
โœ” Add better UI design
โœ” Add keyboard support

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

๐Ÿ“ Practice Tasks โ€“ Day 42

โœ” Build calculator
โœ” Add error handling
โœ” Improve UI
โœ” Add clear button

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

๐ŸŽฏ Day 42 Goal
โœ” Build complete GUI project
โœ” Use functions with buttons
โœ” Handle user input errors

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

๐Ÿ“… Next Topic โ€“ Day 43
๐Ÿ”ฅ Introduction to SQLite Database in Python
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 43 STUDY MATERIAL
โœจ Topic: Introduction to SQLite Database in Python
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ“Œ What is SQLite?

SQLite is a lightweight database that is stored in a single file.

โœ” No server required
โœ” Built into Python
โœ” Perfect for small applications
Used in:
๐Ÿ“ฑ Mobile apps
๐Ÿ’ป Desktop apps
๐Ÿง  Prototyping databases

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ”น Import SQLite Module

SQLite comes built-in with Python.
import sqlite3

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

๐Ÿ”น Creating a Database

import sqlite3
conn = sqlite3.connect("student.db")
print("Database created successfully")
This creates a file student.db

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

๐Ÿ”น Creating a Table

import sqlite3
conn = sqlite3.connect("student.db")
cursor = conn.cursor()
cursor.execute(""" CREATE TABLE student( id INTEGER PRIMARY KEY, name TEXT, age INTEGER ) """)
conn.commit()
conn.close()

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

๐Ÿ”น Inserting Data

import sqlite3
conn = sqlite3.connect("student.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO student VALUES(1,'Soham',20)")
conn.commit()
conn.close()

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

๐Ÿ”น Reading Data

conn = sqlite3.connect("student.db")
cursor = conn.cursor()
cursor.execute("SELECT * FROM student")
rows = cursor.fetchall()
for row in rows:
print(row)

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

๐Ÿ”น Updating Data
cursor.execute( "UPDATE student SET age=21 WHERE id=1"

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

๐Ÿ”น Deleting Data
cursor.execute( "DELETE FROM student WHERE id=1" )

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

๐Ÿง  Why SQLite is Useful?

โœ” Build small database applications
โœ” Store app data locally
โœ” Practice SQL with Python

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

๐Ÿ“ Practice Tasks โ€“ Day 43

โœ” Create database file
โœ” Create student table
โœ” Insert 3 records
โœ” Display all records
โœ” Update a record

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

๐ŸŽฏ Day 43 Goal
โœ” Connect Python with database
โœ” Perform CRUD operations
โœ” Understand cursor & commit

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

๐Ÿ“… Next Topic โ€“ Day 44
๐Ÿ”ฅ Building Student Management System with SQLite
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 44 STUDY MATERIAL
โœจ Mini Project: Student Management System using SQLite

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

๐Ÿ“Œ Project Goal

Create a simple Student Management System that can:
โœ” Add student record
โœ” View student records
โœ” Update student details
โœ” Delete student record
Concepts Used:
โœ” SQLite Database
โœ” CRUD Operations
โœ” Python Functions

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

๐Ÿ—„ Step 1: Create Database & Table

import sqlite3
conn = sqlite3.connect("student.db")
cursor = conn.cursor()
cursor.execute(""" CREATE TABLE IF NOT EXISTS student( id INTEGER PRIMARY KEY, name TEXT, age INTEGER, course TEXT ) """)
conn.commit()

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

โž• Step 2: Insert Student Data

def add_student(id, name, age, course):
cursor.execute( "INSERT INTO student VALUES(?,?,?,?)", (id, name, age, course) )
conn.commit()
Example:
add_student(1,"Soham",20,"Python")

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

๐Ÿ“‹ Step 3: View Students

def view_students():
cursor.execute("SELECT * FROM student")
rows = cursor.fetchall()
for row in rows:
print(row)

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

โœ Step 4: Update Student

def update_student(id, age):
cursor.execute( "UPDATE student SET age=? WHERE id=?", (age,id) )
conn.commit()

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

โŒ Step 5: Delete Student

def delete_student(id):
cursor.execute( "DELETE FROM student WHERE id=?", (id,) )
conn.commit()

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

๐Ÿง  How the System Works?

1๏ธโƒฃ User adds student
2๏ธโƒฃ Data stored in database
3๏ธโƒฃ User can view/update/delete records
Real-world concept:
โœ” Database CRUD operations

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

๐ŸŽจ Bonus Improvements

โœ” Add menu system
โœ” Add input validation
โœ” Connect with Tkinter GUI
โœ” Export data to CSV

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

๐Ÿ“ Practice Tasks โ€“ Day 44

โœ” Create student database
โœ” Insert 5 students
โœ” Display all records
โœ” Update one record
โœ” Delete one record

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

๐ŸŽฏ Day 44 Goal
โœ” Build database project
โœ” Understand CRUD operations
โœ” Use SQLite with Python

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

๐Ÿ“… Next Topic โ€“ Day 45
๐Ÿ”ฅ Web Scraping using Python (BeautifulSoup)
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder
๐Ÿ PYTHON โ€“ DAY 45 STUDY MATERIAL
โœจ Topic: Web Scraping using Python (BeautifulSoup)

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

๐Ÿ“Œ What is Web Scraping?

Web scraping means extracting data from websites automatically using code.
Used for:
โœ” Data collection
โœ” Price tracking
โœ” News aggregation
โœ” Market research

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

๐Ÿ“ฆ Required Libraries

Install libraries:
pip install requests
pip install beautifulsoup4
Import in Python:
import requests
from bs4 import BeautifulSoup

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

๐ŸŒ Step 1: Get Website HTML

import requests
url = "https://example.comโ ๏ฟฝ"
response = requests.get(url)
html = response.text
print(html)
This fetches the HTML source of the webpage.

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

๐Ÿ”Ž Step 2: Parse HTML using BeautifulSoup

from bs4 import BeautifulSoup
soup = BeautifulSoup(html, "html.parser")
print(soup.title)
Extracts the title of the webpage.

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

๐Ÿ”น Extract Specific Data

Example: Get all headings
for heading in soup.find_all("h1"):
print(heading.text)

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

๐Ÿ”น Extract Links from Page

for link in soup.find_all("a"):
print(link.get("href"))

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

๐Ÿ”น Extract Paragraph Text

for p in soup.find_all("p"):
print(p.text)

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

โš  Important Note

Always check a websiteโ€™s robots.txt before scraping.
Some websites do not allow scraping.

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

๐Ÿง  Real-world Uses of Web Scraping

โœ” Job listing collectors
โœ” Product price trackers
โœ” News aggregators
โœ” Social media analysis

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

๐Ÿ“ Practice Tasks โ€“ Day 45

โœ” Fetch website HTML
โœ” Extract title
โœ” Extract all links
โœ” Extract paragraph text

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

๐ŸŽฏ Day 45 Goal
โœ” Understand web scraping concept
โœ” Use BeautifulSoup
โœ” Extract structured data

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

๐Ÿ“… Next Topic โ€“ Day 46
๐Ÿ”ฅ Automating Tasks with Python (Automation Scripts)
โœจ Stay Connected | Keep Coding
๐Ÿš€ TechByWebCoder