Python Metaclasses

Mon 30 June 2025
class Meta1(type):
    def __new__(cls, name, bases, dct):
        dct['meta_id'] = 1
        return super().__new__(cls, name, bases, dct)

class ClassWithMeta1(metaclass=Meta1):
    def show_meta_id(self):
        return self.meta_id

obj1 = ClassWithMeta1()
obj1.show_meta_id()
class Meta2(type):
    def __new__(cls, name, bases, dct):
        dct['meta_id'] = 2
        return super().__new__(cls, name …

Category: basics

Read More

Python Operators

Mon 30 June 2025
a = 10
b = 3
print("Addition (+):", a + b)
print("Subtraction (-):", a - b)
print("Multiplication (*):", a * b)
print("Division (/):", a / b)
print("Floor Division (//):", a // b)
print("Modulus (%):", a % b)
print("Exponentiation (**):", a ** b)
x = 5
print("Initial x:", x)
x += 3
print("x += 3:", x)
x -= 2
print("x -= 2 …

Category: basics

Read More

Python Standard Modules

Mon 30 June 2025
# Example 0 using math module
import math
print('Square root of 0:', math.sqrt(0))
# Example 1 using random module
import random
print('Random number:', random.randint(0, 11))
# Example 2 using datetime module
from datetime import datetime, timedelta
print('Now + 2 days:', datetime.now() + timedelta(days=2))
# Example 3 …

Category: basics

Read More

Python Strings List Dict Set

Mon 30 June 2025
s = 'fpgfxda'
print(s.upper())
print(s[::-1])
print(len(s))
FPGFXDA
adxfgpf
7
s = 'ebhcmad'
print(s.upper())
print(s[::-1])
print(len(s))
EBHCMAD
damchbe
7
s = 'laolqyu'
print(s.upper())
print(s[::-1])
print(len(s))
LAOLQYU
uyqloal
7
s = 'faivrvazmc'
print(s.upper())
print(s[::-1 …

Category: basics

Read More

Regex Basics

Mon 30 June 2025
import re
text = "Contact us at sara123@gmail.com or call +91-9876543210"
email = re.findall(r"[a-zA-Z0-9._]+@[a-z]+\.[a-z]+", text)
print("Email:", email)
Email: ['sara123@gmail.com']
phone = re.findall(r"\+91-\d{10}", text)
print("Phone:", phone)
Phone: ['+91-9876543210']
Regex is used for pattern matching.
Useful in scraping …

Category: basics

Read More

Resume Ranker

Mon 30 June 2025
import streamlit as st
st.set_page_config(page_title="Resume Ranker", layout="wide")
st.title("📄 Resume Ranker")
2025-06-29 18:16:24.949 WARNING streamlit.runtime.scriptrunner_utils.script_run_context: Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.
2025-06-29 18:16:24.952 WARNING streamlit …

Category: pandas-work

Read More

Salesprediction

Mon 30 June 2025
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score
data = pd.read_csv(r'C:\Users\HP\Desktop\OIB-SIP\salesprediction\dataset\Advertising.csv')
print("First 5 rows …

Category: pandas-work

Read More

Sentiment Analysis

Mon 30 June 2025
import streamlit as st
from textblob import TextBlob
st.title("😊 Sentiment Analyzer")
2025-06-29 18:09:29.122 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.
2025-06-29 18:09:29.127 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored …

Category: pandas-work

Read More
Page 5 of 6

« Prev Next »