0% found this document useful (0 votes)
4 views14 pages

Python Exam Notes

This document serves as a comprehensive study guide for Python exam preparation, covering essential libraries such as NumPy, Pandas, Matplotlib, and Seaborn, along with Object-Oriented Programming concepts. It includes practical examples, key functions, and data validation techniques for effective data analysis and visualization. The guide also outlines the syllabus and provides scenario-based applications to reinforce learning.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views14 pages

Python Exam Notes

This document serves as a comprehensive study guide for Python exam preparation, covering essential libraries such as NumPy, Pandas, Matplotlib, and Seaborn, along with Object-Oriented Programming concepts. It includes practical examples, key functions, and data validation techniques for effective data analysis and visualization. The guide also outlines the syllabus and provides scenario-based applications to reinforce learning.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

■ Python Exam Preparation Notes

Complete Study Guide | Based on College Practicals

■ NumPy ■ Pandas ■ Matplotlib

■ OOP & Classes ■ Data Analysis ■ Visualization

■ Data Validation ■ Functions ■ Calculations

■ Syllabus: Python Basics • Libraries (NumPy, Pandas, Matplotlib, Seaborn) • Functions • OOP •
Calculations • Data Validation • Plotting & Visualization
SECTION 1: NumPy — Numerical Python Library
NumPy is the foundational library for numerical computing in Python. It provides high-performance
multi-dimensional arrays and mathematical functions.

1.1 Importing NumPy


import numpy as np

1.2 Creating Arrays


• 1D Array: arr = [Link]([12, 45, 7, 89, 34])
• 2D Array (Matrix): a = [Link]([[1,2],[3,4]])
• Zeros: [Link]((3,3)) — all elements 0
• Ones: [Link]((2,4)) — all elements 1
• Range: [Link](0, 10, 2) → [0,2,4,6,8]
• Random: [Link](mean, std, size)

1.3 Array Statistics (from your practical)


arr = [Link]([12, 45, 7, 89, 34]) print('Max:', [Link]()) # 89 print('Min:', [Link]())
# 7 print('Sum:', [Link]()) # 187 print('Average:', [Link]()) # 37.4

1.4 Matrix Operations (from your practical)


a = [Link]([[1,2],[3,4]]) b = [Link]([[5,6],[7,8]]) print('Addition:\n', a+b) #
Element-wise: [[6,8],[10,12]] print('Multiplication:\n', [Link](a,b)) # Matrix multiply:
[[19,22],[43,50]]

1.5 Key NumPy Functions — Quick Reference


Function Description Example

[Link]() Maximum value 89

[Link]() Minimum value 7

[Link]() Sum of all elements 187

[Link]() Average/mean 37.4

[Link](a,b) Matrix multiplication [[19,22],[43,50]]

[Link]([]) Create array [Link]([1,2,3])

[Link](m,s,n) Random normal dist [Link](170,0,250)

[Link] Dimensions of array (2,2)

[Link] Data type int64

■■ Key Note: [Link](a,b) = Matrix multiplication (NOT element-wise). Element-wise multiply uses a*b.
SECTION 2: Pandas — Data Analysis Library
Pandas provides two main data structures: Series (1D) and DataFrame (2D table). It is the go-to library for loading,
cleaning, and analyzing structured data.

2.1 Importing & Creating Data


import pandas as pd import numpy as np # Series data = [10, 20, 30, 40] s = [Link](data)
print(s) # 0→10, 1→20, 2→30, 3→40 # DataFrame from dictionary data =
{'Name':['Aman','Rohit','Neha'], 'Age':[24,26,23], 'City':['Delhi','Mumbai','Pune']} df =
[Link](data) print(df)

2.2 Reading CSV Files (from your HR Analytics practical)


df = pd.read_csv('/content/HR_Analytics.csv') [Link](10) # First 10 rows [Link](5) #
Last 5 rows

2.3 Data Exploration — The Big 6 Commands


