Class 12 Informatics Practices Formulas, Pandas & SQL Cheat Sheet
Comprehensive chapter-wise formula sheet, Python Pandas Series & DataFrame syntax, Matplotlib plotting rules, MySQL single-row & aggregate functions, SQL joins, networking protocols, and cyber ethics for CBSE Class 12 Informatics Practices (Code 065) as per NCERT 2026-27 syllabus.
Key Principles
- Pandas Data Structures: Series (1D homogeneous array with labeled index) and DataFrame (2D heterogeneous tabular data structure with mutable size and values).
- Series Creation: From 1D ndarray, Python list, scalar value, or Python dictionary (keys become the index).
- Series Indexing & Slicing: Positional indexing (0 to n-1) and label-based indexing; slicing by label includes both endpoints, while slicing by position excludes the upper bound.
- DataFrame Creation: From dictionary of lists/Series, 2D ndarray, list of dictionaries, or series of dictionaries.
- DataFrame Selection: `df['col']` or `df.col` selects a column as Series; `df[['col1', 'col2']]` selects a sub-DataFrame.
- DataFrame Indexers: `df.loc[row_label, col_label]` (label-based, end included) and `df.iloc[row_idx, col_idx]` (integer position-based, end excluded).
- Core Attributes: `shape`, `size`, `ndim`, `dtypes`, `index`, `columns`, `values`, `T` (transpose), `empty`.
| # | Topic | Formula | Conditions & Meaning |
|---|---|---|---|
| 1 | Series Object Creation Syntax | s = pd.Series(data=None, index=None, dtype=None) | Creates a 1D labeled array. When data is a dictionary, keys form the Series index automatically in insertion order. |
| 2 | Series Vectorized Arithmetic & NaN Alignment | s1 + s2 aligns indexes automatically; unaligned indices result in NaN (Not a Number) | Pandas automatically performs index alignment before executing element-wise arithmetic operations. |
| 3 | Series Head and Tail Filtering | s.head(n=5) returns first n elements; s.tail(n=5) returns last n elements | Inspects boundary elements without printing the entire data structure. Defaults to 5 rows if n is omitted. |
| 4 | DataFrame Creation from Dictionary of Lists | df = pd.DataFrame({'Col1': [v1, v2], 'Col2': [v3, v4]}, index=['R1', 'R2']) | Dictionary keys become column headers; lists must have equal lengths to prevent ValueError. |
| 5 | DataFrame Shape and Size Dimension Rules | df.shape = (nrows, ncols); df.size = nrows * ncols; df.ndim = 2 | DataFrame is always a 2-dimensional structure where total elements equal the product of rows and columns. |
Showing 5 of 12 formulas. View all 12 formulas →
Key Principles
- Descriptive Statistics: `max()`, `min()`, `count()`, `sum()`, `mean()`, `median()`, `mode()`, `std()`, `var()`, `quantile()`.
- Aggregation Axis: By default, statistical functions in DataFrame operate vertically across rows for each column (`axis=0` or `axis='index'`). Setting `axis=1` or `axis='columns'` calculates statistics horizontally across columns for each row.
- Handling Missing Data (NaN): `isna()` or `isnull()` detects missing values; `notna()` or `notnull()` detects non-missing values.
- Dropping Missing Data: `df.dropna(axis=0/1, how='any'/'all')` removes rows or columns containing missing values.
- Imputing Missing Data: `df.fillna(value)` substitutes missing values with a designated constant, mean, or median.
- Sorting Data: `df.sort_values(by=col_name, ascending=True/False)` sorts rows based on values; `df.sort_index(ascending=True/False)` sorts rows/columns by labels.
- CSV File I/O: `pd.read_csv('filename.csv')` imports tabular CSV into DataFrame; `df.to_csv('filename.csv', index=False)` writes DataFrame to CSV file.
| # | Topic | Formula | Conditions & Meaning |
|---|---|---|---|
| 1 | Arithmetic Mean Formula across Column / Row | df.mean(axis=0) computes column-wise average ignoring NaN values | Computes arithmetic mean per column (axis=0) or per row (axis=1), automatically excluding missing NaN cells. |
| 2 | Sample Standard Deviation Formula | df.std(axis=0) computes sample standard deviation with degrees of freedom N - 1 | Measures dispersion of numeric data points around the mean. Uses Bessel's correction (ddof=1) by default. |
| 3 | Variance Relation | df.var() = (df.std())^2 | The variance is the square of standard deviation representing average squared deviation. |
| 4 | Missing Value Detection Function | df.isna() or df.isnull() returns boolean DataFrame where True indicates NaN | Flags missing entries as True. Use `df.isna().sum()` to obtain column-wise count of missing cells. |
| 5 | Dropping Missing Values Syntax | df.dropna(axis=0, how='any'/'all', subset=[...], inplace=False) | Removes rows (axis=0) or columns (axis=1) if any value is missing ('any') or all values are missing ('all'). |
Showing 5 of 12 formulas. View all 12 formulas →
Key Principles
- Data Visualization: Graphical representation of information and data using visual elements like charts, graphs, and maps.
- Matplotlib Pyplot: `matplotlib.pyplot` module provides a state-machine interface for plotting similar to MATLAB.
- Line Plot: `plt.plot(x, y)` visualizes data trends over a continuous interval or time span.
- Bar Chart: `plt.bar(x, height)` draws vertical bars for comparing discrete categorical quantities; `plt.barh(y, width)` creates horizontal bars.
- Histogram: `plt.hist(x, bins=n)` plots frequency distribution of continuous numerical data grouped into equal bin intervals.
- Chart Customizations: `plt.title()`, `plt.xlabel()`, `plt.ylabel()`, `plt.legend()`, `plt.grid()`, `plt.xticks()`, `plt.yticks()`.
- Line & Marker Styling: `color` (e.g. 'r', 'blue'), `linestyle` ('-', '--', ':', '-.'), `linewidth`, `marker` ('o', '*', '^', 's'), `markersize`.
- Saving and Displaying: `plt.show()` renders visual canvas in GUI window; `plt.savefig('plot.png')` exports figure to graphic file.
| # | Topic | Formula | Conditions & Meaning |
|---|---|---|---|
| 1 | Line Plot Generation Syntax | plt.plot(x, y, color='blue', linestyle='--', linewidth=2, marker='o', label='Series1') | Plots connected line segments between points (x_i, y_i) to reveal continuous trends. |
| 2 | Vertical Bar Chart Syntax | plt.bar(x, height, width=0.8, color='green', edgecolor='black', label='Sales') | Renders vertical bars where height corresponds to category values; width sets bar thickness. |
| 3 | Horizontal Bar Chart Syntax | plt.barh(y, width, height=0.8, color='orange', edgecolor='black') | Draws horizontal bars extending along x-axis with categories positioned on y-axis. |
| 4 | Histogram Frequency Distribution Syntax | plt.hist(x, bins=10, range=(min_val, max_val), edgecolor='black', cumulative=False) | Divides range of numeric values into k equal intervals (bins) and displays counts per bin. |
| 5 | Plot Title and Axis Label Formatting | plt.title('Title Text', fontsize=14); plt.xlabel('X Label'); plt.ylabel('Y Label') | Annotates the coordinate axes and provides primary chart descriptive heading. |
Showing 5 of 12 formulas. View all 12 formulas →
Key Principles
- SQL Single-Row Functions: Operate on a single record and return one result per row. Divided into Numeric, String, and Date & Time functions.
- Numeric Functions: `POWER(m, n)`, `ROUND(n, d)`, `MOD(m, n)`, `SQRT(n)`, `TRUNCATE(n, d)`.
- String/Text Functions: `UCASE()`/`UPPER()`, `LCASE()`/`LOWER()`, `MID()`/`SUBSTRING()`/`SUBSTR()`, `LENGTH()`, `LEFT()`, `RIGHT()`, `INSTR()`, `LTRIM()`, `RTRIM()`, `TRIM()`, `CONCAT()`.
- Date and Time Functions: `NOW()`, `CURDATE()`, `DATE()`, `MONTH()`, `MONTHNAME()`, `YEAR()`, `DAY()`/`DAYOFMONTH()`, `DAYNAME()`.
- Aggregate/Group Functions: `MAX()`, `MIN()`, `AVG()`, `SUM()`, `COUNT(*)`, `COUNT(col)`. Operate on a set of rows and return a single scalar value.
- Group By and Having: `GROUP BY` groups rows having identical values; `HAVING` filters aggregated groups (used with group functions, whereas `WHERE` filters individual rows before grouping).
- Operations on Relations: Cartesian Product (Cross Join: $m \times n$ rows, $c_1 + c_2$ columns), Equi-Join (matching primary/foreign key values), Natural Join.
| # | Topic | Formula | Conditions & Meaning |
|---|---|---|---|
| 1 | Numeric Power Function | POWER(base, exp) or POW(base, exp) calculates base^exp | Returns the value of a number raised to the power of another number. |
| 2 | Numeric Round Function | ROUND(number, decimals); negative decimals round to tens, hundreds | Rounds a numeric expression to d decimal places. If d < 0, rounds to integer positions to the left of the decimal. |
| 3 | Numeric Modulo Function | MOD(m, n) or m % n returns remainder of m divided by n | Returns remainder of division. If n is 0, returns NULL. |
| 4 | String Substring Extraction Function | MID(str, pos, len) or SUBSTR(str, pos, len); 1-indexed in SQL | Extracts substring starting at 1-based character position pos for specified length len. |
| 5 | String Search Location Function (INSTR) | INSTR(string, substring) returns 1-based position of first match; 0 if not found | Returns index of first occurrence of target substring within source string; returns 0 if absent. |
Showing 5 of 13 formulas. View all 13 formulas →
Key Principles
- Computer Network: Interconnection of autonomous computers to share hardware, software, and data resources.
- Transmission Media: Guided/Wired (Twisted Pair - UTP/STP, Coaxial Cable, Optical Fiber - fastest, immune to EMI) and Unguided/Wireless (Radio Waves - omnidirectional, Microwaves - line of sight, Infrared - short range line-of-sight).
- Network Devices: Modem (Modulator-Demodulator), Hub (broadcast device, physical layer), Switch (intelligent packet forwarder using MAC addresses), Repeater (amplifies attenuated signals), Gateway (connects dissimilar protocol networks), Router (routes packets across networks using IP addresses).
- Network Topologies: Star (central hub/switch; easy fault detection; hub failure brings down network), Bus (single backbone cable; terminator at ends; cable break stops network), Tree (hierarchical combination of bus and star), Mesh (every node connected to every other node; highest redundancy and cost).
- Network Types: PAN (Personal Area Network: ~10m), LAN (Local Area Network: within building/campus), MAN (Metropolitan Area Network: city-wide), WAN (Wide Area Network: country/global, e.g. Internet).
- Network Protocols: HTTP (port 80), HTTPS (port 443, SSL/TLS encrypted), FTP (file transfer, port 20/21), TCP/IP (reliable packet transmission and routing), SMTP (sending mail, port 25), POP3 (receiving mail, port 110), VoIP (voice calls over IP).
- Web Concepts: World Wide Web (WWW), URL (Uniform Resource Locator), Domain Name System (DNS), Web Browser vs Web Server, Cookies (small text files stored by client browser for session management).
| # | Topic | Formula | Conditions & Meaning |
|---|---|---|---|
| 1 | Complete Mesh Topology Links Formula | Number of duplex physical links = N * (N - 1) / 2 | In full mesh topology, every node connects directly to every other node; for 10 nodes, L = 10*9/2 = 45 links. |
| 2 | Star Topology Links Count | Number of links in Star topology = N (each node connected to central switch) | Each of the N network nodes requires exactly one cable connecting it to the central hub or switch. |
| 3 | URL Anatomy Formula | URL = protocol://domain_name:port/path/resource?query#fragment | Deconstructs web address into transmission protocol, registered server domain, port, and file path. |
| 4 | Attenuation vs Repeater Placement Rule | Repeater required when cable distance exceeds maximum transmission segment (e.g. > 70–100 m for UTP) | Signals attenuate (weaken) over long distances; repeaters regenerate digital signals to prevent data loss. |
| 5 | Server Placement Best Practice (80-20 Rule) | Place server in the building / wing having the MAXIMUM number of computers | Minimizes inter-building network traffic and cable installation costs in CBSE layout questions. |
Showing 5 of 12 formulas. View all 12 formulas →
Key Principles
- Digital Footprint: The trail of digital data left behind by an individual when surfing the internet. Active (intentionally submitted: forms, posts, emails) vs Passive (unintentionally collected: browsing history, cookies, IP logs).
- Net Etiquette & Digital Ethics: Courteous behavior online, respecting copyright, avoiding hate speech, respecting others' privacy, and citing sources.
- Intellectual Property Rights (IPR): Legal rights protecting creations of the mind. Includes Copyright (artistic/literary/software works), Patents (inventions/processes), and Trademarks (brand logos/names/symbols).
- Plagiarism: Presenting another creator's ideas, text, or work as one's own without proper credit or attribution.
- Open Source Software (OSS) & Licenses: Free and Open Source Software (FOSS), GNU General Public License (GPL), Creative Commons (CC), Apache License.
- Cyber Crimes: Hacking (unauthorized system access), Phishing (fraudulent attempts to steal sensitive credentials via deceptive emails/sites), Cyber bullying, Cyber stalking, Identity Theft, Ransomware.
- Indian IT Act 2000: Primary legal framework for electronic governance and cyber offenses in India (amended 2008). Section 66 deals with computer-related offenses (hacking, identity theft).
- E-Waste Management: Hazards of toxic elements (Lead, Mercury, Cadmium) from discarded electronics; 3R principle (Reduce, Reuse, Recycle) and safe disposal via certified e-waste recyclers.
- Ergonomics: Science of designing the workplace environment (posture, eye level, monitor distance, lighting) to minimize strain and repetitive strain injuries (RSI).
| # | Topic | Formula | Conditions & Meaning |
|---|---|---|---|
| 1 | Digital Footprint Classification Rule | Total Footprint = Active Footprint (Forms, Social Posts) + Passive Footprint (IP Logs, Cookies, Geolocation) | Active footprint is voluntarily shared; passive footprint is collected automatically without explicit immediate awareness. |
| 2 | IPR Triad Categories | IPR = Copyright (Art & Software) + Patent (Inventions) + Trademark (Brand Symbols) | Copyright protects expression; patent protects functional invention; trademark protects commercial brand identity. |
| 3 | FOSS Freedom Dimensions (Richard Stallman 4 Freedoms) | Freedoms 0 (Run) + 1 (Study/Adapt) + 2 (Redistribute) + 3 (Improve/Publish) | The four fundamental software freedoms underpinning Free and Open Source Software defined by FSF. |
| 4 | Indian Information Technology Act 2000 Core Provisions | Enacted 9 June 2000; Amended 2008; Section 43 (Damage to computer), Section 66 (Hacking/Cyber Crimes), Section 66C (Identity Theft) | Provides legal recognition for electronic transactions, digital signatures, and prescribes penal punishments for cyber crimes. |
| 5 | Cyber Crime Classification Formula | Cyber Crime = Against Individuals (Cyber stalking, Harassment) + Against Property (Phishing, Hacking) + Against Government (Cyber Terrorism) | Categorization of illegal criminal offenses committed using computers and digital telecommunication networks. |
Showing 5 of 12 formulas. View all 12 formulas →