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 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
PYTHON – DAY 46 STUDY MATERIAL
✨ Topic: Automating Tasks with Python

━━━━━━━━━━━━━━━━━━━

πŸ“Œ What is Automation?

Automation means using code to perform repetitive tasks automatically.
Instead of doing work manually, Python can do it faster and automatically.

Examples:
βœ” Renaming multiple files
βœ” Sending emails automatically
βœ” Data backup scripts
βœ” Auto downloading files

━━━━━━━━━━━━━━━━━━━

πŸ“¦ Useful Python Modules for Automation

βœ” os β†’ File operations
βœ” shutil β†’ File moving/copying
βœ” schedule β†’ Task scheduling
βœ” smtplib β†’ Email automation
βœ” pyautogui β†’ Keyboard & mouse automation

━━━━━━━━━━━━━━━━━━━

πŸ“ Example 1: List Files in Folder

import os
files = os.listdir()
for file in files:
print(file)
Shows all files in the current directory.

━━━━━━━━━━━━━━━━━━━

✏ Example 2: Rename Multiple Files

import os
files = os.listdir()
for i, file in enumerate(files):
os.rename(file, f"file_{i}.txt")
This renames files automatically πŸ”₯

━━━━━━━━━━━━━━━━━━━

πŸ“‚ Example 3: Copy Files Automatically

import shutil
shutil.copy("source.txt", "backup.txt")
Used for file backup automation.

━━━━━━━━━━━━━━━━━━━

⏰ Example 4: Schedule Tasks

Install schedule library:
pip install schedule
Example:
import schedule
import time
def job():
print("Task executed")
schedule.every(5).seconds.do(job)
while True:
schedule.run_pending()
time.sleep(1)
Runs task every 5 seconds.

━━━━━━━━━━━━━━━━━━━

🧠 Real-world Automation Examples

βœ” Auto email sender
βœ” Auto report generator
βœ” File organizer
βœ” Social media automation

━━━━━━━━━━━━━━━━━━━

πŸ“ Practice Tasks – Day 46

βœ” List files in directory
βœ” Rename files automatically
βœ” Copy file backup
βœ” Schedule a task

━━━━━━━━━━━━━━━━━━━

🎯 Day 46 Goal
βœ” Understand automation concept
βœ” Use OS & file modules
βœ” Create simple automation scripts

━━━━━━━━━━━━━━━━━━━

πŸ“… Next Topic – Day 47
πŸ”₯ Sending Emails using Python
✨ Stay Connected | Keep Coding
πŸš€ TechByWebCoder
🐍 PYTHON – DAY 47 STUDY MATERIAL
✨ Topic: Sending Emails using Python

━━━━━━━━━━━━━━━━━━━

πŸ“Œ Why Send Emails with Python?

Python can automate email tasks like:
βœ” Sending notifications
βœ” Sending reports automatically
βœ” Sending OTP messages
βœ” Marketing email automation

━━━━━━━━━━━━━━━━━━━

πŸ“¦ Required Module

Python provides built-in module:
smtplib
Used to send emails using SMTP (Simple Mail Transfer Protocol).

━━━━━━━━━━━━━━━━━━━

πŸ“§ Basic Email Sending Example

import smtplib
sender = "your_email@gmail.com"
receiver = "receiver_email@gmail.com"
password = "your_app_password"
message = "Hello! This email was sent using Python."
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(sender, password)
server.sendmail(sender, receiver, message)
server.quit()
print("Email Sent Successfully βœ…")

━━━━━━━━━━━━━━━━━━━

πŸ” Important: Use App Password

For Gmail you must use App Password, not your main password.

Steps:
1️⃣ Go to Google Account
2️⃣ Security β†’ App Passwords
3️⃣ Generate password for Mail
4️⃣ Use that password in Python

━━━━━━━━━━━━━━━━━━━

πŸ“„ Sending Email with Subject

from email.mime.text import MIMEText
message = MIMEText("Hello from Python!")
message["Subject"] = "Python Email Test"
message["From"] = sender
message["To"] = receiver

━━━━━━━━━━━━━━━━━━━

πŸ“Ž Sending Email with Attachment (Concept)

Modules used:
βœ” email
βœ” smtplib
βœ” MIMEBase

This allows sending:
πŸ“„ PDFs
πŸ“· Images
πŸ“Š Reports

━━━━━━━━━━━━━━━━━━━

🧠 Real-world Uses

βœ” Daily report email automation
βœ” Alert systems
βœ” Customer notifications
βœ” Password reset emails

━━━━━━━━━━━━━━━━━━━

πŸ“ Practice Tasks – Day 47

βœ” Send simple email
βœ” Add subject line
βœ” Send email to yourself
βœ” Try adding attachment

━━━━━━━━━━━━━━━━━━━

🎯 Day 47 Goal
βœ” Understand SMTP
βœ” Send email using Python
βœ” Learn email automation basics

━━━━━━━━━━━━━━━━━━━

