Oswaal CBSE Class 11 Term-2 Computer Science Revision Notes
Oswaal CBSE Class 11 Term-2 Computer Science Revision Notes
ØØ Operations on Lists:
• Concatenation – A process in which multiple lists can be combined together using ‘+’.
Syntax:
list3 = list1 + list2
• Replication – A process in which a list gets replicated or repeated a specific number of times using ‘*’.
Syntax:
list1 * 3
Two lists can’t be multiplied using *
• Membership Testing – An operation carried out to check whether a particular element is a member
of that list or not.
Using ‘in’ operator – returns “True” if the element appears in the list, otherwise returns “False”.
Using ‘not in’ operator – returns “True” if the element does not appear in the list, otherwise
returns “False”.
Syntax:
print (<element> in/not in <list1>)
• Indexing – An index value is assigned for each item present in the sequence.
In Python, indexing starts from 0.
Negative indices identify positions from the end of the list and starts with-1.
• Slicing – It is an operation in which the user can slice a particular range from that sequence.
List slices are sub-part of a list extracted out.
Syntax:
list1 [start: stop: step]
ØØ Built-in Functions for lists:
• append( ) – Adds a single item to the end of the list and does not create a new list.
Syntax:
list1.append(item)
• extend( ) – Adds one list at the end of the other list.
Syntax:
list1.extend(list2)
• insert( ) – Inserts an element at a specified index.
Syntax:
list1.insert(index_number, value)
• reverse( ) – Reverses the order of the elements in a list.
Syntax:
list.reverse( )
• index( ) – Returns the index of first matched item from the list.
Syntax:
list.index(<item>)
• update( ) – Changes an item or a range of items using ‘=’
Syntax:
list[index] = <new value>
• len( ) – Returns the length of the list.
Syntax:
len(list)
• sort( ) – Sorts the items of the list.
For ascending order
Syntax:
list.sort( )
Oswaal CBSE Chapterwise & Topicwise Revision Notes, For Term-II, COMPUTER SCIENCE, Class – XI [ 3
For descending order
Syntax:
list.sort(reverse = True)
• clear( ) – Removes all items from the list.
Syntax:
list.clear( )
• count( ) – Counts how many times an element has occurred in a list and returns it.
Syntax:
list.count(element)
ØØ Deletion operation – For deleting an item from a list.
• If index is known
pop( ) – Removes the element from specified index and returns the removed element.
Syntax:
list.pop(index)
If no index value is provided, the last element in the list is removed.
del statement – Removes the specified element but does not return the removed element.
Syntax:
del list(index) - to delete single element
OR del list(start index : stop index) - to delete a range of elements
• If element is known but its index is not known
remove( )
Syntax:
list.remove(element)
ØØ Searching the list
• For a particular element / index – index( )
Syntax:
list.index(element)
• For the maximum value in the list – max( )
Syntax:
max(list)
• For the minimum value in the list – min( )
Syntax:
min(list)
TUPLES
ØØ A tuple consists of a number of values separated by commas.
ØØ Tuples are enclosed within parentheses ( ).
ØØ The values that make up a tuple are called its elements.
ØØ Elements in a tuple need not be of the same type.
ØØ The index value of tuple starts with 0.
ØØ Tuples are faster and more efficient than lists.
ØØ If a tuple comprises of a single element, the element should be followed by a comma. Such a tuple is called
a singleton tuple.
ØØ Creating tuple with a single element:
Syntax:
tuple_name = (“January”,)
OR tuple_name = tuple( )
ØØ A tuple can be created by accepting input by user input using while loop.
ØØ Tuples can be nested. This means that tuples can be placed inside other tuples.
4 ] Oswaal CBSE Chapterwise & Topicwise Revision Notes, For Term-II, COMPUTER SCIENCE, Class – XI
ØØ The individual elements of a tuple can be accessed through their indices given in square brackets [ ].
ØØ A tuple can be traversed using
• ‘in’ operator with for loop.
Syntax:
for i in tuple_name:
print(i)
• range( ) function
Syntax:
for i in range(len (tuple_name)):
print(tuple_name [i])
ØØ Slicing is used to retrieve a subset of values.
Syntax:
tuple_name[start: stop: step]
ØØ Two tuples can be combine together using ‘+’ operator.
ØØ The elements of a tuple can be repeated using ‘*’ operator.
ØØ The users can check whether a particular element is a member of that tuple or not.
Using ‘in’ operator – returns “True” if the element appears in the tuple, otherwise returns “False”.
Using ‘not in’ operator – returns “True” if the element does not appear in the tuple, otherwise
returns “False”.
Syntax:
<element> in/not in <tuple_name>
ØØ Tuple functions:
• len( ) – Returns the length of a tuple.
Syntax:
len(tuple_name)
• count( ) – Counts the occurrence of an item in the tuple.
Syntax:
tuple_name.count(element)
• any( ) – Returns True if a tuple is having at least one item and returns False if the tuple is empty.
Syntax:
any(tuple_name)
• max( ) – Returns the element with maximum ASCII value in the tuple.
Syntax:
max(tuple_name)
• min( ) – Returns the element with minimum ASCII value in the tuple.
Syntax:
min(tuple_name)
• sorted( ) – Sorts the elements of a tuple.
Syntax:
sorted(tuple_name)
• index( ) – Finds the first index of a given item and returns the index.
Syntax:
tuple_name.index(value, start, end)
ØØ Tuples can be compared using comparison operators like <, >, = =, !=, etc.
ØØ In Python, comparison operators start by comparing the first element from each sequence. If they are
equal, it goes on to the next element until it finds the elements that differ. The subsequent elements are
not considered.
ØØ A tuple is deleted using del statement.
Oswaal CBSE Chapterwise & Topicwise Revision Notes, For Term-II, COMPUTER SCIENCE, Class – XI [ 5
Syntax:
del tuple_name
DICTIONARIES
Python Dictionary is an unordered collection of items where each item is a key-value pair.
ØØ A dictionary can be created by placing items inside curly braces { } separated by a comma.
Syntax:
<dictionary_name>={‘key1’:‘value1’, ‘key2’:‘value2’,…, ‘keyn’:‘valuen’}
ØØ To access elements in a dictionary, square brackets [ ] alongwith the key are used.
ØØ Traversing a dictionary means accessing each element of a dictionary.
Syntax:
for i in dictionary_name:
print(i, ‘:’, dictionary_name[i])
ØØ To add new elements to an existing dictionary
Syntax:
dictionary_name [‘key’] = ‘value’
Ø To modify existing key-value pair in a dictionary
Syntax:
dictionary_name [‘key’] = ‘value’
Ø To merge two dictionaries
Syntax:
dictionary_name.update(dictionary2)
• When two dictionaries are merged, the values of the same key are overwritten.
ØØ To remove an item from the dictionary
• Using del command
Syntax:
del dictionary_name[key]
• Using pop( ) method
Syntax:
dictionary_name.pop(key)
ØØ The users can check whether a particular key is present in a dictionary or not.
Using ‘in’ operator – returns “True” if the key is present in the dictionary, otherwise returns
“False”.
Using ‘not in’ operator – returns “True” if the key is not present in the dictionary, otherwise
returns “False”.
Syntax: <key> in/not in <dictionary_name>
ØØ Dictionary functions:
• len( ) – Returns the number of key-value pairs in the dictionary.
Syntax:
len(dictionary_name)
• clear( ) – Removes all items from the dictionary.
Syntax:
dictionary_name.clear( )
• get( ) – Returns the value of a given key in the dictionary.
Syntax:
dictionary_name.get(key)
• items( ) – Returns all the key-value pairs in the dictionary.
Syntax:
dictionary_name.items( )
6 ] Oswaal CBSE Chapterwise & Topicwise Revision Notes, For Term-II, COMPUTER SCIENCE, Class – XI
Chapter-2
Introduction to Python Module
ØØ A module is a Python object with arbitrarily named attributes that you can bind and reference. A module allows
you to logically organize your Python code.
ØØ In Python modules, we can define different functions, classes and variables.
ØØ All Python code for module are stored in a file named filename. py, where py is the extension of Python code file.
ØØ A module can contain executable statements as well as function definitions. These statements are intended to
initialize the module.
ØØ Modules can import other modules. It is mandatory but not required to place all import statements at the begin-
ning of a module.
ØØ Import STATEMENT
• import statement combines two operations : It searches for the named module, then it binds the results of
that search to a name in the local namespace.
• When a module is first imported, Python searches for the module python standard library and if found, it
creates a module object, initializing it.
• Syntax
• import module_ name
ØØ MATHEMATICAL FUNCTION
ØØ In Python, math module is used to perform mathematical functions. Definitions of all mathematical functions
are stored in math module.
ØØ To perform mathematical functions, we must import the math module.
ØØ Various mathematical functions are as follows
• sqrt ( ) If you want to find the square root of any number, sqrt ( ) function is used in Python.
Syntax
math.sqrt(num)
e.g. >>> import math
>>> num = math. sqrt (49)
>>> print (num)
7.0
>>> print (math. sqrt (–9))
Trackback (most recent call last) :
File “<pyshell# 27>”, line 1, in <module> print (math. sqrt(–9))
ValueError : math domain Error
• ceil() It is used to return ceiling value of any number. It gives smallest integer but not less than that number.
Syntax
Oswaal CBSE Chapterwise & Topicwise Revision Notes, For Term-II, COMPUTER SCIENCE, Class – XI [ 7
math. ceil (num)
e.g. >>> import math
>>> num = math. ceil (79.23)
>>> print (num)
80
>>> print (math. ceil (–25.46))
– 25
• floor ( ) It returns the value which is equal or less than given number.
Syntax
math. floor (number)
e.g. >>> import math
>>> num = math. floor (82.45)
>>> print (num)
82
>>> print (math. floor (–82.45))
– 83
• pow ( ) It returns x raised to the power y. In Python, there are two ways to perform this.
Syntax
pow (x, y) OR pow (x, y, mod)
When third argument is given python calculate x to the power of y modules z i.e., pow(x, y) % z
e.g. >>> import math
>>> a = 5
>>> b = 3
>>>num = pow (a, b)
>>> print (num)
125
>>>pow (5, 3, 20)
5
>>>pow (16, 2, 4)
0
• fabs ( ) It returns the positive floating point value of the number. This positive value is called absolute value.
Syntax
math. fabs (number)
e.g. >>> import math
>>> num = – 67
>>> math. fabs (num)
67.0
>>> print (math. fabs (49))
49.0
ØØ RANDOM MODULE/METHODS
This module is used to generate random number.
Various random methods are as follows
• random ( ) It returns a random floating point number between 0 and 1. Returned number will be in float.
Syntax
random. random ()
e.g. >>> import random
8 ] Oswaal CBSE Chapterwise & Topicwise Revision Notes, For Term-II, COMPUTER SCIENCE, Class – XI
Chapter-3
Society, Law and Ethics
ØØ DIGITAL FOOTPRINTS
• Whatever a person does on internet creates his image or we can say leaves a shadow behind that creates
his/her identity, this identity is called digital footprint.
• Digital footprint is nothing but the record of what a person does online.
• Digital footprint includes email you sent, information you shared, websites you visit and the activities you
took part online.
• Digital footprint is used for several reasons for example- marketers use your digital footprint to find out in
what kind of product user is interested and an interviewer what kind of activities the candidates perform
online. It gives better idea about the candidate’s personality.
ØØ There are two kinds of digital footprints:
1. Active digital footprint: When a user knowingly shares the personal data in order to share information
about the user by the means of social networking sites or other websites then it is known as active digital
footprint.
For example: When user makes a comment or posts something on social media.
2. Passive digital footprint: When the personal data of the user is collected without letting him know or col-
lection of personal data of user without the permission of him is known as passive digital footprint.
For example: when user visits any website then website traces his physical location using user ’s device IP
address.
ØØ DIGITAL SOCIETY AND NETIZEN
As our society is inclined towards using more and more digital technologies, we end up managing most of
our tasks digitally. In this era of digital society, our daily activities like communication, social networking,
banking, shopping, entertainment, education, transportation, etc., are increasingly being driven by online
transactions.
Digital society thus reflects the growing trend of using digital technologies in all spheres of human ac-
tivities. But while online, all of us need to be aware of how to conduct ourselves, how best to relate with
others and what ethics, morals and values to maintain. Anyone who uses digital technology along with
internet is a digital citizen or a netizen.
A responsible netizen must abide by net etiquettes, communication etiquettes and social media etiquettes.
1. Netiquettes
• As in real world, while communicating, socialising or interacting with others we need to follow certain
conventions and rules, in virtual world also, while using social media, sending e-mails or simple web surf-
ing, we need to follow certain rules and conventions called Netiquattes.
Importance of Netiquettes
• Netiquettes makes communications more effective.
• Following netiquettes makes our digital footprints positive.
• Following netiquettes will lower the cyber crime curve.
• Following netiquettes make web a better way to get information and convey our thoughts
• Netiquettes ensure careful word formation and also placing them at right place. Netiquettes also ensure
the correct use of emoticons.
10 ] Oswaal CBSE Chapterwise & Topicwise Revision Notes, For Term-II, COMPUTER SCIENCE, Class – XI
2. Communication Etiquettes
• Digital communication includes email, texting, instant messaging, talking on the cell phone, audio or
video conferencing, posting on forums, social networking sites, etc. All these are great ways to connect
with people in order to exchange ideas, share data and knowledge.
• Good communication over email, chat room and other such forums require a digital citizen to abide by the
communication etiquettes.
3. Social Media Etiquettes
• Social media are websites or applications that enable their users to participate in social networking by
creating and sharing content with others in the community. In the current digital era, we are familiar with
different kinds of social media and we may have an account on Facebook, Google, Twitter, Instagram,
Pinterest, or YouTube channel.
• Social media are websites or applications that enable their users to participate in social networking by cre-
ating and sharing content with others in the community. These platforms encourage users to share their
thoughts and experiences through posts or pictures. In this way users can interact with other online users
of those social media apps or channels.
• This is why the impact and outreach of social media has grown exponentially. It has begun to shape the
outcome of politics, business, culture, education and more. In social media too, there are certain etiquettes
we need to follow.
• Do not post personal comments.
• Courtiously post and tag photos.
• Don’t be reactive. You do not have to react to every post you see on social media.
• Don’t mispresent yourself.
Ø DATA PROTECTION
In this digital era, data or information protection is mainly about the privacy of data stored digitally. Ele-
ments of data that can cause substantial harm, embarrassment, inconvenience and unfairness to an indi-
vidual, if breached or compromised, is called sensitive data.
All over the world, each country has its own data protection policies (laws). These policies are legal docu-
ments that provide guidelines to the user on processing, storage and transmission of sensitive informa-
tion. The motive behind implementation of these policies is to ensure that sensitive information is appro-
priately protected from modification or disclosure.
1. Intellectual Property Right (IPR): Intellectual Property refers to the inventions, literary and artistic ex-
pressions, designs and symbols, names and logos. The ownership of such concepts lies with the creator, or
the holder of the intellectual property. This enables the creator or copyright owner to earn recognition or
financial benefit by using their creation or invention.
Intellectual Property is legally protected through copyrights, patents, trademarks, etc.
(A) Copyright: Copyright grants legal rights to creators for their original works like writing, photograph,
audio recordings, video, sculptures, architectural works, computer software, and other creative works
like literary and artistic work. Copyright law gives the copyright holder a set of rights that they alone can
avail legally. The rights include right to copy (reproduce) a work, right to create derivative works based
upon it, right to distribute copies of the work to the public, and right to publicly display or perform the
work. It prevents others from copying, using or selling the work.
(B) Patent: A patent is usually granted for inventions. When a patent is granted, the owner gets an exclusive
right to prevent others from using, selling, or distributing the protected invention. Patent gives full con-
trol to the patentee to decide whether or how the invention can be used by others. Thus it encourages
inventors to share their scientific or technological findings with others. A patent protects an invention for
20 years, after which it can be freely used.
(C) Trademark: Trademark includes any visual symbol, word, name, design, slogan, label, etc., that distin-
guishes the brand or commercial enterprise, from other brands or commercial enterprises.
Violation of IPR
Violation of intellectual property right may happen in one of the following ways:
(A) Plagiarism: Presenting someone else’s idea or work as one’s own idea or work is called plagiarism. If
we copy some contents from Internet, but do not mention the source or the original creator, then it is
considered as an act of plagiarism. It is a serious ethical offense and sometimes considered as an act of
fraud.
(B) Copyright Infringement: Copyright infringement is when we use other person’s work without obtaining
their permission to use or we have not paid for it, if it is being sold.
(C) Trademark Infringement: Trademark Infringement means unauthorized use of other ’s trademark on
products and services. An owner of a trademark may commence legal proceedings against someone who
infringes its registered trademark.
Oswaal CBSE Chapterwise & Topicwise Revision Notes, For Term-II, COMPUTER SCIENCE, Class – XI [ 11
2. Licensing
A license is a type of contract or a permission agreement between the creators of an original work per-
mitting someone to use their work, generally for some price; whereas copyright is the legal rights of the
creator for the protection of original work of different types.
Licensing is the legal term used to describe the terms under which people are allowed to use the copy-
righted material.
3. Open Source Software
Copyright sometimes puts restriction on the usage of the copyrighted works by anyone else. If others are
allowed to use and built upon the existing work, it will encourage collaboration and would result in new
innovations in the same direction. Licenses provide rules and guidelines for others to use the existing
work.
When authors share their copyrighted works with others under public license, it allows others to use and
even modify the content. Open source licenses help others to contribute to existing work or project with-
out seeking special individual permission to do so.
Free and Open Source Software (FOSS) has a large community of users and developers who are contribut-
ing continuously towards adding new features or improving the existing features.
Two popular categories of public licenses are
(i) GNU General Public License (GPL): GPL is primarily designed for providing public license to software.
GNU GPL is another free software license, which provides end users the freedom to run, study, share and
modify the software, besides getting regular updates. Users or companies who distribute GPL licensed
works may charge a fee for copies or give them free of charge.
(ii) Creative Commons (CC): CC is used for all kind of creative works like websites, music, film, literature,
etc. CC enables the free distribution of an otherwise copyrighted work. It is used when an author wants
to give people the right to share, use and build upon a work that they have created.
Ø CYBER CRIME
Ø Cybercrime is a criminal act facilitated by use of electronic gadgets and information systems through
internet.
Ø Cybercrimes are carried out against either an individual, or a group, or an organization or even against
a country, with the intent to directly or indirectly cause physical harm, financial loss or mental harass-
ment.
1. Hacking
Hacking is the act of unauthorized access to a computer, computer network or any digital system. Hackers
usually have technical expertise of the hardware and software. Hacking is of two types. Ethical hacking
and Non-ethical hacking
• Hacking, when done with a positive intent, is called ethical hacking. Such ethical hackers are known as
white hat hackers. They are specialists in exploring any vulnerability or loophole during testing of the
software. Thus, they help in improving the security of software. Ethical hacking is actually preparing
the owner against any cyber-attack.
• A non-ethical hacker is the one who tries to gain unauthorized access to computers or networks in or-
der to steal sensitive data with the intent to damage or bring down systems. They are called black hat
hackers or crackers. Their primary focus is on security cracking and data stealing.
2. Eavesdropping
Eavesdropping is as an electronic attack where digital communications are intercepted by an individual
for whom they are not intended.An eavesdropping attack occurs when a hacker intercepts, deletes, or
modifies data that is transmitted between two devices. Eavesdropping, also known as sniffing or snoop-
ing, relies on unsecured network communications to access data in transit between devices.
3. Phishing and Fraud Emails
Phishing is an unlawful activity where fake websites or emails that look original or authentic are present-
ed to the user to fraudulently collect sensitive and personal details, particularly usernames, passwords,
banking and credit card details.
The most common phishing method is through email spoofing where a fake or forged email address is
used and the user presumes it to be from an authentic source.
4. Ransomware
This is another kind of cybercrime where the attacker gains access to the computer and blocks the user
from accessing, usually by encrypting the data. Ransomware can get downloaded when the users visit
any malicious or unsecure websites or download software from doubtful repositories. Some ransomware
are sent as email attachments in spam mails. It can also reach our system when we click on a malicious
advertisement on the Internet.
Preventing Cyber Crime
• Take regular backup of important data.
12 ] Oswaal CBSE Chapterwise & Topicwise Revision Notes, For Term-II, COMPUTER SCIENCE, Class – XI