Command What it does Output from your practical

[Link]() Column names, types, non-null count 38 columns, 1480 entries

[Link]() Statistical summary (mean, std, min, max) Numeric stats

[Link]().sum() Count missing values per column YearsWithCurrManager: 57 nulls

[Link] Rows × Columns (1480, 38)

df['Col'].unique() All unique values in a column Dept: R&D, Sales, HR

df['Col'].nunique() Count of unique values 3 departments

2.4 Selecting Data


# Single column print(df['Name']) # Multiple columns print(df[['Name', 'Age']]) # First
row by index print([Link][0]) # Filter rows df[df['Age'] > 30] # Sort
df['AgeGroup'].sort_values()

2.5 HR Analytics Dataset — Key Findings from Your Practical


• Dataset: 1480 employees, 38 columns
• Missing data: Only YearsWithCurrManager had 57 null values
• Departments: Research & Development, Sales, Human Resources
• Age Groups: 18-25, 26-35, 36-45, 46-55, 55+
• Correlation heatmap used: [Link]([Link](numeric_only=True))

■■ Data Validation: Always run [Link]().sum() to check missing values before analysis!
SECTION 3: Matplotlib — Data Visualization Library
Matplotlib is Python's primary plotting library. It creates line plots, bar charts, scatter plots, histograms, pie charts,
and more.

3.1 Basic Import & Plot Structure


import [Link] as plt import numpy as np # Always follow: create data → plot →
labels → show [Link](x, y) # Line plot [Link]('X-axis') # X label
[Link]('Y-axis') # Y label [Link]('My Plot') # Title [Link]() # Display

3.2 All Plot Types — From Your Practicals


Plot Type Function Code Example When to Use

Line Plot [Link]() [Link](x, y) Trends over time

Scatter Plot [Link]() [Link](x,y,color='blue',marker='x') Relationships

Bar Plot (V) [Link]() [Link](x, y, color='pink') Category comparison

Bar Plot (H) [Link]() [Link](x, y, color='orange') Horizontal bars

Histogram [Link]() [Link](marks, bins=5, color='skyblue') Distribution

Pie Chart [Link]() [Link](values, labels=labels, autopct='%1.1f%%')


Proportions

Stack Plot [Link]() [Link](x,y1,y2,y3) Cumulative parts

3.3 Pie Chart with Explode — From Plot G Practical


data = {'Rent':40,'Food':25,'Transport':10,'Entertainment':15,'Savings':10} labels =
list([Link]()) values = list([Link]()) # Explode the highest value max_value =
max(values) explode = [0.1 if v == max_value else 0 for v in values] [Link](values,
labels=labels, autopct='%1.1f%%', explode=explode, startangle=140, shadow=True,
colors=['#ff9999','#66b3ff','#99ff99','#ffcc99','#c2c2f0']) [Link]('Monthly Expenses
Breakdown') [Link]('equal') # Keeps pie circular [Link]()

3.4 Histogram — Distribution Analysis


marks = [45,55,60,62,65,70,72,75,78,80,82,85,88,90,92] [Link](marks, bins=5,
color='skyblue', edgecolor='black') [Link]('Distribution of Student Marks')
[Link]('Marks Scored') [Link]('Number of Students') [Link](axis='y',
linestyle='--', alpha=0.7) [Link]()

3.5 Stack Plot — Multiple Series


days=[1,2,3,4,5] sleeping=[7,8,6,11,7] eating=[2,3,4,2,3] working=[7,8,7,2,7]
playing=[8,5,8,7,13] [Link](days, sleeping, eating, working, playing,
colors=['m','c','r','k']) [Link]('X') [Link]('Y') [Link]('Stack Plot')
[Link]() [Link]()

3.6 Grouped Bar Chart — BMW vs Audi Comparison


[Link]([0.25,1.25,2.25,3.25,4.25],[50,40,70,80,20], label='BMW', color='0.5')
[Link]([0.75,1.75,2.75,3.75,4.75],[80,20,20,50,60], label='Audi', color='r', width=.5)
[Link]() [Link]('Days') [Link]('Distance(kms)') [Link]('Information')
[Link]()

3.7 Subplots & Multiple Plots


[Link](figsize=(12, 5)) [Link](1, 2, 1) # 1 row, 2 cols, plot 1
[Link](df['Age'], kde=True, bins=20) [Link]('Age Distribution') [Link]()

■■ Common Error: 'olivegreen' is NOT a valid matplotlib color. Use 'olive', 'green', or HEX codes like
'#556B2F'.
SECTION 4: Seaborn — Statistical Visualization
Seaborn is built on Matplotlib and provides beautiful statistical visualizations with less code. Used with Pandas
DataFrames.

4.1 Key Seaborn Functions Used in Your Practicals


import seaborn as sns import [Link] as plt # Heatmap (Correlation Matrix) corr =
[Link](numeric_only=True) [Link](corr, cmap='RdBu', annot=True)
[Link]('Correlation') [Link]() # Histogram with KDE curve [Link](df['Age'],
kde=True, bins=20) [Link]('Age Distribution') [Link]()