πŸ“… Next Topic – Day 48
πŸ”₯ Multithreading in Python
✨ Stay Connected | Keep Coding
πŸš€ TechByWebCoder
🐍 PYTHON – DAY 48 STUDY MATERIAL
✨ Topic: Multithreading in Python

━━━━━━━━━━━━━━━━━━━

πŸ“Œ What is Multithreading?

Multithreading allows a program to run multiple tasks at the same time.
Instead of executing tasks one by one, Python can run them concurrently.

Example:
βœ” Download multiple files simultaneously
βœ” Handle multiple users in a server
βœ” Perform background tasks

━━━━━━━━━━━━━━━━━━━

⚑ Thread vs Process

Thread β†’ Lightweight task inside a program
Process β†’ Independent running program
Multithreading helps improve performance for many tasks.

━━━━━━━━━━━━━━━━━━━

πŸ“¦ Threading Module

Python provides built-in module:
import threading

━━━━━━━━━━━━━━━━━━━

πŸ”Ή Creating a Thread

import threading
def task():
print("Thread is running")
t = threading.Thread(target=task)
t.start()
This starts a new thread.

━━━━━━━━━━━━━━━━━━━

πŸ”Ή Running Multiple Threads

import threading
def task():
print("Thread executed")
t1 = threading.Thread(target=task)
t2 = threading.Thread(target=task)
t1.start()
t2.start()
Both tasks run simultaneously πŸ”₯

━━━━━━━━━━━━━━━━━━━

πŸ”Ή Using join()

join() makes main program wait for thread to finish.

t1.start()
t1.join()
print("Thread finished")

━━━━━━━━━━━━━━━━━━━

πŸ”Ή Example with Delay

import threading
import time
def task():
print("Task started")
time.sleep(2)
print("Task completed")
t = threading.Thread(target=task)
t.start()
━━━━━━━━━━━━━━━━━━━

🧠 Where Multithreading is Used?

βœ” Web servers
βœ” Game development
βœ” File downloads
βœ” Background processing

━━━━━━━━━━━━━━━━━━━

πŸ“ Practice Tasks – Day 48

βœ” Create one thread
βœ” Run two threads
βœ” Use join()
βœ” Add delay using time.sleep()

━━━━━━━━━━━━━━━━━━━

🎯 Day 48 Goal
βœ” Understand threading concept
βœ” Create and run threads
βœ” Improve program efficiency

━━━━━━━━━━━━━━━━━━━

πŸ“… Next Topic – Day 49
πŸ”₯ Multiprocessing in Python
✨ Stay Connected | Keep Coding
πŸš€ TechByWebCoder
🐍 PYTHON – DAY 49 STUDY MATERIAL
✨ Topic: Multiprocessing in Python

━━━━━━━━━━━━━━━━━━━
πŸ“Œ What is Multiprocessing?

Multiprocessing means running multiple processes simultaneously using multiple CPU cores.

Unlike multithreading, each process runs independently.

Example:
βœ” Video processing
βœ” Large data analysis
βœ” Machine learning tasks
βœ” High-performance computing

━━━━━━━━━━━━━━━━━━━

⚑ Thread vs Process

Thread β†’ Runs inside same program memory
Process β†’ Runs in separate memory space
Multiprocessing uses multiple CPU cores, making programs faster.

━━━━━━━━━━━━━━━━━━━

πŸ“¦ Multiprocessing Module

Python provides built-in module:
import multiprocessing

━━━━━━━━━━━━━━━━━━━

πŸ”Ή Creating a Process

import multiprocessing
def task():
print("Process running")
p = multiprocessing.Process(target=task)
p.start()
This creates a new process.

━━━━━━━━━━━━━━━━━━━

πŸ”Ή Running Multiple Processes

import multiprocessing
def task():
print("Process executed")
p1 = multiprocessing.Process(target=task)
p2 = multiprocessing.Process(target=task)
p1.start()
p2.start()
Both processes run in parallel πŸ”₯

━━━━━━━━━━━━━━━━━━━

πŸ”Ή Using join()

join() waits for process completion.
p1.start()
p1.join()
print("Process finished")

━━━━━━━━━━━━━━━━━━━

πŸ”Ή Example with CPU Work

import multiprocessing
import time
def task():
for i in range(5):
print("Processing", i)
time.sleep(1)
p = multiprocessing.Process(target=task)
p.start()

━━━━━━━━━━━━━━━━━━━

🧠 Where Multiprocessing is Used?

βœ” Data science
βœ” Machine learning
βœ” Image processing
βœ” Scientific computing

━━━━━━━━━━━━━━━━━━━

πŸ“ Practice Tasks – Day 49

βœ” Create a process
βœ” Run two processes
βœ” Use join()
βœ” Add loop processing

━━━━━━━━━━━━━━━━━━━

🎯 Day 49 Goal
βœ” Understand multiprocessing concept
βœ” Run parallel processes
βœ” Use multiple CPU cores

━━━━━━━━━━━━━━━━━━━

πŸ“… Next Topic – Day 50
πŸ”₯ Logging in Python
✨ Stay Connected | Keep Coding
πŸš€ TechByWebCoder