You are on page 1of 13

Computer Science(083)

Class XII
Term2 (Quick Revision)

Unit I: Computational Thinking and Programming – 2


Data Structures :
A data structure in python can be defined as a structure which can holds related
data. In other words we can say that data structure is a way of storing, organizing
and fetching data in computer. There are four data structure in python:
1. List
2. Tuple
3. Dictionary
4. Set

STACK :
• A stack is a linear data structure in python in which addition and deletion of
elements can be done at one end only.
• A stack is known as LIFO (Last – In, First – Out) data structure in python.
• LIFO means the elements which are added in the last would be the first one
to remove.
• Examples of stack are pile of books, pile of plates or stack of carom coins.
Operations on Stack:
There are two main operations on Stack:
1. Addition of element on the Top of the Stack is called PUSH.
2. Removal of element on the Top of the Stack is called POP.
Unit II: Computer Networks
A computer network is an interconnection of two or more computers or computing
devices. A network allows computers to share data and resources among each
other.
Node :In a communication network, each device that is a part of a network and that
can receive, create, store or send data to different network routes is called a node.
Server :It is a special computer which provide services to other computer/devices
in a called clients.
Client :A computer/device connected in a network sending request to server is
called client.

Types of Network
Based on the geographical area covered and data transfer rate, computer networks
are broadly categorised as:
1. PAN (Personal Area Network)
2. LAN (Local Area Network)
3. MAN (Metropolitan Area Network)
4. WAN (Wide Area Network)

DATA COMMUNICATION TERMINOLOGIES

1. Channel: A channel is a communication path through which the data is


transmitted from the sender device to the receiver device.

2. Baud: The number of changes in a signal per second is known as baud. It is the
measuring unit of the data transfer rate. Technically, baud refers to a number of
discrete signal elements transmitted per second. 1 baud represents only 1 signal
change per second and is equivalent to 1 bit per second.

3. Bandwidth: The amount of data that can be passed along a communication


channel in each period of time (1 second) is termed as bandwidth. The measuring
unit is hertz (Hz), where 103 Hz = 1 Kilo Hertz (KHz), 103 KHz = 1 Mega Hertz
(MHz).

4. Data and Signals: Information that is stored within computer systems and
transferred over a computer network can be divided into two categories—data and
signals. Data are entities that are stored in the form of 0’s and 1’s, which convey
some special meaning to the computer system. When this data is transmitted from
one place to another, it is converted into signal. Signals are the electric or
electromagnetic encoding of data and are used to transmit data.
5. Communication/Transmission Media: It is a means of communication or
access (lines of communication) set up between two organizations to exchange
data/information. Communication media is the way of transmitting the signal from
one place to another. Communication media is also known as transmission media.
It plays an important role in sending and receiving of data to and from the sender
and receiver.
6. Data Transfer Rate: It is the amount of data transferred in one direction over a
link divided by the time taken to transfer it in bits per second (bps). The various
measuring units are bits per second (bps) and bytes per second (Bps) or baud,
kilobits per second (kbps), megabits per second (mbps), gigabits per second (gbps),
terabits per second (tbps.)

Switching Techniques
The main goal of networking is the reliable exchange of data or information among
several interconnected nodes. For the delivery of data with accuracy, various types
of switching techniques are used, namely:
1. Circuit Switching
2. Packet Switching
3. Message Switching

Transmission media

1) Guided Media or wired communication channel:


The guided media refers to the different types of cables used in the network.
They are of Type
a. Twisted Pair Cable
i. Shielded Twisted Pair (STP)
ii. Unshielded Twisted Pair (UTP)
b. Coaxial Cables
c. Optical Fibers
2) Unguided media or Wireless Communication Channel:
The unguided or wireless communication channels referred to a wireless
connection to the network. There is no physical connection given through wires in
this channel. The connection will be done through either sensors, antenna or any
other component
a. Microwave
b. Radio Wave
c. Satellite
d. Infrared
e. Laser
f. Bluetooth

Network Devices
Those devices which are used to connect computer, laptop, printer etc. to create a
network are called networking device. for example Modem, Hub, Switch, Router
etc

1. Modem : Modem stands for ‘MOdulator DEMolulator’. It refers to a device


used for conversion between analog signals and digital bits. The modem at the
sender’s end acts as a modulator that converts the digital data into analog signals.
The modem at the receiver’s end acts as a demodulator that converts the analog
signals into digital data for the destination node to understand.

2. Ethernet Card : also known as Network Interface Card (NIC card in short) is a
network adaptor used to set up a wired network. It acts as an interface between
computer and the network. It is a circuit board mounted on the motherboard of a
computer. Each NIC has a MAC address, which helps in uniquely identifying the
computer on the network.