4.2 Seaborn Quick Reference


• [Link]() — Correlation heatmap with colour coding
• [Link](kde=True) — Histogram with smooth density curve
• [Link]() — Box-whisker plot for outliers
• [Link]() — Count of categorical values
• cmap='RdBu' — Red-Blue diverging colour map (negative=red, positive=blue)
• annot=True — Show values inside each heatmap cell

Key Correlation Findings from HR Data: MonthlyIncome vs JobLevel = 0.95 (very strong). YearsAtCompany vs
YearsWithCurrManager = 0.76 (strong).
SECTION 5: Object-Oriented Programming (OOP)
OOP organises code into Classes (blueprints) and Objects (instances). It promotes reusability, modularity, and
clean code structure.

5.1 Class vs Object


• Class = Blueprint/Template (e.g., the idea of a 'Car')
• Object = Instance of a class (e.g., a specific BMW)
• Attribute = Data stored in a class/object
• Method = Function defined inside a class

5.2 Basic Class — Class Variables


class Student: name = 'Aman' # Class variable (shared by all instances) age = 22 s1 =
Student() print([Link]) # Aman print([Link]) # 22

5.3 Instance Variables (set on the object)


class Employee: company = 'TCS' # Class variable e1 = Employee() [Link] = 'Amit' #
Instance variable [Link] = 40000 e2 = Employee() [Link] = 'Neha' [Link] = 50000
print([Link], [Link], [Link]) # Amit 40000 TCS print([Link], [Link],
[Link]) # Neha 50000 TCS

5.4 Methods — Functions Inside a Class


class Add: def add_numbers(self, a, b, c): # 'self' = refers to the object return a + b + c
a1 = Add() print('Addition:', a1.add_numbers(77636635, 109877997, 766)) # 187515398 class
Square: def find_numbers(self, n): return n * n obj = Square() print('Square:',
obj.find_numbers(87)) # 7569

5.5 More Class Examples from Your Practical


# Even/Odd Checker class Numbers: def evenodd(self, n): if n % 2 == 0: return 'Even' else:
return 'Odd' n1 = Numbers() print([Link](9)) # Odd print([Link](68)) # Even #
Simple Interest class Interest: def calc(self, p, r, t): return (p * r * t) / 100 si =
Interest() print('SI:', [Link](7, 8, 6)) # 3.36 # Find Largest class Largest: def
find_largest(self, a, b): return a if a > b else b n1 = Largest() print(n1.find_largest(92,
67)) # 92

5.6 __init__ Constructor & Dunder Methods


