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 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
Tech Python pinned Deleted message
🐍 PYTHON – DAY 50 STUDY MATERIAL
✨ Topic: Logging in Python

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

Logging is used to record events that happen while a program runs.
Instead of using print() everywhere, developers use logging to track:

βœ” Errors
βœ” Warnings
βœ” Debug information
βœ” Application activity

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

πŸ“¦ Logging Module

Python provides a built-in module:
import logging

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

πŸ”Ή Basic Logging Example

import logging
logging.basicConfig(level=logging.DEBUG)
logging.debug("Debug message")
logging.info("Information message")
logging.warning("Warning message")
logging.error("Error occurred")
logging.critical("Critical issue")

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

πŸ“Š Logging Levels

DEBUG β†’ Detailed information
INFO β†’ General program events
WARNING β†’ Something unexpected
ERROR β†’ Program error
CRITICAL β†’ Serious failure

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

πŸ“ Logging to a File

import logging
logging.basicConfig( filename="app.log", level=logging.INFO )
logging.info("Application started")
This creates a log file automatically.

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

⏰ Logging with Time Format

import logging
logging.basicConfig( filename="app.log", level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" )
logging.info("Program started")

Example output:
2026-03-16 21:45:22 - INFO - Program started

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

🧠 Why Logging is Important?

βœ” Debugging large programs
βœ” Monitoring applications
βœ” Tracking errors in production
βœ” Maintaining software systems

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

πŸ“ Practice Tasks – Day 50

βœ” Use logging instead of print
βœ” Create log file
βœ” Log errors and warnings
βœ” Add time format

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

🎯 Day 50 Goal
βœ” Understand logging system
βœ” Track application events
βœ” Improve debugging skills

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

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

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

πŸ“Œ What are Command Line Arguments?

Command line arguments allow you to pass inputs to a Python program when running it from the terminal.

Example:
python script.py Soham
Here Soham is a command line argument.

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

πŸ“¦ Using sys Module

Python provides a built-in module:
import sys

This module allows access to command line arguments.

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

πŸ”Ή Basic Example

import sys
print(sys.argv)
Output example:
['script.py', 'Soham']

Explanation:
sys.argv[0] β†’ script name
sys.argv[1] β†’ first argument

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

πŸ”Ή Using Argument in Program

import sys
name = sys.argv[1]
print("Hello", name)

Run command:
python script.py Soham

Output:
Hello Soham

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

πŸ”Ή Multiple Arguments

import sys
a = int(sys.argv[1])
b = int(sys.argv[2])
print("Sum:", a + b)

Run:
python script.py 10 20

Output:
Sum: 30

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

⚠ Handling Missing Arguments

import sys
if len(sys.argv) < 2:
print("Please provide an argument")
else:
print("Argument:", sys.argv[1])

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

🧠 Where Command Line Arguments Are Used?

βœ” Automation scripts
βœ” DevOps tools
βœ” System utilities
βœ” Data processing scripts

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

πŸ“ Practice Tasks – Day 51

βœ” Print command line arguments
βœ” Create greeting script
βœ” Add two numbers using arguments
βœ” Handle missing arguments

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

🎯 Day 51 Goal
βœ” Understand command line inputs
βœ” Use sys.argv
βœ” Build simple CLI tools

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

πŸ“… Next Topic – Day 52
πŸ”₯ Introduction to argparse (Professional CLI Tools)
✨ Stay Connected | Keep Coding
πŸš€ TechByWebCoder
🐍 PYTHON – DAY 52 STUDY MATERIAL
✨ Topic: argparse – Building Professional CLI Tools
━━━━━━━━━━━━━━━━━━━

πŸ“Œ What is argparse?

argparse is Python’s standard library for building command-line interfaces (CLI).
It helps you:
βœ” Parse command-line arguments
βœ” Show help messages automatically
βœ” Validate user input
βœ” Build professional CLI tools

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

πŸ“¦ Importing argparse
import argparse

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

πŸ”Ή Basic Example

import argparse
parser = argparse.ArgumentParser()
parser.add_argument("name")
args = parser.parse_args()
print("Hello", args.name)
Run command:
python script.py Soham

Output:
Hello Soham

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

πŸ”Ή Adding Optional Arguments

import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--age", type=int)
args = parser.parse_args()
print("Age:", args.age)
Run command:
python script.py --age 20

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

πŸ”Ή Adding Help Description

parser = argparse.ArgumentParser( description="Simple CLI Program" )
Running this command shows help:
python script.py --help
It displays all arguments automatically πŸ“–

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

πŸ”Ή Multiple Arguments Example

import argparse
parser = argparse.ArgumentParser()
parser.add_argument("num1", type=int)
parser.add_argument("num2", type=int)
args = parser.parse_args()
print("Sum:", args.num1 + args.num2)
Run command:
python script.py 10 5
Output:
Sum: 15

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

🧠 Where argparse is Used?

βœ” DevOps scripts
βœ” Data processing tools
βœ” Automation utilities
βœ” Command-line applications

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

πŸ“ Practice Tasks – Day 52

βœ” Create CLI greeting tool
βœ” Add optional argument
βœ” Create CLI calculator
βœ” Use help command

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

🎯 Day 52 Goal
βœ” Understand argparse module
βœ” Build professional CLI programs
βœ” Improve command-line scripting skills

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

πŸ“… Next Topic – Day 53
πŸ”₯ Environment Variables in Python
✨ Stay Connected | Keep Coding
πŸš€ TechByWebCoder
πŸš€ Top 2 Full Stack Python Django Project with MySQL Database

We offer a complete collection of 2 modern Full Stack Python Django web applications developed using Django, HTML, CSS, JavaScript, and MySQL/SQLite database connectivity. These projects are perfect for computer science students, final-year projects, freelancers, and portfolio building.

πŸ–₯️ Code: https://rzp.io/rzp/pydjango-1

πŸ–ΌοΈ Output Preview: https://youtu.be/234fQQRKy7E


🌐 Included Projects

1. AI Resume Analyzer & Job Matcher
2. Smart Study Planner with AI


πŸ“¦ What You Will Get (For Each Project):


β€’ Full Python Source Code (Python Djnago+ MySQL)
β€’ MySQL Database File (.sql)
β€’ Output Screenshots / UI Preview
β€’ Project Documentation (Detailed Report)
β€’ PowerPoint Presentation (PPT)
β€’ User Manual (Step-by-Step Guide)
β€’ README File (Installation + Setup Instructions)
β€’ Well-Structured and Easy-to-Understand Code


Follow For More !
🐍 PYTHON – DAY 53 STUDY MATERIAL
✨ Topic: Environment Variables in Python

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

πŸ“Œ What are Environment Variables?

Environment variables are external values stored in the operating system that programs can access.

They are used to store:
βœ” API keys
βœ” Database credentials
βœ” Configuration settings
βœ” Secret tokens
This helps keep sensitive data secure.

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

πŸ“¦ Using os Module

Python provides the os module to access environment variables.
import os

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

πŸ”Ή Reading an Environment Variable

import os
api_key = os.getenv("API_KEY")
print(api_key)
If the variable exists β†’ value is returned
If not β†’ returns None

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

πŸ”Ή Setting Environment Variable (Temporarily)

Windows:
set API_KEY=12345

Mac/Linux:
export API_KEY=12345
Then run Python program.

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

πŸ”Ή Providing Default Value

import os
api_key = os.getenv("API_KEY", "DefaultKey")
print(api_key)
If variable is missing β†’ DefaultKey will be used.

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

πŸ“ Using .env Files (Best Practice)

Install library:
pip install python-dotenv

Example:
API_KEY=12345
DB_PASSWORD=secret

Python code:
from dotenv import load_dotenv
import os
load_dotenv()
print(os.getenv("API_KEY"))

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

🧠 Why Environment Variables are Important?

βœ” Secure application configuration
βœ” Protect sensitive data
βœ” Used in deployment & cloud platforms

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

πŸ“ Practice Tasks – Day 53

βœ” Create environment variable
βœ” Read variable in Python
βœ” Use default value
βœ” Create .env file

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

🎯 Day 53 Goal
βœ” Understand environment variables
βœ” Protect sensitive information
βœ” Manage application configuration

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

πŸ“… Next Topic – Day 54
πŸ”₯ Introduction to REST API Development using Flask
✨ Stay Connected | Keep Coding
πŸš€ TechByWebCoder
Tech Python pinned Deleted message
Tech Python pinned Deleted message
πŸš€ Top 2 Full Stack Python Django Project with MySQL Database

We offer a complete collection of 2 modern Full Stack Python Django web applications developed using Django, HTML, CSS, JavaScript, and MySQL/SQLite database connectivity. These projects are perfect for computer science students, final-year projects, freelancers, and portfolio building.

πŸ–₯️ Code: https://rzp.io/rzp/pydjango-2

πŸ–ΌοΈ Output Preview: https://youtu.be/3OvYLoQS2jM


🌐 Included Projects
1. Fake News Detection Platform
2. Online Code Judge System


πŸ“¦ What You Will Get (For Each Project):
β€’ Full Python Source Code (Python Djnago+ MySQL)
β€’ MySQL Database File (.sql)
β€’ Output Screenshots / UI Preview
β€’ Project Documentation (Detailed Report)
β€’ PowerPoint Presentation (PPT)
β€’ User Manual (Step-by-Step Guide)
β€’ README File (Installation + Setup Instructions)
β€’ Well-Structured and Easy-to-Understand Code


Follow For More !
Tech Python pinned a photo
🐍 PYTHON – DAY 54 STUDY MATERIAL
✨ Topic: Introduction to REST API Development using Flask

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

Flask is a lightweight Python web framework used to build:
βœ” Web applications
βœ” REST APIs
βœ” Backend services

It is simple, flexible, and widely used in Python backend development.

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

πŸ“¦ Install Flask

pip install flask
Import in Python:
from flask import Flask

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

πŸ–₯ Creating First Flask App

from flask import Flask
app = Flask(name)
@app.route("/")
def home():
return "Hello, Flask API!"
app.run(debug=True)

Run the program and open browser:
http://127.0.0.1:5000

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

🌐 Creating API Endpoint

from flask import Flask, jsonify
app = Flask(name)
@app.route("/api")
def api():
data = {"message": "Hello API"}
return jsonify(data)
app.run(debug=True)

Output:
{ "message": "Hello API" }

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

πŸ”Ή Handling URL Parameters

@app.route("/user/")
def user(name):
return "Hello " + name
Example:
http://127.0.0.1:5000/user/Soham

Output:
Hello Soham

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

πŸ”Ή Handling JSON Request (POST)

from flask import request
@app.route("/data", methods=["POST"])
def receive():
data = request.json
return {"received": data}

━━━━━━━━━━━━━━━━━━━
🧠 Where Flask APIs Are Used?

βœ” Mobile app backends
βœ” Web application backends
βœ” AI model APIs
βœ” Microservices architecture

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

πŸ“ Practice Tasks – Day 54

βœ” Install Flask
βœ” Create simple API
βœ” Return JSON response
βœ” Use URL parameter

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

🎯 Day 54 Goal
βœ” Understand Flask framework
βœ” Create simple REST API
βœ” Handle requests and responses

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

πŸ“… Next Topic – Day 55
πŸ”₯ Connecting Flask with Database (SQLite)
✨ Stay Connected | Keep Coding
πŸš€ TechByWebCoder