Skip to content

Instantly share code, notes, and snippets.

@therayyanawaz
Created July 9, 2024 19:23
Show Gist options
  • Save therayyanawaz/956851e814a95ea2ee76aba5edfc289f to your computer and use it in GitHub Desktop.
Save therayyanawaz/956851e814a95ea2ee76aba5edfc289f to your computer and use it in GitHub Desktop.
Informatics Practices, CLASS 12 comprehensive notes.

Unit 1: Data Handling using Pandas -I

Introduction to Python Libraries: Pandas and Matplotlib

Python offers powerful libraries for data handling and visualization, with Pandas and Matplotlib being two of the most prominent. Pandas is primarily used for data manipulation and analysis, while Matplotlib is used for creating static, interactive, and animated visualizations in Python.

Data Structures in Pandas: Series and DataFrames

Series

A Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating point numbers, Python objects, etc.). The axis labels are collectively referred to as the index.

Creation of Series:

  • From ndarray:
    import pandas as pd
    import numpy as np
    
    data = np.array([1, 2, 3, 4])
    series = pd.Series(data)
    print(series)
  • From dictionary:
    data = {'a': 1, 'b': 2, 'c': 3}
    series = pd.Series(data)
    print(series)
  • From scalar value:
    series = pd.Series(5, index=['a', 'b', 'c'])
    print(series)

Mathematical Operations: Series support element-wise operations:

series = pd.Series([1, 2, 3, 4])
print(series + 5)

Head and Tail Functions:

  • series.head(n) returns the first n elements.
  • series.tail(n) returns the last n elements.

Selection, Indexing, and Slicing:

print(series[0])  # Selection by position
print(series['a'])  # Selection by label
print(series[0:2])  # Slicing by position
print(series['a':'c'])  # Slicing by label

DataFrames

A DataFrame is a two-dimensional labeled data structure with columns of potentially different types. It is similar to a table in a database or a data frame in R.

Creation of DataFrames:

  • From dictionary of Series:
    data = {'col1': pd.Series([1, 2, 3]), 'col2': pd.Series([4, 5, 6])}
    df = pd.DataFrame(data)
    print(df)
  • From list of dictionaries:
    data = [{'a': 1, 'b': 2}, {'a': 3, 'b': 4}]
    df = pd.DataFrame(data)
    print(df)
  • From CSV file:
    df = pd.read_csv('file.csv')
    print(df)

Display and Iteration:

  • df.head(n) and df.tail(n) for displaying the first and last n rows.
  • Iteration over rows:
    for index, row in df.iterrows():
        print(index, row)

Operations on Rows and Columns:

  • Add:
    df['new_col'] = df['col1'] + df['col2']
  • Select:
    print(df[['col1', 'col2']])
  • Delete:
    del df['col1']
  • Rename:
    df.rename(columns={'col1': 'new_col1'}, inplace=True)

Indexing using Labels and Boolean Indexing:

  • Label-based indexing:
    df.loc[0]
  • Boolean indexing:
    df[df['col1'] > 2]

Importing/Exporting Data:

  • To CSV:
    df.to_csv('file.csv', index=False)
  • From CSV:
    df = pd.read_csv('file.csv')

Data Visualization with Matplotlib

Purpose of Plotting: Plotting helps in understanding data patterns, trends, and outliers.

Types of Plots:

  • Line Plot:
    import matplotlib.pyplot as plt
    
    plt.plot(df['col1'])
    plt.savefig('line_plot.png')
    plt.show()
  • Bar Graph:
    df.plot(kind='bar')
    plt.savefig('bar_graph.png')
    plt.show()
  • Histogram:
    df['col1'].plot(kind='hist')
    plt.savefig('histogram.png')
    plt.show()

Customizing Plots:

  • Adding Label, Title, and Legend:
    plt.plot(df['col1'], label='Column 1')
    plt.xlabel('X-axis Label')
    plt.ylabel('Y-axis Label')
    plt.title('Plot Title')
    plt.legend()
    plt.savefig('custom_plot.png')
    plt.show()

By mastering these tools and techniques, you can efficiently handle and visualize data, making it easier to derive insights and make data-driven decisions.

Unit 2: Database Query using SQL

Revision of Database Concepts and SQL Commands

This unit covers a comprehensive revision of database concepts and SQL commands that were introduced in Class XI. The focus is on enhancing your understanding and ability to manipulate databases using SQL.

Math Functions

  • POWER(): Raises a number to the power of another number.
    SELECT POWER(2, 3); -- Returns 8
  • ROUND(): Rounds a number to a specified number of decimal places.
    SELECT ROUND(123.4567, 2); -- Returns 123.46
  • MOD(): Returns the remainder of a division.
    SELECT MOD(10, 3); -- Returns 1