class ComplexRange: def __init__(self, start, stop, step=complex(1,1)): [Link] = start
[Link] = stop [Link] = step # __init__ runs automatically when object is created def
__iter__(self): # Makes object iterable [Link] = [Link] [Link] = 0 return
self def __next__(self): # Controls what 'next' returns if [Link] > self.max_steps:
raise StopIteration result = [Link] [Link] += [Link] [Link] += 1 return
result

5.7 OOP Summary Table


Concept Keyword/Syntax Purpose

Class Definition class ClassName: Create blueprint

Object Creation obj = ClassName() Create instance

Class Variable Inside class, outside method Shared by all objects

Instance Variable [Link] = value Unique to each object

Method def method(self, ...): Function in a class


Self First param of every method Refers to current object

Constructor def __init__(self, ...): Auto-called at object creation

Iterator __iter__ + __next__ Make object loop-able


SECTION 6: Functions, Formations & Calculations
6.1 Function Definition vs Method
# Regular Function def add(a, b): return a + b print(add(5, 3)) # 8 # Method (function
inside a class — needs self) class Multiply: def mul_numbers(self, a, b, c): return a * b *
c a1 = Multiply() print(a1.mul_numbers(7, 8, 6)) # 336

6.2 Key Mathematical Formations


# Simple Interest SI = (P * R * T) / 100 # Matrix Addition [a+b for each element] # Matrix
Multiplication (dot product) C[i][j] = sum(A[i][k] * B[k][j]) # Percentage percent = (value
/ total) * 100 # Even/Odd if n % 2 == 0: Even else: Odd

6.3 Data Validation Techniques


• Check null values: [Link]().sum()
• Check data types: [Link] or [Link]()
• Check unique values: df['col'].unique()
• Check shape: [Link] → (rows, cols)
• Statistical summary: [Link]()
• Filter invalid: df[df['Age'] > 0]

6.4 Pandas Series vs DataFrame


# SERIES — 1D data (like a single column) data = [10, 20, 30, 40] s = [Link](data) #
Output: index → value # 0→10, 1→20, 2→30, 3→40 # DATAFRAME — 2D table data =
{'Name':['Aman','Rohit'], 'Age':[24,26]} df = [Link](data) # Looks like an Excel
table

6.5 Matplotlib Plot Customization Options


Parameter Options/Values Example

color Named colors, hex codes 'red', '#ff9999', '0.5'(grey)

marker Plot point shapes 'x', 'o', 's'(square), '^'(triangle)

linestyle Line pattern '--', '-', ':', '-.'

figsize Width × Height in inches [Link](figsize=(8,6))

bins Histogram bucket count bins=5, bins=20

alpha Transparency 0-1 alpha=0.7

edgecolor Bar/histogram border edgecolor='black'

autopct Pie chart % format autopct='%1.1f%%'

explode Pull out a pie slice [0.1, 0, 0, 0]


SECTION 7: 5 Scenario-Based Case Studies
These case studies are directly based on the code from your college practicals. Each presents a real-world
scenario, questions, and complete answers.

■ CASE STUDY 1: HR Analytics — Employee Attrition Investigation


Scenario: A large company with 1,480 employees wants to analyse their HR dataset to understand employee
attrition. As a data analyst, you are handed the file HR_Analytics.csv and asked to validate the data and
perform exploration.

Q1. How would you load and initially inspect the HR dataset?
import pandas as pd import numpy as np df = pd.read_csv('/content/HR_Analytics.csv')
print([Link](10)) # View first 10 rows print([Link]) # (1480, 38) print([Link]()) #
Column types and null counts print([Link]()) # Statistical summary

→ Answer: The dataset has 1,480 rows and 38 columns. We use head(), shape, info(), describe() to understand
structure before any analysis.

Q2. How do you check for missing/null values and what did you find?
print([Link]().sum()) # Result: All columns have 0 nulls EXCEPT: # YearsWithCurrManager
→ 57 null values # All other 37 columns → 0 nulls

→ Answer: Only YearsWithCurrManager had 57 missing values (out of 1,480 entries). This means 3.85% data is
missing for that column. Best practice: fill with mean
df['YearsWithCurrManager'].fillna(df['YearsWithCurrManager'].mean(), inplace=True)

