Data Visualization Master

Mon 30 June 2025
# Imports
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
%matplotlib inline
# Sample Data
x = [1, 2, 3, 4, 5]
y = [10, 15, 13, 17, 20]
# DataFrame for seaborn
df = pd.DataFrame({
    'Day': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
    'Sales': [200, 300, 250 …

Category: pandas-work

Read More

Dictionary Operations

Mon 30 June 2025
student = {
    "name": "Sara",
    "age": 20,
    "score": 95
}
print(student)
{'name': 'Sara', 'age': 20, 'score': 95}
student["grade"] = "A"
for k, v in student.items():
    print(f"{k}: {v}")
name: Sara
age: 20
score: 95
grade: A


Score: 0

Category: basics

Read More

Dsa

Mon 30 June 2025
# Stack using List
stack = []
# Pushing elements
stack.append(10)
stack.append(20)
stack.append(30)
print("Stack after pushes:", stack)
Stack after pushes: [10, 20, 30]
# Popping elements
stack.pop()
print("Stack after pop:", stack)
Stack after pop: [10, 20]
# Peek
if stack:
    print("Top element:", stack[-1])
Top element …

Category: basics

Read More

Dsa 7000 Cells

Mon 30 June 2025
# Array Example 0
arr = list(range(3))
print('Array 0:', arr)
# Linked List Node 1
class Node1:
    def __init__(self, data):
        self.data = data
        self.next = None
n1 = Node1(1)
print('Node data:', n1.data)
# Stack Example 2
stack = []
for j in range(3):
    stack.append(j)
print('Stack 2 …

Category: basics

Read More

Email Spam Detection

Mon 30 June 2025
import pandas as pd  
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
import streamlit as st  
data = pd.read_csv('C:/Users/HP/Desktop/OIB-SIP/emailspam/dataset-mail/spam.csv', encoding='latin-1')
print("Original Shape:", data.shape)
Original Shape: (5572, 5)
print(data.head …

Category: pandas-work

Read More

Exploratory Data Analysis

Mon 30 June 2025
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'values': [i*2 for i in range(10)]})
df.plot(kind='line')
plt.title('Line Plot 1')
plt.show()

png

import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'values': [i*3 for i in range …

Category: pandas-work

Read More

Fake News Detector

Mon 30 June 2025
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
import streamlit as st
data = {
    "text": [
        "NASA confirms water on Mars",
        "You won't believe what this actor did!",
        "Government passes new education bill",
        "Scientists …

Category: pandas-work

Read More

Filehandling

Mon 30 June 2025
# Writing a file
file = open("sara.txt", "w")
file.write("Sara\n")
file.close()
# Reading the file
file = open("sara.txt", "r")
print(file.read())
file.close()
Sara
# Writing multiple lines
lines = ["Line 1\n", "Line 2\n", "Line 3\n"]
file = open("lines.txt", "w")
file.writelines(lines)
file …

Category: basics

Read More

Functions

Mon 30 June 2025
def greet():
    print("Hello, Sara!")

greet()
Hello, Sara!
def add(a, b):
    return a + b
add(5, 3)
8
def say_hello():
    print("Hello!")
def greet_name(name):
    print(f"Hi {name}!")
def square(x):
    return x * x
def welcome(name="Sara"):
    print(f"Welcome, {name}!")
def intro(name, age):
    print(f …

Category: basics

Read More

Hashtables

Mon 30 June 2025
d = {}
d['a'] = 1
d['b'] = 2
print(d)
{'a': 1, 'b': 2}
print(d['a'])
1
d['c'] = 3
d['a'] = 100
print(d)
{'a': 100, 'b': 2, 'c': 3}
del d['b']
print(d)
{'a': 100, 'c': 3}
len(d)
2
d.get('a')
100
d.get('z …

Category: basics

Read More
Page 2 of 6

« Prev Next »