Topper Style Notes
Topper Style Notes
Python
Basics of Python
Data Types:
o Integer: Whole numbers, e.g., 1, 2, 3.
o Float: Decimal numbers, e.g., 1.5, 2.75.
o String: Sequence of characters, e.g., "hello".
o Boolean: Represents True or False values.
o Mutable: Data types that can be modified after creation, such as Lists and
Dictionaries.
o Immutable: Data types that cannot be modified after creation, such as Tuples and
Strings.
List Slicing and Replication:
o Slicing: Used to extract parts of a list using the syntax list[start:stop:step].
Example: list[1:5:2].
o Replication: Duplicates the list elements using list * n. Example: [1, 2, 3]
* 2 results in [1, 2, 3, 1, 2, 3].
Dictionaries:
o A collection of key-value pairs defined using curly braces {}. Example: {'name':
'John', 'age': 30}.
o Access values by key: dict['name'] returns 'John'.
For Loop:
o Iterates over a sequence (like a list, tuple, or string). Example:
o for i in range(5):
print(i)
Attributes:
o shape: Returns a tuple (number of rows, number of columns).
o size: Total number of elements (rows * columns).
o columns: Lists all column labels.
o index: Lists all row labels.
o dtypes: Data types of each column.
Manipulating DataFrames:
o Adding Rows/Columns: Add a new column using df['new_col'] = values.
o Removing Rows/Columns: Remove using df.drop(labels, axis) where axis
is 0 for rows and 1 for columns.
o Renaming Columns: Use df.rename(columns={'old_name': 'new_name'}).
o loc and iloc:
loc: Access rows/columns using labels. Example: df.loc[1,
'column'].
iloc: Access rows/columns using integer positions. Example:
df.iloc[0, 1].
o Boolean Indexing: Filter DataFrame rows based on conditions. Example:
df[df['age'] > 30].
Slice vs DataFrame
Slice: A subset of the DataFrame that reflects changes in the original DataFrame.
DataFrame: A standalone object that can be modified independently.
CSV Operations
Primary Key: A unique identifier for each record in a table. It cannot have NULL
values.
Foreign Key: A field in a table that links to the primary key of another table, ensuring
referential integrity.
Candidate Key: A set of fields that uniquely identify a record. One candidate key is
chosen as the primary key.
DataTypes of MySQL
Data Constraints
RDBMS Terminologies
SQL Commands
Functions in SQL
String Functions:
o CONCAT(): Combines two or more strings.
o LENGTH(): Returns the length of a string.
o SUBSTR(): Extracts a substring from a string.
ROUND(): Rounds a number to a specified number of decimal places.
Aggregate Functions:
o SUM(): Calculates the sum of a set of values.
o AVG(): Calculates the average value.
o MAX(): Finds the maximum value.
o MIN(): Finds the minimum value.
o COUNT(): Counts the number of rows.
Date and Time Functions:
o NOW(): Returns the current date and time.
o CURDATE(): Returns the current date.
o YEAR(), MONTH(): Extracts the year or month from a date.
ORDER BY: Sorts the result set in ascending or descending order.
GROUP BY: Groups rows that have the same values in specified columns.
Star Topology:
o Features a central hub or switch to which all devices are connected.
o Easy to manage and troubleshoot.
o Real-life example: Home networks where all devices connect to a central router.
Networking Devices
Hub vs Switch:
o Hub: Broadcasts data to all devices in the network.
o Switch: Directs data to the specific device based on MAC address, more efficient
than a hub.
Router: Connects different networks and directs data packets to their destination.
Commonly used in homes and offices for internet access.
Repeater: Amplifies and retransmits signals to extend the range of a network.
Modem: Converts digital signals from a computer to analog for telephone lines and vice
versa.
LAN (Local Area Network): Covers a small geographic area like an office or home.
MAN (Metropolitan Area Network): Covers a larger area such as a city.
WAN (Wide Area Network): Covers large geographical areas, often consisting of
multiple LANs. The internet is the largest WAN.
Hacking vs Cracking
Intellectual Property
Cyber Crime
Refers to criminal activities carried out using computers and the internet. Examples
include identity theft, phishing, and ransomware attacks.
Website Concepts
Full Forms