Q3. How do you explore the Department and AgeGroup columns?


# Department print(df['Department'].unique()) # ['Research & Development', 'Sales', 'Human
Resources'] print(df['Department'].nunique()) # 3 # AgeGroup
print(df['AgeGroup'].unique()) # ['18-25', '26-35', '36-45', '46-55', '55+']
print(df['AgeGroup'].nunique()) # 5 print(df['AgeGroup'].sort_values()) # Sorted list

→ Answer: There are 3 unique departments and 5 age groups, confirming the data is properly categorised.
sort_values() helps verify the categories are logically ordered.

Q4. How would you create a correlation heatmap to identify relationships?


import [Link] as plt import seaborn as sns [Link](figsize=(25, 20)) corr =
[Link](numeric_only=True) [Link](corr, cmap='RdBu', annot=True)
[Link]('Correlation') [Link]() # Key finding: MonthlyIncome & JobLevel correlation =
0.95 (very high!)

→ Answer: The heatmap reveals MonthlyIncome and JobLevel are almost perfectly correlated (0.95).
YearsAtCompany and TotalWorkingYears also correlate strongly (0.63). Red = negative, Blue = positive.

■ CASE STUDY 2: Vendor Management System Using OOP


Scenario: A fruit market owner wants a Python program to manage multiple vendors selling different fruits. Each
vendor has a product name, quantity, and price. The market always sells 'Fruits' as the product category.

Q1. Design a Vendor class for the fruit market.


class Vendor: product = 'Fruits' # Class variable — same for all vendors v1 = Vendor()
[Link] = 'Apple' # Instance variable [Link] = 40 [Link] = 120 v2 = Vendor()
[Link] = 'Banana' [Link] = 20 [Link] = 100 v3 = Vendor() [Link] =
'Coco' [Link] = 50 [Link] = 80 print('Vendor 1:', [Link], 'Qty:',
[Link], [Link], [Link]) print('Vendor 2:', [Link], 'Qty:', [Link],
[Link], [Link]) print('Vendor 3:', [Link], 'Qty:', [Link], [Link],
[Link])

→ Output: Vendor 1: Apple Qty: 40 120 Fruits | Vendor 2: Banana Qty: 20 100 Fruits | Vendor 3: Coco Qty: 50
80 Fruits

Q2. What is the difference between class variable and instance variable here?
→ Answer: product = 'Fruits' is a class variable — it is defined inside the class and shared by all vendor objects
(v1, v2, v3 all have product='Fruits' automatically). Productname, Quantity, price are instance variables —
each object has its own unique values. Changing [Link] does NOT affect [Link].

Q3. Add a method to calculate total revenue for each vendor.


class Vendor: product = 'Fruits' def total_revenue(self): return [Link] *
[Link] v1 = Vendor() [Link] = 'Apple' [Link] = 40 [Link] = 120
print('Revenue:', v1.total_revenue()) # 40 × 120 = 4800

■ CASE STUDY 3: Student Performance Visualisation


Scenario: A college professor has student marks data and wants to visually analyse the distribution of scores and
the relationship between study hours and marks. Use Matplotlib to create the required charts.

Q1. Create a histogram showing the distribution of student marks.