Text Functions

  • UCASE()/UPPER(): Converts a string to uppercase.
    SELECT UPPER('hello'); -- Returns 'HELLO'
  • LCASE()/LOWER(): Converts a string to lowercase.
    SELECT LOWER('HELLO'); -- Returns 'hello'
  • MID()/SUBSTRING()/SUBSTR(): Extracts a substring from a string.
    SELECT SUBSTRING('Hello World', 1, 5); -- Returns 'Hello'
  • LENGTH(): Returns the length of a string.
    SELECT LENGTH('Hello'); -- Returns 5
  • LEFT(): Extracts a specified number of characters from the left of a string.
    SELECT LEFT('Hello', 2); -- Returns 'He'
  • RIGHT(): Extracts a specified number of characters from the right of a string.
    SELECT RIGHT('Hello', 2); -- Returns 'lo'
  • INSTR(): Returns the position of the first occurrence of a substring.
    SELECT INSTR('Hello World', 'World'); -- Returns 7
  • LTRIM(): Removes leading spaces from a string.
    SELECT LTRIM('   Hello'); -- Returns 'Hello'
  • RTRIM(): Removes trailing spaces from a string.
    SELECT RTRIM('Hello   '); -- Returns 'Hello'
  • TRIM(): Removes leading and trailing spaces from a string.
    SELECT TRIM('   Hello   '); -- Returns 'Hello'

Date Functions

  • NOW(): Returns the current date and time.
    SELECT NOW(); -- Returns current date and time
  • DATE(): Extracts the date part of a date or datetime expression.
    SELECT DATE(NOW()); -- Returns current date
  • MONTH(): Returns the month part of a date.
    SELECT MONTH(NOW()); -- Returns current month
  • MONTHNAME(): Returns the name of the month.
    SELECT MONTHNAME(NOW()); -- Returns current month name
  • YEAR(): Returns the year part of a date.
    SELECT YEAR(NOW()); -- Returns current year
  • DAY(): Returns the day of the month.
    SELECT DAY(NOW()); -- Returns current day
  • DAYNAME(): Returns the name of the day.
    SELECT DAYNAME(NOW()); -- Returns current day name

Aggregate Functions

  • MAX(): Returns the maximum value.
    SELECT MAX(salary) FROM employees; -- Returns highest salary
  • MIN(): Returns the minimum value.
    SELECT MIN(salary) FROM employees; -- Returns lowest salary
  • AVG(): Returns the average value.
    SELECT AVG(salary) FROM employees; -- Returns average salary
  • SUM(): Returns the sum of values.
    SELECT SUM(salary) FROM employees; -- Returns total salary
  • COUNT(): Returns the number of rows.
    SELECT COUNT(*) FROM employees; -- Returns number of employees

Querying and Manipulating Data

  • GROUP BY: Groups rows that have the same values into summary rows.
    SELECT department, COUNT(*) FROM employees GROUP BY department;
  • HAVING: Filters groups based on a condition.
    SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 10;
  • ORDER BY: Sorts the result set.
    SELECT * FROM employees ORDER BY salary DESC;

Working with Two Tables Using Equi-Join

  • Equi-Join: Combines rows from two or more tables based on a related column.
    SELECT employees.name, departments.name 
    FROM employees 
    JOIN departments ON employees.department_id = departments.id;

This comprehensive overview should help you revise and understand the key SQL functions and commands necessary for database querying and manipulation.

Unit 3: Introduction to Computer Networks

Introduction to Networks

A computer network is a collection of interconnected devices that communicate and share resources. Networks facilitate communication, data sharing, and resource allocation among multiple devices.

Types of Networks

  • PAN (Personal Area Network): A short-range network designed for personal devices, typically within a range of 30 feet. Examples include Bluetooth connections between a smartphone and a headset.
  • LAN (Local Area Network): A network that spans a small geographic area, like a single building or campus. It is commonly used in homes, schools, and offices.
  • MAN (Metropolitan Area Network): A network that covers a larger geographic area than a LAN, such as a city or a large campus.
  • WAN (Wide Area Network): A network that covers a broad area, such as a country or continent. The Internet is the largest example of a WAN.

Network Devices

  • Modem: Converts digital data from a computer into analog signals for transmission over telephone lines and vice versa.
  • Hub: A basic networking device that connects multiple computers in a LAN. It broadcasts data to all devices.
  • Switch: Similar to a hub but more efficient. It sends data only to the device that needs it.
  • Repeater: Amplifies and regenerates signals to extend the range of a network.
  • Router: Directs data packets between different networks, working at the network layer of the OSI model.
  • Gateway: Connects different types of networks and translates data between them.