3. Repeater : Data are carried in the form of signals over the cable. These signals
can travel a specified distance (usually about 100 m). Signals lose their strength
beyond this limit and become weak. A repeater is an analog device that works with
signals on the cables to which it is connected. The weakenedsignal appearing on
the cable is regenerated and put back on the cable by a repeater.
4. Hub : An Ethernet hub is a network device used to connect different devices
through wires. Data arriving on any of the lines are sent out on all the others. The
limitation of hub is that if data from two devices come at the same time, they will
collide.

5. Switch : A switch is a networking device that plays a central role in a Local


Area Network (LAN). Like a hub, a network switch is used to connect multiple
computers or communicating devices. A switch is called an intelligent hub as it
sends signals to only selected devices instead of sending to all.

6. Router : A router is a network device that can receive the data, analyse it and
transmit it to other networks. A router connects a local area network to the internet.
A router can be wired or wireless. A wireless router can provide Wi-Fi access to
smartphones and other devices.

7. Gateway : As the term “Gateway” suggests, it is a key access point that acts as a
“gate” between an organisation’s network and the outside world of the Internet.
Gateway serves as the entry and exit point of a network, as all data coming in or
going out of a network must first pass through the gateway in order to use routing
paths. A gateway can be implemented as software, hardware, or a combination of
both. This is because a network gateway is placed at the edge of a network and the
firewall is usually integrated with it.

Networking Topologies
The arrangement of computers and other peripherals in a network is called its
topology. Common network topologies are mesh, ring, bus, star and tree.

Mesh Topology : In this networking topology, each communicating device is


connected with every other device in the network. Such a network can handle large
amounts of traffic since multiple nodes can transmit data simultaneously.
Ring Topology : In ring topology, each node is connected to two other devices,
one each on either side. The nodes connected with each other thus form a ring. The
link in a ring topology is unidirectional. Thus, data can be transmitted in one
direction only (clockwise or counterclockwise).
Bus Topology : In bus topology, each communicating device connects to a
transmission medium, known as bus. Data sent from a node are passed on to the
bus and hence data can be received by any of the nodes connected to the bus.
In this topology, a single backbone wire called bus is shared among the nodes,
which makes it cheaper and easy to maintain.
Star Topology : In star topology, each communicating device is connected to a
central node, which is a networking device like a hub or a switch. Star topology is
considered very effective, efficient and fast as each device is directly connected
with the central device.
Disturbance in one device will not affect the rest of the network, any failure in the
central networking device may lead to the failure of complete network.
Tree or Hybrid Topology : It is a hierarchical topology, in which there are
multiple branches and each branch can have one or more basic topologies like star,
ring and bus. Such topologies are usually realised in WANs where multiple LANs
are connected.

Network Protocol
It is set of rules or standard that governs communication.
Types of Protocol
(a) TCP (Transmission Control Protocol)
(b) IP (Internet Protocol)
(c) FTP (File Transfer Protocol)
(d) PPP (Point-to-Point Protocol)
(e) SMTP (Simple Mail Transfer Protocol)
(f) POP3 (Post Office Protocol)
(g) TELNET (Remote Login)

INTRODUCTION TO WEB SERVICES

• WWW : : WWW is a set of programs and protocols that allows the user to
create and display multimedia web pages and is linked to the internet.
• Hyper Text Markup Language (HTML) : HTML is a Markup language that
enables users to create web pages and format them using predefined tags.
Tags are called coded elements.
• Extensible Markup Language (XML) : XML is a Markup Language for
creating documents in a structured format. Users can create their own tags
along with predefined tags already defined by HTML.
• web browser : A web browser is a WWW client that navigates through the
WWW and displays web pages.

• Domain names
o A domain name is a website's address on the Internet.
o Domain names are used in URLs to identify to which server belong a
specific webpage.
o The domain name consists of a hierarchical sequence of names
(labels) separated by periods (dots) and ending with an extension.
• URL :- URL stands for Uniform Resource Locator. A URL is nothing more
than the address of a given unique resource on the Web or address of a
website. The URL is an address that matches users to a specific resource
online, such as webpage.

• Website:- a website is a group of web pages, containing text, images and all
types of multi-media files.

• Web Server: - A web server is a computer that stores web server software
and a website's component files (e.g. HTML documents, images, CSS style
sheets, and JavaScript files).

• Web Hosting:- Web hosting is an online service that enables you to publish
your website or web application on the internet. When you sign up for a
hosting service, you basically rent some space on a server on which you can
store all the files and data necessary for your website to work properly.
Unit III: Database Management
RDBMS Terminology:
a. Relation: Tables in Relational Database
b. Attributes: Columns in a Relation
c. Tuples: Records/Rows in a relation
d. Degree: No. of attributes in a relation
e. Cardinality: No. of Tuples/records in a relation
f. Domain: Set of values taken for an attribute
g. Primary key: Key attribute that uniquely identifies a tuple
• Only one primary key in a relation
• No null values in primary key column
• No values can be repeated in a primary key column
h. Candidate keys: Set of attributes have the ability to become primary key
i. Alternate keys: All the candidate keys except primary key
Candidate key = primary key + alternate key
Alternate key = candidate key - primary key
j. Foreign key: A non-key attribute which is used to set relationship between 2
tables .The values of the foreign key are derived from the primary key of
another table.
Foreign key is also known as Referential Integrity constraint