import [Link] as plt marks = [45,55,60,62,65,70,72,75,78,80,82,85,88,90,92]
[Link](figsize=(8, 6)) [Link](marks, bins=5, color='skyblue', edgecolor='black')
[Link]('Distribution of Student Marks') [Link]('Marks Scored') [Link]('Number
of Students') [Link](axis='y', linestyle='--', alpha=0.7) [Link]()

→ bins=5 divides the range (45-92) into 5 equal buckets. The grid makes it easier to read exact counts.
alpha=0.7 makes the grid lines semi-transparent.

Q2. Show the relationship between study hours and marks using scatter plot.
hours = [1, 2, 3, 4, 5, 6, 7, 8] marks = [35, 40, 50, 55, 65, 70, 78, 85] [Link](hours,
marks) # Line connecting points [Link](hours, marks, color='Black', marker='x') #
Data points [Link]('Hours of Study vs. Marks Scored') [Link]('Hours of Study')
[Link]('Marks Scored') [Link](True, linestyle='--', alpha=0.6) [Link]()

→ The scatter clearly shows a positive linear relationship — more study hours → higher marks. IMPORTANT:
'olivegreen' is NOT a valid color (causes ValueError). Use 'olive', 'green', or hex codes.

Q3. Create a pie chart of a student's subject marks.


import numpy as np x = [Link]([35, 25, 25, 15]) # Random scores near these values
marks = ['OB', 'Corporate Law', 'Marketing', 'Accounts'] [Link](x, labels=marks,
autopct='%1.1f%%') [Link]() # autopct='%1.1f%%' shows percentages with 1 decimal place

■ CASE STUDY 4: OOP Calculator with Business Logic


Scenario: A software company asks you to create a simple calculator application using Object-Oriented
Programming. The calculator must perform basic operations, check odd/even, compute simple interest, and find
largest/smallest numbers.

Q1. Create a Calculator class with all four arithmetic operations.


class Calculator: pass # 'pass' creates an empty class calc = Calculator() calc.num1 = 1003
calc.num2 = 13 print('Addition:', calc.num1 + calc.num2) # 1016 print('Subtraction:',
calc.num1 - calc.num2) # 990 print('Multiplication:', calc.num1 * calc.num2) # 13039
print('Division:', calc.num1 / calc.num2) # 77.15...
Q2. Build a class-based system to compute Simple Interest for a loan.
class Interest: def calc(self, p, r, t): # p=principal, r=rate%, t=time(years) return (p *
r * t) / 100 si = Interest() result = [Link](7, 8, 6) print('Simple Interest:', result) #
3.36 # Formula: SI = (P × R × T) / 100

→ For a loan of P=7, Rate=8%, Time=6 years: SI = (7×8×6)/100 = 3.36

Q3. Create separate classes to find the Largest and Smallest of two numbers.
class Largest: def find_largest(self, a, b): if a > b: return a else: return b class
Smallest: def find_smallest(self, a, b): if a < b: return a else: return b n1 = Largest()
print('Largest:', n1.find_largest(92, 67)) # 92 n2 = Smallest() print('Smallest:',
n2.find_smallest(92, 67)) # 67

Q4. How does the class-based approach help in a business calculator?


→ Answer: OOP provides: (1) Reusability — once written, any part of the program can use the class. (2)
Modularity — each operation is isolated in its own class. (3) Scalability — new operations can be added without
touching existing code. (4) Testing — each class can be tested independently. This is why enterprise software
uses OOP.

■ CASE STUDY 5: Monthly Budget & Expense Dashboard


Scenario: A financial advisor wants to create a visual dashboard of a client's monthly expenses to help them
understand their spending patterns. The expenses are: Rent 40%, Food 25%, Transport 10%, Entertainment 15%,
Savings 10%.

