ComputerScience(083)-XII
4. Unit wise Syllabus
==============================================
Unit 1: Computational Thinking and Programming – 2
● Revision of Python topics covered in Class XI.
● Functions: types of function (built-in functions, functions defined in module, user
defined functions), creating user defined function, arguments and parameters,
default parameters, positional parameters, function returning value(s), flow of
execution, scope of a variable (global scope, local scope)
● Exception Handling: Introduction, handling exceptions using try-except-finally
blocks
● Introduction to files, types of files (Text file, Binary file, CSV file), relative
and absolute paths
● Text file: opening a text file, text file open modes (r, r+, w, w+, a, a+), closing a text
file, opening a file using with clause, writing/appending data to a text file using
write() and writelines(), reading from a text file using read(), readline() and
readlines(), seek and tell methods, manipulation of data in a text file
● Binary file: basic operations on a binary file: open using file open modes (rb, rb+,
wb, wb+, ab, ab+), close a binary file, import pickle module, dump() and load()
method, read, write/create, search, append and update operations in a binary file
● CSV file: import csv module, open / close csv file, write into a csv file using
writer(),writerow(),writerows() and read from a csv file using reader()
● Data Structure: Stack, operations on stack (push & pop), implementation of stack
using list.
______________________________________________________________________
Unit 1: Computational Thinking and Programming – 2
Revision of Python Topics Covered in Class XI
Before diving into advanced topics, it’s important to revise the basics of Python programming, including:
- Variables, data types, and operators.
- Conditional statements (if, elif, else).
- Loops (for, while) and loop control statements (break, continue, pass).
- String and list operations.
- Functions and modules.
Functions
Functions are reusable blocks of code that perform a specific task.
Types of Functions:
- Built-in Functions: Predefined functions in Python. Example:
len(),max(). - Functions in Modules: Functions provided by external libraries. Example:
math.sqrt()from themathmodule. - User-defined Functions: Functions created by the user.
Creating User-Defined Functions:
# Example of a user-defined function
def greet(name):
print(f"Hello, {name}!")
greet("Alice")
Arguments and Parameters:
- Positional Parameters: Arguments passed in order.
- Default Parameters: Provide a default value if no argument is given.
Example:
def greet(name="Guest"): print(f"Hello, {name}!")
greet() # Output: Hello, Guest!
#### Function Returning Values:
Functions can return values using the `return` statement.
```python
def add(a, b):
return a + b
result = add(5, 3)
print(result) # Output: 8
Scope of a Variable:
- Local Scope: Variables declared inside a function.
- Global Scope: Variables declared outside all functions.
global_var = 10
def example():
local_var = 5
print(local_var) # Accessible only inside the function
Exception Handling
Exception handling allows the program to handle errors gracefully without crashing.
- try-except-finally Blocks:
try:
num = int(input("Enter a number: "))
print(10 / num)
except ZeroDivisionError:
print("Cannot divide by zero!")
finally:
print("Execution complete.")
Introduction to Files
Files are used to store data permanently.
Types of Files:
- Text Files: Store plain text data.
- Binary Files: Store data in binary format.
- CSV Files: Store tabular data in comma-separated values.
File Paths:
- Relative Path: Relative to the program’s location.
- Absolute Path: Complete path to the file.
Text File Operations
- Open Modes:
r(read),r+(read and write),w(write),w+(write and read),a(append),a+(append and read).
- Using the
withClause: Ensures the file is closed automatically.
with open("example.txt", "w") as file:
file.write("Hello, World!")
- Reading and Writing:
- Write:
write(),writelines(). - Read:
read(),readline(),readlines(). - Seek/Tell: Navigate and track the file pointer.
- Write:
Binary File Operations
- Open Modes:
rb(read),rb+(read and write),wb(write),wb+(write and read),ab(append),ab+(append and read). - Using the
pickleModule:
import pickle
# Writing data to a binary file
with open("data.pkl", "wb") as file:
pickle.dump([1, 2, 3], file)
# Reading data from a binary file
with open("data.pkl", "rb") as file:
data = pickle.load(file)
print(data)
CSV File Operations
- Using the
csvModule:
import csv
# Writing to a CSV file
with open("data.csv", "w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["Name", "Age"])
writer.writerows([["Alice", 25], ["Bob", 30]])
# Reading from a CSV file
with open("data.csv", "r") as file:
reader = csv.reader(file)
for row in reader:
print(row)
Data Structure: Stack
A stack is a linear data structure following the LIFO (Last In, First Out) principle.
Operations:
- Push: Add an element to the top of the stack.
- Pop: Remove the top element from the stack.
Implementation Using Lists:
stack = [ ]
# Push operation
stack.append(10)
stack.append(20)
# Pop operation
print(stack.pop()) # Output: 20These topics provide the foundation for advanced programming concepts and practical applications in computer science.
===========================================================
Unit 2: Computer Networks
● Evolution of networking: introduction to computer networks, evolution of networking
(ARPANET, NSFNET, INTERNET)
● Data communication terminologies: concept of communication, components of
data communication (sender,receiver, message, communication media,
protocols), measuring capacity of communication media (bandwidth, data
transfer rate), IP address, switching techniques (Circuit switching, Packet
switching)
● Transmission media: Wired communication media (Twisted pair cable, Co-axial
cable, Fiber-optic cable), Wireless media (Radio waves, Micro waves, Infrared
waves)
● Network devices (Modem, Ethernet card, RJ45, Repeater, Hub, Switch, Router,
Gateway, WIFI card)
● Network topologies and Network types: types of networks (PAN, LAN, MAN,
WAN), networking topologies (Bus, Star, Tree)
● Network protocol: HTTP, FTP, PPP, SMTP, TCP/IP, POP3, HTTPS, TELNET,
VoIP
● Introduction to web services: WWW, Hyper Text Markup Language (HTML),
Extensible Markup Language (XML), domain names, URL, website, web
browser, web servers, web hosting.
_______________________________________________________________________
Unit 2: Computer Networks
Evolution of Networking
- Introduction to Computer Networks: A computer network is a system of interconnected devices that exchange data and share resources, such as printers or the Internet. These networks can range in size from small personal area networks to vast global networks.
- Evolution of Networking:
- ARPANET (1969): The first-ever network, developed by the U.S. Department of Defense, laid the foundation for modern networking by connecting four computers in different locations.
- NSFNET (1980s): Expanded networking capabilities beyond military use to include academic and research institutions, enabling broader access.
- INTERNET (1990s-Present): The global network we use today connects millions of private, public, academic, business, and government systems, facilitating worldwide communication and collaboration.
Data Communication Terminologies
- Concept of Communication: Data communication involves the exchange of information between devices using a transmission medium.
- Components of Data Communication:
- Sender: The device that initiates and sends the message, such as a computer or smartphone.
- Receiver: The device that receives and processes the message.
- Message: The actual data being transmitted, which could be text, audio, video, or images.
- Communication Media: The physical or wireless medium through which data travels (e.g., cables or radio waves).
- Protocols: A set of rules that define how data is transmitted and received. For example, TCP/IP governs most Internet communication.
- Measuring Communication Media Capacity:
- Bandwidth: Indicates the maximum amount of data that can be transferred over a network in a specific time, measured in bits per second (bps).
- Data Transfer Rate: Reflects the actual speed at which data moves between devices, which can vary due to network congestion.
- IP Address: A unique numerical identifier assigned to every device on a network, allowing them to communicate.
- Switching Techniques:
- Circuit Switching: Establishes a dedicated communication path for the duration of a connection, commonly used in telephone networks.
- Packet Switching: Breaks data into packets and transmits them independently. This method is the backbone of Internet communication.
Transmission Media
- Wired Communication Media:
- Twisted Pair Cable: Consists of two insulated copper wires twisted together, commonly used in LAN setups.
- Co-axial Cable: Features a single copper conductor with a shielding layer. It is widely used in cable TV networks.
- Fiber-optic Cable: Transmits data using light, offering high speeds and long-distance communication with minimal data loss.
- Wireless Media:
- Radio Waves: Utilized in Wi-Fi, Bluetooth, and cellular networks, providing broad coverage.
- Microwaves: Used in satellite communications and point-to-point wireless links.
- Infrared Waves: Limited to short-range communication, such as in remote controls or infrared sensors.
Network Devices
- Modem: A device that modulates and demodulates signals for Internet access by converting digital signals to analog and vice versa.
- Ethernet Card: A hardware component that enables a computer to connect to a wired network.
- RJ45 Connector: A standard connector used to plug Ethernet cables into networking devices.
- Repeater: Amplifies and regenerates signals to extend the range of a network.
- Hub: A simple device that connects multiple computers in a network and broadcasts data to all connected devices.
- Switch: A more advanced device that connects devices and forwards data only to the intended recipient, improving efficiency.
- Router: Directs data packets between different networks, often used to connect a home or office network to the Internet.
- Gateway: Acts as a bridge between two networks using different protocols.
- Wi-Fi Card: A wireless network adapter that allows devices to connect to Wi-Fi networks.
Network Topologies and Network Types
- Types of Networks:
- PAN (Personal Area Network): Covers a very small area, such as Bluetooth connections between a smartphone and a smartwatch.
- LAN (Local Area Network): Covers a limited area like a home, office, or school, often using Ethernet or Wi-Fi.
- MAN (Metropolitan Area Network): Extends across a city or campus, typically used for public Wi-Fi or large institutions.
- WAN (Wide Area Network): Covers vast geographical areas, connecting multiple LANs. The Internet is the largest example of a WAN.
- Networking Topologies:
- Bus Topology: All devices share a single communication line. If the main cable fails, the entire network is disrupted.
- Star Topology: All devices are connected to a central hub or switch, making it easy to troubleshoot but dependent on the central device.
- Tree Topology: A combination of bus and star topologies, offering hierarchical connectivity.
Network Protocols
- HTTP (Hypertext Transfer Protocol): Facilitates the transfer of web pages over the Internet.
- FTP (File Transfer Protocol): Used to transfer files between computers.
- PPP (Point-to-Point Protocol): Establishes direct communication links between two devices.
- SMTP (Simple Mail Transfer Protocol): Used for sending emails.
- TCP/IP (Transmission Control Protocol/Internet Protocol): Forms the foundation of Internet communication by defining how data is transmitted.
- POP3 (Post Office Protocol 3): Retrieves emails from a server to a client device.
- HTTPS (Secure HTTP): Encrypts communication between a browser and a web server for secure transactions.
- TELNET: Enables remote login to another computer, primarily for administrative purposes.
- VoIP (Voice over Internet Protocol): Allows voice calls over the Internet, such as through Skype or WhatsApp.
Introduction to Web Services
- WWW (World Wide Web): A vast collection of interlinked web pages and multimedia content accessible over the Internet.
- HTML (HyperText Markup Language): The standard language used to create web pages.
- XML (Extensible Markup Language): A flexible markup language for structuring and transporting data.
- Domain Names: Readable names for websites, such as "google.com," that correspond to IP addresses.
- URL (Uniform Resource Locator): The unique address of a web page on the Internet.
- Website: A collection of related web pages hosted on a web server.
- Web Browser: Software used to access and display web pages, such as Google Chrome or Mozilla Firefox.
- Web Servers: Computers that store and deliver web pages to users.
- Web Hosting: A service that provides storage space and accessibility for websites, enabling them to be viewed online.
===========================================================
Unit 3: Database Management
● Database concepts: introduction to database concepts and its need
● Relational data model: relation, attribute, tuple, domain, degree, cardinality, keys
(candidate key, primary key, alternate key, foreign key)
● Structured Query Language: introduction, Data Definition Language and Data
Manipulation Language, data type (char(n), varchar(n), int, float, date), constraints
(not null, unique, primary key), create database, use database, show databases,
drop database, show tables, create table, describe table, alter table (add and
remove an attribute, add and remove primary key), drop table, insert, delete, select,
operators (mathematical, relational and logical), aliasing, distinct clause, where
clause, in, between, order by, meaning of null, is null, is not null, like, update
command, delete command, aggregate functions (max, min, avg, sum, count),
group by, having clause, joins: cartesian product on two tables, equi-join and natural
join
● Interface of python with an SQL database: connecting SQL with Python, performing insert, update, delete queries using cursor, display data by using connect(),
cursor(), execute(), commit(), fetchone(), fetchall(), rowcount, creating database
connectivity applications, use of %s format specifier or format() to perform queries.
___________________________________________________________________
Unit 3: Database Management
Database Concepts
Introduction to Database Concepts
A database is an organized collection of data that facilitates efficient access, management, and updating of information. Databases are essential for systematically storing vast amounts of information, making retrieval, manipulation, and security easy and effective. These systems are critical in fields such as healthcare for managing patient records, e-commerce for tracking orders, and banking for account details. For example, a library database manages book records, borrower information, and lending transactions, streamlining the overall process.
Relational Data Model
Core Terminologies
- Relation: Represents a table in a database that organizes data into rows and columns.
- Attribute: A column in a table that specifies a property of the data, such as "Name" or "Age."
- Tuple: A row in a table representing a single record, e.g., a student's details.
- Domain: A set of permissible values for a given attribute, like valid ages between 1 and 120.
- Degree: The number of attributes (columns) in a table. For instance, a table with ID, Name, and Age has a degree of three.
- Cardinality: Refers to the number of rows (tuples) in a table.
Keys
- Candidate Key: A set of attributes that uniquely identifies tuples in a table.
- Primary Key: A unique identifier chosen from candidate keys, e.g., Student_ID.
- Alternate Key: Candidate keys not selected as the primary key.
- Foreign Key: An attribute in one table that references the primary key in another table to establish relationships.
Structured Query Language (SQL)
Overview of SQL
Structured Query Language (SQL) is a standard language for managing relational databases. It provides tools to create, retrieve, manipulate, and delete data.
Components of SQL
- Data Definition Language (DDL): Commands for defining database structures, such as
CREATE,ALTER, andDROP. - Data Manipulation Language (DML): Commands for manipulating data, including
INSERT,UPDATE,DELETE, andSELECT.
Data Types
- char(n): Fixed-length character string.
- varchar(n): Variable-length character string.
- int: Integer data type.
- float: Floating-point number.
- date: Stores calendar dates.
Constraints
- NOT NULL: Ensures a column cannot contain null values.
- UNIQUE: Guarantees that all values in a column are distinct.
- PRIMARY KEY: Combines NOT NULL and UNIQUE constraints to identify records uniquely.
SQL Commands
Database Management
- Create Database:
CREATE DATABASE database_name; - Use Database:
USE database_name; - Show Databases:
SHOW DATABASES; - Drop Database:
DROP DATABASE database_name;
Table Management
- Create Table:
CREATE TABLE table_name ( column1 datatype constraints, column2 datatype constraints ); - Describe Table:
DESCRIBE table_name; - Alter Table:
- Add/Remove Columns:
ALTER TABLE table_name ADD column_name datatype; - Add/Remove Primary Keys:
ALTER TABLE table_name ADD PRIMARY KEY (column_name);
- Add/Remove Columns:
- Drop Table:
DROP TABLE table_name;
Data Manipulation
- Insert Data:
INSERT INTO table_name VALUES (...); - Delete Data:
DELETE FROM table_name WHERE condition; - Select Data:
SELECT columns FROM table_name WHERE condition;
Operators and Clauses
- Operators:
- Mathematical:
+,-,*,/ - Relational:
=,>,<,>=,<=,<> - Logical:
AND,OR,NOT
- Mathematical:
- Clauses:
- Aliasing: Rename columns or tables using
AS. - DISTINCT: Remove duplicate rows in the output.
- WHERE: Filter records based on conditions.
- IN: Check if a value exists within a set.
- BETWEEN: Filter records within a range.
- ORDER BY: Sort records in ascending or descending order.
- NULL Checks:
IS NULL,IS NOT NULL. - LIKE: Match patterns using
%or_.
- Aliasing: Rename columns or tables using
Updating Data
- Modify data using
UPDATE table_name SET column=value WHERE condition;
Aggregate Functions
MAX(),MIN(),AVG(),SUM(),COUNT().
Grouping and Filtering
GROUP BYgroups rows sharing a common value.HAVINGfilters grouped data.
Joins
- Cartesian Product: Combines all rows from two tables.
- Equi-Join: Matches rows based on specified conditions.
- Natural Join: Automatically matches rows with identical column names and values.
Interface of Python with an SQL Database
Python-SQL Integration
Python supports SQL database interaction using libraries like mysql.connector and sqlite3. These libraries enable developers to execute queries and handle database connections efficiently.
Basic Operations
- Connecting to a Database: Use
connect()to establish a database connection. - Executing Queries:
cursor.execute("SQL query") - Fetching Results:
fetchone(): Retrieves one row.fetchall(): Retrieves all rows.
- Commit Changes: Use
commit()to save modifications.
Example Code
Benefits of Python-SQL Integration
Python’s integration with SQL databases allows seamless data processing, enabling the development of robust applications for industries ranging from education to finance.



RUonTop: Hi Welcome to our Blog...