DDL & DML Commands


❑ SQL constraints are used to specify rules for the data in a table.
❑ Constraints are used to limit the type of data that can go into a table. This
ensures the accuracy and reliability of the data in the table. If there is any
violation between the constraint and the data action, the action is aborted.
❑ Constraints can be column level or table level.
❑ Column level constraints apply to a column, and
❑ table level constraints apply to the whole table.
❑ NOT NULL - Ensures that a column cannot have a NULL value
❑ UNIQUE - Ensures that all values in a column are different
❑ PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely
identifies each row in a table
❑ FOREIGN KEY - Prevents actions that would destroy links between tables
❑ CHECK - Ensures that the values in a column satisfies a specific condition
❑ DEFAULT - Sets a default value for a column if no value is specified

Aggregate Functions
Aggregate Functions is used to perform calculation on group of rows and return the
calculated summary.
1. SUM()
2. AVG()
3. MAX()
4 .MIN()
5. COUNT()

The GROUP BY Statement

The GROUP BY statement is used in conjunction with the aggregate functions to


group the result-set by one or more columns.

Syntax: SELECT column_name, aggregate_function(column_name)


FROM table_name WHERE column_name operator value GROUP BY
column_name

The HAVING Clause


The HAVING clause was added to MySQL because the WHERE keyword could
not be used with aggregate functions.

Syntax: SELECT column_name, aggregate_function(column_name) FROM


table_name WHERE column_name operator value GROUP BY column_name
HAVING aggregate_function(column_name) operator value
JOINS : A join is a method of linking data between one (self-join) or more tables
based on values of the common column between the tables. MySQL supports the
following types of joins:
1. Cross join
2. Equi Join
3. Natural Join

Cross Join (Cartesian Product) The SQL CROSS JOIN produces a result set
which is the number of rows in the first table multiplied by the number of rows in
the second table if no WHERE clause is used along with CROSS JOIN.This kind
of result is called as Cartesian Product.

SQL EQUI JOIN performs a JOIN against equality or matching column(s) values
of the associated tables. An equal sign (=) is used as comparison operator in the
where clause to refer equality.

NATURAL JOIN is a type of EQUI JOIN and is structured in such a way that,
columns with the same name of associated tables will appear once only.

Interface of python with an SQL database

Basically the process of transfer data between python programs and MySQL
database is known as Python Database Connectivity. To connect python program
with any database like MySQL we need to create an interface / connection between
Python and MySQL.
To interfacing Python with MySQL we need a connector called “mysql
connector”.
Once the connector is installed, we are ready to connect our Python program to
MySQL Database.
These are the 5 steps we should follow to connect the Python program to
MySQL.
STEP 1 :- Open Python.
STEP 2:- Import the required package using following command – import
mysql.connector
STEP 3:- Use connect( ) function to establish the connection.
The syntax of connect( ) method is – connect(host=,user=, passwd=[,database=])
• Server_name :- Name of database server, generally it is given as
“localhost”
• User_name :- Name of the database user by which we connect with mysql
generally it is given as “root”
• Password :- It is the password of user “root” or associated with the
username.
• Database:- It is the name of database to which we want to connect with.

STEP 4:- Execute SQL Commands and fetch Rows. The next step after the
successful connection is to write SQL command and fetch rows. You have to
create a cursor object for executing SQL command and fetch rows. Cursor object is
a special kind of structure that processes the data row by row in database. You can
create cursor object in the following manner.

To perform the DML operations like insert, update or delete follow these steps:
• Create a cursor object.
• Write command as parameters for execute() function
• Use commit() function to save the changes and reflect the data in the table.
For Select Command :- As we know the select command is used to retrieve
records from the database. The result is available in the resultset or dataset. You
can store the select the command in cursor object in python. Then for resultset you
can use any of the the fetch…() functions. These are:
• fetchall(): It will retrieve all data from a database table in form of record or
tuple or a row.
• fetchone(): It will retrieve one record from the resultset as a tuple or a list. It
returns the records in a specific order like first record, the next time next
record and so on. If records are not available then it will return None.
• fetchmany(): It will retrieve a number of records from the database. If
records are not available then it will return an empty tuple.
• rowcount: It is one of the properties of cursor object that return number of
rows fetched from the cursor object.

STEP 5 :- To close the connection. The last step for Python MySQL connectivity
is closing the connection. Finally, we have to close the established connect using
close() function. It will help to clean up the memory. Syntax code: mycon.close()

You might also like