Q1. Create a detailed pie chart with highlight on the largest expense.
import [Link] as plt data = {'Rent':40, 'Food':25, 'Transport':10,
'Entertainment':15, 'Savings':10} labels = list([Link]()) values = list([Link]())
# Dynamically find and explode the largest slice max_value = max(values) # 40 (Rent)
explode = [0.1 if v == max_value else 0 for v in values] # Result: [0.1, 0, 0, 0, 0]
[Link](figsize=(8, 6)) [Link](values, labels=labels, autopct='%1.1f%%',
explode=explode, startangle=140, shadow=True,
colors=['#ff9999','#66b3ff','#99ff99','#ffcc99','#c2c2f0']) [Link]('Monthly Expenses
Breakdown') [Link]('equal') # IMPORTANT: keeps pie as a circle! [Link]()

→ explode=[0.1,0,0,0,0] pulls the 'Rent' slice outward to highlight it. startangle=140 rotates the chart for better
label placement. shadow=True adds a 3D shadow effect.

Q2. What does [Link]('equal') do and why is it critical?


→ Answer: Without [Link]('equal'), the pie chart stretches to fill the figure dimensions and appears as an
oval/ellipse instead of a circle. [Link]('equal') forces equal scaling on both X and Y axes, ensuring the pie is
perfectly circular. Always include this when drawing pie charts.

Q3. Create a grouped bar chart comparing two categories over 5 days.
import [Link] as plt # Offset bars slightly so they appear side-by-side
[Link]([0.25, 1.25, 2.25, 3.25, 4.25], [50,40,70,80,20], label='BMW', color='0.5',
width=0.5) [Link]([0.75, 1.75, 2.75, 3.75, 4.75], [80,20,20,50,60], label='Audi',
color='r', width=0.5) [Link]() [Link]('Days') [Link]('Distance (kms)')
[Link]('BMW vs Audi Distance Comparison') [Link]()

→ Key technique: The two sets of bars are offset by 0.5 on the X-axis so they appear side-by-side. Both use the
same width=0.5. The legend() call creates the coloured key.

Q4. Using NumPy, generate a random expense simulation and plot it.
import numpy as np import [Link] as plt # Generate 250 normally distributed
expense values around ■10,000 x = [Link](10000, 1500, 250) [Link](x, bins=20,
color='skyblue', edgecolor='black') [Link]('Simulated Monthly Expenses Distribution')
[Link]('Expense Amount (■)') [Link]('Frequency') [Link]() #
[Link](mean, std_dev, count) # mean=10000, std=1500, 250 data points
QUICK REVISION CHEATSHEET — Last Minute Review
Topic Most Important Points to Remember

NumPy Import import numpy as np

Pandas Import import pandas as pd

Matplotlib Import import [Link] as plt

Seaborn Import import seaborn as sns

Create Array [Link]([1,2,3]) | [Link](mean,std,n)

Matrix Multiply [Link](a,b) — NOT a*b (that's element-wise)

Array Stats .max() .min() .sum() .mean()

Load CSV pd.read_csv('[Link]')

DataFrame Info [Link]() | [Link]() | [Link] | [Link]().sum()

Select Column df['Col'] | df[['Col1','Col2']] | [Link][0]

Unique Values df['Col'].unique() | df['Col'].nunique()

Class Variable Defined inside class, outside method — shared by all

Instance Variable [Link] = val — unique to each object

Method Self def method(self, a, b): — self always first parameter

Constructor def __init__(self): — auto-called on object creation

Pie Chart Fix [Link]('equal') — makes pie circular, not oval

Pie Percentages autopct='%1.1f%%'

Explode Slice explode=[0.1, 0, 0, 0] — pulls out first slice

Histogram [Link](data, bins=N, color='skyblue', edgecolor='black')

Scatter Plot [Link](x, y, color='blue', marker='x')

Bar Chart [Link](x, y) | [Link](x,y) for horizontal

Add Labels [Link]() | [Link]() | [Link]() | [Link]()

Heatmap [Link]([Link](numeric_only=True), cmap='RdBu', annot=True)

KDE Histogram [Link](df['col'], kde=True, bins=20)

Grid [Link](True, linestyle='--', alpha=0.7)

Figure Size [Link](figsize=(8,6))

Subplots [Link](rows, cols, index)

■■ Error 'olivegreen' is NOT valid — use 'olive' or hex code

■■ Null Values HR Data: YearsWithCurrManager had 57 nulls

■■ Correlation MonthlyIncome vs JobLevel = 0.95 (strongest in HR data)

■ Best of luck on your exam! You've got this!



Remember: Read questions carefully, show your code with comments, and always import libraries
first.

You might also like