Network Topologies

  • Star Topology: All devices are connected to a central hub or switch. It is easy to install and manage but relies heavily on the central device.
  • Bus Topology: All devices share a single communication line. It is inexpensive but can be slow and difficult to troubleshoot.
  • Tree Topology: A hierarchical topology that combines characteristics of star and bus topologies.
  • Mesh Topology: Every device is connected to every other device. It provides high redundancy and reliability but is expensive and complex to install.

Introduction to the Internet

The Internet is a global network of interconnected computers that communicate using standardized protocols. It supports various applications such as the World Wide Web (WWW), email, chat, and Voice over Internet Protocol (VoIP).

  • URL (Uniform Resource Locator): The address used to access resources on the Internet.
  • WWW (World Wide Web): A system of interlinked hypertext documents accessed via the Internet.

Applications of the Internet

  • Web: Accessing and sharing information through websites.
  • Email: Sending and receiving electronic messages.
  • Chat: Real-time text communication between users.
  • VoIP (Voice over Internet Protocol): Making voice calls over the Internet.

Website and Webpage

  • Website: A collection of related web pages hosted on a web server.
  • Webpage: A single document on the web, which is part of a website.
  • Static Webpage: Content does not change unless manually updated.
  • Dynamic Webpage: Content can change dynamically based on user interaction or other factors.
  • Web Server: A server that hosts websites and serves web pages to users.
  • Web Hosting: The service of providing storage space and access for websites on a web server.

Web Browsers

  • Introduction: Software applications used to access and view websites.
  • Commonly Used Browsers: Google Chrome, Mozilla Firefox, Microsoft Edge, Safari.
  • Browser Settings: Options to customize the browser's behavior and appearance.
  • Add-ons and Plug-ins: Extensions that add functionality to the browser.
  • Cookies: Small pieces of data stored by websites on a user's computer to remember preferences and track activity.

This overview provides a foundational understanding of computer networks, their types, devices, topologies, and related Internet concepts.

Unit 4: Societal Impacts

Digital Footprint

A digital footprint is the trail of data you leave behind when you use the internet. This includes websites visited, emails sent, and information submitted online. It is important to be aware of your digital footprint as it can be tracked and used by others.

Net and Communication Etiquettes

Netiquette, or internet etiquette, refers to the proper way to communicate online. Key points include:

  • Respect Privacy: Do not share personal information about others without their consent.
  • Avoid Plagiarism: Do not post copyrighted material without permission.
  • Respect Opinions: Avoid attacking or insulting others based on their opinions or beliefs.

Data Protection

Data protection involves safeguarding personal information from unauthorized access and misuse. This includes using strong passwords, encrypting data, and being cautious about sharing personal information online.

Intellectual Property Rights (IPR)

IPR are legal rights that protect creations of the mind, such as inventions, literary and artistic works, and symbols. These rights help creators control and benefit from their work.

Plagiarism

Plagiarism is the act of using someone else's work or ideas without proper attribution. It is considered unethical and can have serious consequences in academic and professional settings.

Licensing and Copyright

  • Copyright: Provides legal protection to the creators of original works, giving them exclusive rights to use and distribute their work.
  • Licensing: Allows others to use copyrighted material under specific conditions set by the copyright holder.

Free and Open Source Software (FOSS)

FOSS is software that is freely available to use, modify, and distribute. It promotes collaboration and sharing within the software community.

Cybercrime and Cyber Laws

Cybercrime includes illegal activities conducted via the internet, such as hacking, phishing, and cyberbullying. Cyber laws are regulations designed to combat these crimes and protect users.

  • Hacking: Unauthorized access to computer systems.
  • Phishing: Fraudulent attempts to obtain sensitive information by pretending to be a trustworthy entity.
  • Cyberbullying: Using digital platforms to harass or intimidate others.

Overview of Indian IT Act

The Indian IT Act provides a legal framework for electronic governance and addresses issues related to cybercrime and electronic commerce. It aims to promote secure and efficient use of digital technology.

E-waste: Hazards and Management

E-waste refers to discarded electronic devices. It poses environmental and health hazards due to the presence of toxic substances. Proper management includes recycling and safe disposal to minimize harm.

Health Concerns Related to Technology Usage

Excessive use of technology can lead to various health issues, such as:

  • Eye Strain: Prolonged screen time can cause eye discomfort.
  • Repetitive Strain Injury (RSI): Overuse of keyboards and mice can lead to musculoskeletal problems.
  • Mental Health: Overuse of social media and digital devices can contribute to stress, anxiety, and depression.

This unit provides a comprehensive understanding of the societal impacts of technology, emphasizing the importance of responsible and ethical use of digital resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment