XI-CS Material 2023-24
XI-CS Material 2023-24
XI-CS Material 2023-24
1. Learning Outcomes
Students should be able to:
a) develop basic computational thinking
b) explain and use data types
c) appreciate the notion of algorithms
d) develop a basic understanding of computer systems- architecture, operating
system, and cloud computing
e) explain cyber ethics, cyber safety, and cybercrime
f) understand the value of technology in societies along with consideration of gender
and disability issues.
2. Distribution of Marks
Theory Practical
Total 70 110 70
● Digital Society and Netizen: net etiquettes, communication etiquettes, social media
étiquettes
● Data Protection: Intellectual property rights (copyright, patent , trademark), violation of
IPR(plagiarism, copyright infringement, trademark infringement), open source software and
licensing (Creative Commons, GPL and Apache)
● Cyber Crime: definition, hacking, eavesdropping, phishing and fraud emails, ransomware,
cyber trolls, cyber bullying
● Cyber safety: safely browsing the web, identity protection, confidentiality
● Malware: viruses, trojans, adware
● E-waste management: proper disposal of used electronic gadgets.
● Information Technology Act (IT Act)
● Technology and society: Gender and disability issues while teaching and using computers
4. Practical
S.No. Unit Name Marks (Total=30)
1. Lab Test (12 marks)
Python program (60% logic + 20% documentation + 20%code 12
quality)
* 12345 A AB
** 1234 ABC
*** 123 ABCD
**** 12 ABCDE
***** 1
● Write a program to input the value of x and n and print the sum of the following series:
⮚ 1 + 𝑥 + 𝑥2 + 𝑥3 + 𝑥4 + ⋯ 𝑥𝑛
⮚ 1 − 𝑥 + 𝑥2 − 𝑥3 + 𝑥4 − ⋯ 𝑥𝑛
𝑥2 𝑥3 𝑥4 𝑥𝑛
⮚ 𝑥+ + + +⋯
2 3 4 𝑛
𝑥2 𝑥3 𝑥4 𝑥𝑛
⮚ 𝑥+ + + +⋯
2! 3! 4! 𝑛!
A computer is an electronic device, under the control of instructions stored in its memory that can
accept data (input), process the data according to specified rules(Program) on processor & produces
information (output), and store the information for future use.
Data vs Information
Data are raw numbers or other findings which, by themselves, are of limited value.Information is data
that has been converted into a meaningfuland useful context.Computers are being used extensively
nowadays in
everyday life/every field
In the form of laptop, desktop, smartphone,gadgets etc.
Advantages of computer
• Speed
• Accuracy
• Huge storage
• Versatility
• Tirelessness
Disadvantages of computer
• Data security issue
• Computer crimes
• Health risk
• Bad impact on environment if not properly disposed off
Memory Types
Primary Memory
Random Access Memory (RAM) - is a type of volatile memory that is stores information on an
integrated circuit which hold the data mainly when the program is being executed by the CPU. As it is
volatile in nature so it can't store data permanently.
Read Only Memory (ROM) - a non-volatile memory chip in which data are stored permanently, and
can not be altered by
Cache Memory - is the volatile computer memory which is very nearest to the CPU,so also called CPU
memory, and is between CPU and RAM all the Recent Instructions are Stored into the Cache Memory. It
is the fastest memory that provides high-speed data access to a computer microprocessor.
MCQ
1. Smallest measurement unit of computer memory is?
(a) Megabyte
(b) Bit
(c) Byte
Boolean Logic
Because of computer understands machine language(0/1) which is binary value so every operation is
done with the help of these binary value by the computer.
To understand boolean logic properly we have to understand Boolean logic rule,Truth table and logic
gates
Boolean Logic rules
Boolean Algebra is the mathematics we use to analyse digital gates and circuits. We can use these
“Laws of Boolean” to both reduce and simplify a complex Boolean expression in an attempt to reduce
the number of logic gates required.
A +1=1 Annulment
A +0=A Identity
A .1=A Identity
A.0 =0 Annulment
A +A=A Idempotent
A .A=A Idempotent
NOTA=A Double Negation
A +A =1 Complement
A .A =0 Complement
A+B=B+A Commutative
A.B =B.A Commutative
A+B =A.B deMorgan’sTheorem
A.B=A+B deMorgan’sTheorem
Boolean Expression
A Boolean expression is a logical statement that is either TRUE or FALSE .
A Boolean expression can consist of Boolean data, such as the following:
* BOOLEAN values (YES and NO, and their synonyms, ON and OFF, and TRUE and FALSE)
* BOOLEAN variables or formulas
* Functions that yield BOOLEAN results
De Morgan’s Law
The complement of the union of two sets is equal to the intersection of their complements and the
complement of the intersection of two sets is equal to the union of their complements. These are called
De Morgan’s laws.
For any two finite sets A and B
(i) (A+B)’=A’.B’
(ii) (A . B)’=A’+B’
Truth table
A truth table is a mathematical table used in logic. e.g.
Logic Gates
Logic gate is an idealized or physical device implementing a Boolean function. These are used to
construct logic circuit.
Universal gates are the logic gates which are capable of implementing any Boolean function without
requiring any other type of gate.
Types of Universal Gates-
In digital electronics, there are only two universal gates which are-
1. NAND Gate
2. NOR Gate
Number System & Encoding Schemes
In general term computer represent information in different types of data forms i.e. number , character
,picture ,audio , video etc.
Computers are made of a series of switches/ gates. Each switch has two states: ON(1) or OFF(0).That's
why computer works on the basis of binary number system(0/1).But for different purpose different
number systems are used in computer world to represent information. E.g. Octal, Decimal, Hexadecimal.
CONVERSIONS
DECIMAL TO OTHER
1. DECIMAL TO BINARY
Decimal Number System to Other Base
To convert Number system from Decimal Number System to Any Other Base is quite easy;you
have to follow just two steps:
A) Divide the Number(Decimal Number)by the base of target base system(in which you want to
convert the number:Binary (2),octal (8)and Hexadecimal(16)).
B) Write the remainder from step1 as a Least Signification Bit(LSB)to Step last as a Most
significant Bit(MSB).
Decimal to Binary Conversion Result
Decimal Number is :
(12345)10
BinaryNumberis
(11000000111001)2
2. DECIMAL TO OCTAL
Decimal to Octal Conversion Result
Octal Number is
(30071)8
3. DECIMAL TO HEXADECIMAL
Decimal to Hexadecimal Result
Conversion
Example1
Hexadecimal Number
is(3039)16
Example2
Hexadecimal Number is
Decimal Number is:(725)10
(2D5)16
Convert
10,11,12,13,14,15
To its equivalent...A,B,C,D,E,F
BINARY TO OTHER
A)Multiply thedigit with 2(with place value exponent).Eventually add all the multiplication
becomes the Decimal number.
1. BINARY TODECIMAL
2. BINARY TO OCTAL
An easy way to convert from binary to octal is to group binary digits into sets of three, starting with
the least significant (rightmost)digits.
Binary:11100101 11 100 101
=
011 100 101 Pad the most significant digits with zeros
if necessary to complete a group of three.
Octal: 0 1 2 3 4 5 6 7
Octal = 3 4 5 = 345oct
3. BINARYTOHEXADECIMAL
An equally easy way to convert from binary to hexadecimal is to group binary digits into sets off
our,starting with the least significant (rightmost)digits.
Binary:11100101 =11100101
Hexadecimal: 0 1 2 3 4 5 6 7
Hexadecimal: 8 9 A B C D E F
OCTAL TO OTHER
1. OCTAL TO BINARY
Converting from octal to binary is as easy as converting from binary to octal. Simply lookup each
octal digit to obtain the equivalent group of three binary digits.
Octal: 0 1 2 3 4 5 6 7
2. OCTALTOHEXADECIMAL
When converting from octal to hexadecimal, it is often easier to first convert the octal number
into binary and then from binary into hexadecimal. For example, to convert 345octal into hex:
Octal = 3 4 5
Drop any leading zeros or pad with leading zeros to get groups of four binary digits
(bits):Binary 011100101=11100101
3. OCTALTODECIMAL
The conversion can also be performed in the conventional mathematical way,by showing
each digit place as an increasing power of 8.
HEXADECIMAL TO OTHER
1. HEXADECIMALTO BINARY
Converting from hexadecimal to binary is as easy as converting from binary to
hexadecimal.Simply lookup each hexadecimal digit to obtain the equivalent group off our
binary digits.
Hexadecimal: 0 1 2 3 4 5 6 7
Hexadecimal: 8 9 A B C D E F
2. HEXADECIMAL TO DECIMAL
3. HEXADECIMALTOOCTAL
ENCODING SCHEMES
In the early 1960s, computers had no way of communicating with each other due to different
ways of representing keys of the keyboard. Hence, the need for a common standard was realised
to overcome this shortcoming. Thus, encoding scheme ASCII was developed for standardising the
character representation. ASCII is still the most commonly used coding scheme.
Initially ASCII used7 bit store present characters. Recall that there are only binary
digits(0or1).Therefore, total number of different character son the English keyboard that can be
encoded by 7-bit ASCII code is 27 = 128. Following Table shows some printable characters for
ASCII code. But ASCII is able to encode character set of English language only.
Indian Script Code for Information Interchange(ISCII)
In order to facilitate the use of Indian languages on computers, a common standard for coding
Indian scripts called ISCII was developed in India during mid1980s.
It is an 8-bit code representation for Indian languages which means it can represent
28=256characters.It retainsall 128 ASCII codes and uses rest of the codes(128)for additional
Indian language character set. Additional codes have been assigned in the upper region (160–
255)for the ‘aksharas’ of the language.
UNICODE
There were many encoding schemes, for character sets of different languages. But they were not
able to communicate with each other, as each of them represented characters in their own ways.
Therefore, a standard called UNICODE has been developed to incorporate all the characters of
every written language of the world. Commonly used UNICODE encodings are UTF-8, UTF-16 and
UTF-32.
MCQ
2.3 Coding
• After finalising the algorithm, we need to convert the algorithm into the
format which can be understood by the computer to generate the
desired solution.
2.4 Testing and Debugging
• The program created should be tested on various parameters.
• The program should meet the requirements of the user.
• In the presence of syntactical errors, no output will be obtained.
• In case the output generated is in correct, then the program should be
checked for logical errors, if any.
3. Algorithm
Algorithm is the step by step procedure for solving the problem. Suppose following are
the steps required for an activity ‘riding a bicycle’:
• Remove the bicycle from the stand,
• Sit on the seat of the bicycle,
• Start peddling,
• Use breaks when ever needed and
• Stop on reaching the destination.
Example:
Algorithm to find square of anumber.
Step1: Input a number and store it to num
Step 2: Compute num * num and store
it in square
Step 3:Print square
4. Representation of Algorithms
There are two common methods of representing an algorithm —flowchart and
pseudocode. Either of the methods can be used to represent an algorithm while keeping
in mind the following:
• it show cases the logic of the problem solution, excluding any
implementational details
• it clearly reveals the flow of control during execution of the program
4.1 Flowchart —Visual Representation of Algorithms
• A flow chart is a visual representation of an algorithm.
• A flowchart is a diagram made up of boxes, diamonds and other shapes,
connected by arrows.
Flow chart to calculate square of a number
4.2 Pseudocode
A pseudocode (pronounced Soo-doh-kohd) is another way of representing an algorithm. It is considered as
a non-formal language that helps programmers to write algorithm. The word“pseudo” means “not real,” so
“pseudocode” means “not real code”. Following are some of the frequently used keywords while writing
pseudocode:
• INPUT/•COMPUTE/•PRINT/•INCREMENT/•DECREMENT
• IF/ELSE,•WHILE,•TRUE/FALSE
Example:
Pseudo code for the sum of two numbers will be:
Input num1
input num2
COMPUTE Result = num1 + num2
PRINT Result
4.3 Coding
• Once analgorithm is finalised,it should be coded in ahigh-level
programming language as selected by the programmer.
• The ordered set of instructions are written in that programming language
by following its syntax.
• Syntax is the set of rules or grammar that governs the formulation of the
statements in the language,such as spellings,order of words,
punctuation,etc.
4.4 Decomposition
• The basic idea of solving a complex problem by decomposition is to
'decompose' or break down a complex problem into smaller sub problems.
1. Write pseudo code and draw flow chart to accept number still the user enters
and then find their average.
2. Write a pseudocode and draw a flowchart where multiple conditions are
checked to categorize a person as either child(<13), teenager(>=13but<20)
or adult(>=20),based on age specified:
3. Write an algorithmth at accepts four numbers as input and find the largest
and smallest of them.
PYTHON PROGRAMMING FUNDAMENTAL:
To write and run (execute) a Python program, we need to have a Python interpreter installed on our
computer or we can use any online Python interpreter. The interpreter is also called Python shell. A
sample screen of Python interpreter is shown in Figure:
In the above screen, the symbol >>> is the Python prompt, which indicates that the interpreter is
ready to take instructions. We can type commands or statements on this prompt to execute them
using a Python interpreter.
Interactive mode allows execution of individual statement instantaneously. Whereas, Script mode
allows us to write more than one instruction in a file called Python source code file that can be executed.
To work in the interactive mode, we can simply type a Python statement on the >>> prompt directly.
As soon as we press enter, the interpreter executes the statement and displays the result(s), as shown in
Figure:
Working in the interactive mode is convenient for testing a single line code for instant execution. But
in the interactive mode, we cannot save the statements for future use and we have to retype the
statements to run them again.
(B) Script Mode
In the script mode, we can write a Python program in a file, save it and then use the interpreter to
execute it. Python scripts are saved as files where file name has extension “.py”. By default, the Python
scripts are saved in the Python installation folder. To execute a script, we can either:
a) Type the file name along with the path at the prompt. For example, if the name of the file is prog5-
1.py, we type prog5-1.py. We can otherwise open the program directly from IDLE.
b) While working in the script mode, after saving the file, click [Run]->[Run Module] from the menu
as shown in Figure below.
Basic DataTypes:
• Integers (default for numbers)- Number without decimal point
z=5/2 # Answer 2.5, integer division
• Floats : Number with decimal Point
x = 3.456
• Strings -
Can use “” or ‘’ to specify with “abc” == ‘abc’
Use triple double-quotes for multi-line strings or strings than contain both ‘ and “ inside of
them:
“““a‘b“c”””
Comments :
• Comments are very important while writing a program. It describes what's going
on inside a program so that a person looking at the source code does not have a
hard time figuring it out.
• In Python, we use the hash (#) symbol to start writing a comment.
• If we have comments that extend multiple lines, one way of doing it is to use hash
(#) in the beginning of each line.
• For example:
• Another way of doing this is to use triple quotes, either ''' or """.
• These triple quotes are generally used for multi-line strings. But they can be used
as multi-line comment as well.
"""This is also a
perfect example of
multi-line comments"""
Assignment :
• Binding a variable in Python means setting a name to hold a reference to some object
Assignment creates references, not copies
• Names in Python do not have an intrinsic type, objects have types
Python determines the type of the reference automatically based on what data is assigned to
it
• You create a name the first time it appears on the left side of an assignment expression:
x=3
• A reference is deleted via garbage collection after any names bound to it have passed out of
scope
• Python uses reference semantics (more later)
• You can assign to multiple names at the same time
>>> x, y = 2, 3
>>> x
2
>>> y
3
>>> x, y = y, x
>>> a = b = x = 2
Python keywords
Reserved words in the library of a language.There are 3 3keywords in python.
Identifier
and, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global,
if, import, in, is, lambda, not, or, pass, print, raise, return, try, while
Program : Write a program to display values of variables in Python.
Output:
Hello
Program : Write a Python program to find the area of a rectangle given that its length is 10 units and
breadth is 20 units.
Output: 200
Do it yourself:
1. Write a Python program to find the sum and subtract of two numbers
2. Find the simple interest. Principle amount, rate of interest and time given by user.
Constants
• A constant is a type of variable whose value cannot be changed.
• It is helpful to think of constants as containers that hold information which cannot be changed
later.
Literals
• Literals
• Literal is a raw data given in a variable or constant. In Python, there are various types of
literals they are as follows:
• Numeric Literals
• Numeric Literals are immutable (unchangeable). Numeric literals can belong to 3
different numerical types Integer, Float and Complex.
• a = 0b1010 #Binary Literals
• b = 100 #Decimal Literal
• c = 0o310 #Octal Literal
• d = 0x12c #Hexadecimal Literal
• #Float Literal
• float_1 = 10.5
• float_2 = 1.5e2
• #Complex Literal
• x = 3.14j
• print(a, b, c, d)
• print(float_1, float_2)
• print(x, x.imag, x.real)
OUTPUT
10 100 200 300
10.5 150.0
3.14j 3.14 0.0
In programming, data type is an important concept. Variables can store data of different types, and
different types can do different things. Python has the following data types built-in by default, in
these categories:
Str
>>> num1 = 10
>>> type(num1)
<class 'int'>
>>> num2 = -1210
>>> type(num2)
<class 'int'>
>>> var1 = True
>>> type(var1)
<class 'bool'>
Operators
An operator is used to perform specific mathematical or logical operation on values. The values that
the operators work on are called operands. For example, in the expression 10 + num, the value 10, and
the variable num are operands and the + (plus) sign is an
operator. Python supports several kinds of operators whose categorisation is briefly explained in this
section
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
Concatenation
Concatenating means obtaining a new string that contains both of the original strings. In Python, there
are a few ways to concatenate or combine strings. The new string that is created is referred to as a
string object. In order to merge two strings into a single object, you may use the + operator.
For Example
>>>”CBSE “+”India”
Output is CBSEIndia
Replication. : The multiplication operator acts as a replication operator when we have one string
and one integer as operands. What is replication? First, understand the meaning of the word
replication.
>>>”CBSE” 3
Output is CBSECBSECBSE
Statement
In Python, a statement is a unit of code that the Python interpreter can execute.
Example
>>> x = 4 #assignment statement
>>> cube = x ** 3 #assignment statement
>>> print (x, cube) #print statement
4 64
• Multi-line statement
In Python, end of a statement is marked by a newline character. But we can make a statement
extend over multiple lines with the line continuation character (\).
For example:
a=1+2+3+\
4+5+6+\
7+8+9
Input and Output
Sometimes, a program needs to interact with the user’s to get some input data or information from
the end user and process it to give the desired output. In Python, we
have the input() function for taking the user input. The input() function prompts the user to enter data.
It accepts all user input as string. The user may enter a number or a string but the input() function treats
them as strings only. The syntax for input() is:
input ([Prompt])
Example
>>>fname = input("Enter your first name: ")
Enter your first name: Arnab
>>> type(age)
<class 'str'>
Example
Example
Statement Output
print("Hello") Hello
print(10*2.5) 25.0
print("I" + "love" + "my" + "country") Ilovemycountry
print("I'm", 16, "years old") I'm 16 years old
More Examples:
print(1,2,3,4)
# Output: 1 2 3 4
print(1,2,3,4,sep='*')
# Output: 1*2*3*4
print(1,2,3,4,sep='#',end='&')
# Output: 1#2#3#4&
Type Conversion
The process of converting a Python data type into another data type is known as type conversion.
There are mainly two types of type conversion methods in Python: implicit type conversion and explicit
type conversion
Explicit Conversion
Explicit conversion, also called type casting happens when data type conversion takes place because
the programmer forced it in the program. The general form of an explicit data type conversion is:
(new_data_type) (expression)
With explicit type conversion, there is a risk of loss of information since we are forcing an expression
to be of a specific type. For example, converting a floating value of x = 20.67 into an integer type, i.e.,
int(x) will discard the fractional part .67. Following are some of the functions in Python that are used
for explicitly converting an expression or a variable to a different type.
Function Description
int(x) Converts x to an integer
float(x) Converts x to a floating-point number
str(x) Converts x to a string representation
chr(x) Converts x to a character
Program of explicit type conversion from int to float.
#Explicit type conversion from int to float
num1 = 10
num2 = 20
num3 = num1 + num2
print(num3)
print(type(num3))
num4 = float(num1 + num2)
print(num4)
print(type(num4))
Output:
30
<class 'int'>
30.0
<class 'float'>
Implicit Conversion
Implicit conversion, also known as coercion, happens when data type conversion is done
automatically by Python and is not instructed by the programmer.
Output:
30.0
<class 'float'>
MCQ:
Q.1 Who developed the Python language?
a) Zim Den
b)Wick van Rossum
c) Guido van Rossum
d) NieneStom
a) 1
b) 0
c) 1
d) 3
Answers :
Q.4. C Q.5. D
Practice Questions
1. Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water
boils at 100 degree C and freezes as 0 degree C, use the program to find out what is the boiling
point and freezing point of water on the Fahrenheit scale.
(Hint: T(°F) = T(°C) × 9/5 + 32)
2. Write a Python program to calculate the amount payable if money has been lent on simple
interest. Principal or money lent = P, Rate of interest = R% per annum and Time = T years.P,R,T
are given by user. Then Simple Interest (SI) = (P x R x T)/ 100.
3. Amount payable = Principal + SI
4. Write a program to enter two integers and perform all arithmetic operations on them.
Syntax Errors
Python has its own rules that determine its syntax. The interpreter
interprets the statements only if it is syntactically (as per the rules of
Python) correct. For example, parentheses must be in pairs, so the
expression (10 + 12) is syntactically correct, whereas (7 + 11 is not due
to absence of right parenthesis. Such errors need to be removed before
the execution of the program
Logical Errors
Logical errors are also called semantic errors as they occur when the
meaning of the program (its semantics) is not correct.For example, if
we wish to find the average of two numbers 10 and 12 and we write
the code as 10 + 12/2, it would run successfully and produce the result
16. Surely, 16 is not the average of 10 and 12. The correct code to find
the average should have been (10 + 12)/2 to give the correct output as
11.
Runtime Error
Output : a is greater
if-else statement
The statements inside the if block are executed only when condition is True,
otherwise the statements in the else block are executed.
Syntax
if <condition>:
Statement(s)
else:
statements
Flow Chart
Example:
a=5
b=6
if a < b :
print(‘b is greater’)
else:
print(‘a is greater’)
Output : b is greater
if elif statement
The if...elif...else statement allows you to check for multiple test expressions and execute
different codes for more than two conditions.
FlowChart
Example :
if 51<5:
print("False, statement skipped")
elif 6<5:
print("False, statement skipped")
elif 0<3:
print("true, block will execute")
else:
print("If all fails.")
output : true, block will execute
48
Iteration statements
Iteration statements(loop) are used to execute a block of statements as long as the condition
is true.
Python Iteration (Loops) statements are of three type:-
1. while Loop
2. for Loop
WHILE LOOP
It is used to execute a block of statement if a given condition is true. And when the
condition become false, the control will come out of the loop. The condition is checked
every time at the beginning of the loop.
Syntax
while(condition) :
[statement]
Example :
count =0
while(count <2):
count=count +1
print("Hello")
Output : Hello
Hello
FOR LOOP
49
Example:
for i in [1,2,3,4,5]:
print(i*5)
OUTPUT:
5
10
15
20
25
range() Function
This function generates a sequence of numbers based on the parameters passed.
Parameters
start: Starting number of the sequence.
stop: Generate numbers up to, but not including this number.
step(Optional): Determines the increment between each numbers in the sequence.
Python use range() function in three ways:
a. range(stop) : By default, It starts from 0 and increments by 1 and ends upto
stop, but not including stop value.
fori inrange(5):
print(i, end=" ")
Output : 0 1 2 3 4
b.range(start,stop) : It starts from the start value and upto stop, but not
including stop value.
fori inrange(5, 10):
print(i, end=" ")
Output : 5 6 7 8 9
c. range(start,stop,step): Third parameter specifies to increment or decrement the
value by adding or subtracting the value.
fori inrange(0, 10, 2):
print(i, end=" ")
Output : 0 2 4 6 8
BREAK STATEMENT
It is used to terminate the loop.
50
Example
for val in "string":
if val == "i":
break
print(val, end=””)
print("The end")
Output: s t r The end
CONTINUE STATEMENT
• Used to skip the rest of the statements of the current loop block and to move
to next iteration, of the loop.
• Continue will return back the control to the beginning of the loop.
Example
for letter in ‘Python’:
if letter == ‘h’:
continue
print (letter)
Output
Pyton
Nested Loops
Nested loops mean loops inside a loop. For example, while loop inside the for loop, for loop
inside the for loop, etc.
51
SOLVED QUESTIONS
MCQ ( 1 mark )
1. 1
2. 2
3. Error
4. 12
Ans : 2. 2
52
Q4 : Which keyword is used to terminate the looping in Python when certain condition is
met ?
1. Break
2. Continue
3. Raise
4. Pass
Ans 1. Break
1. 1 2
2. 1 2 3
3. Error
4. None of the mentioned
Ans : 1. 1 2
Q 6 : Which of the following sequences would be generated in the given line of code?
range (5,0, -2)
1. 5 4 3 2 1 0 -1
2. 5 3 1 -1
3. 5 3 1
4. 5 3
5.
Ans : 3. 5 3 1
53
Very Short Answer type Questions ( 2 marks )
Q1 : Find output
x=True
y=False
z=False
if x or y and z:
print("YES")
elif x and y or z:
print("yes")
else:
print("no")
Ans : no
Ans : 128
54
Q5 . Write a Python program that accepts two integers from the user and prints a
message saying if first number is divisible by second number or if it is not?
Ans:
x=int(input(“enter first number”))
y=int(input(“enter second number”))
if(X%Y ==0):
print(x, “is divisible by”,y)
else :
print(x,”is not divisible by “ , y)
Q 1 Write a program to print grade of a student as per input percentage as per criteria
given below:-
Percentage range Grade
>=90 A
75<=89 B
60<=74 C
40<=59 D
>=40 E
55
Ans:
perc= int(input(“enter percentage”))
if(perc>=90):
Print(“ grade A”)
elif(perc>=75 and perc< 89 ) :
Print ( “ grade B “)
elif( perc>= 60 and perc< 74 ) :
Print(“grade C”)
elif(perc>=40 and perc< 60):
Print(“grade D”)
else:
Print(“E”)
Ans :
a=int(input ("Enter First Number ?"))
b=int(input("Enter First Number ?"))
c=int(input("Enter First Number ?"))
if (a>b) and (a>c) :
print ("Max number is ",a)
if (b>a) and (b>c) :
print ("Max number is ",b)
if (c>a) and (c>b) :
print ("Max number is ",c)
Q2. Q1 Write python code to Generate following pattern using Nested loop
*
**
***
****
*****
Ans :
n = int(input("Enter the number of rows"))
# outer loop to handle number of rows
56
for i in range(0, n):
for j in range(0, i + 1):
print("* ", end="")
# ending line after each row
print()
Unsolved questions :
MCQs
Q1 : How do we differentiate the body of the loop from the rest of the code?
Q3 : The statement skips the rest of the loop statements and causes the next
iteration of the loop to take place.
1. Break
2. Continue
3. Raise
4. Pass
57
VSA ( 2marks )
Q2 . Find Output
i=0
while (i<10):
i=i+1
if i==5:
break
print(i,end=” “)
SA ( 3 marks)
Q1. Write a program to find sum of all even numbers from 1 to 100.
Q2.Write a program which accept Sales Amount from user then calculate and print discount
amount per following criteria :
Sales Amount Discount
Less than 5000 5% of Sales Amount
5001 to 10000 7% of sales Amount
More than 10000 10% of Sales Amount
(e.g. if Sales amount is 400 then Discount amount would be 400*5/100 i.e. 20)
58
LA ( 5 marks )
Q1 Write a python program to accept age of a person from user and check whether he
has completed 18 years or more. If yes print ‘Eligible for Voting’ or otherwise print ‘Minor’.
Q2 Write a program in python to print the table of a number given by the user using
for loop
STRING MANIPULATION
Strings: Sequence of characters that is enclosed in single or double quotes referred as String.
Strings are immutable. Various string operations are as follows:-
59
find() str.find (sub, start, end) It is used to search the first occurrence
of the substring in the given string.
replace() str.replace (old, new) It replaces all the occurrences of the
old string with the new string.
index() index(substr, start, end) It also searches the first occurrence
and returns the lowest index of the
substring.
lower() str,lower () It converts the string into lowercase
islower() str.islower () It returns True if all the letters in the
string are in lowercase otherwise false
upper() str.upper() It converts the string into uppercase
isupper() str.isupper () It returns True if all the letters in the
string are in uppercase otherwise
false.
isalpha() str.isaplha () It checks for alphabets in an inputted
string and returns True in string
contains only letters else false.
isalnum() str.isanum () It returns True if all the characters are
alphanumeric else false.
isdigit() str.sidigit () It returns True if the string contains
only digits, otherwise false.
lstrip() str.istrip(chars) It returns the string after removing the
str.istrip() space from the left of the string
rstrip() str.restrip(chars) It returns the string after removing the
str.rstrip() space from the right of the string
strip() str.strip() It returns the string after removing the
space from the both side of the string
index() str.index(substring) It returnsthe index position of an
element or an item in a string of
characters or a list of items.
startswith() string.startswith(substring, It returns True if the string starts with
start, end) the given substring, and False
otherwise.
partition() str.partition(separator) It splits a given string into three parts
based on the first occurrence of a
specified separator. It returns a tuple
containing the three parts: the portion
before the separator, the separator
itself, and the portion after the
separator.
join() It is used to concatenate elements
separator.join(iterable) from an iterable (like a list or tuple)
into a single string, with a specified
separator between each element.
endswith() string.endswith(substring, It returns True if the string ends with
start, end) the given substring, and False
otherwise.
60
MULTIPLE CHOICE QUESTIONS (MCQ)-1 Mark
3 Which of the following functions will return the total number of characters in a
string?
count () b) index() c) len() d) all of these
4 Which of the following functions will return the last three characters of a string
s?
s[3: ] b) s[ : 3] c) s[-3: ] d) s[ : -3]
5 Which of the following functions will raise an error if the given substring is not
found in the string ?
a) find() b) index() c) replace() d) all of these
6 Which of the following functions removes all leading and trailing spaces from a
string ?
a) lstrip() b) rstrip() c) strip() d) all of these
7 Find the operator which cannot be used with a string in Python from the
following:
(a) + (b) not in (c) * (d) //
8 What will be the output of above Python code?
str1= “6/4”
print(“str1”)
a) 1 b) 6/4 c) str1 d (1.5)
61
a) formatb) formation c) orma d) ormat
12 What will be the output of below Python code?
str1="Aplication"
str2=str1.replace('a','A')
print(str2)
a) application b) Application c) ApplicAtion d) applicAtion
13 What will be the output of below Python code?
str1=”power”
str1.upper( )
print(str1)
a) POWER b) Power c) power d) power
b)
a) print(str1[-7:-12]) b) print(str1[-11:-7])
c) print(str1[-11:-6]) d) print(str1[-7:-11])
62
ANSWER (1 MARK- MULTIPLE CHOICE QUESTIONS (MCQ)
1 c 11 a
2 a 12 c
3 c 13 a
4 c 14 c
5 b 15 a
6 c 16 a
7 d 17 c
8 c 18 b
9 b 19 a
10 b 20 d
VeryShortanswerTypeQuestions
Q1.Which of the following is not a Python legal string operation?
a) ‟abc‟+‟abc‟ (b)„abc‟*3
b) (c)‟abc‟+3 (d)‟abc‟.lower()Ans:
Ans. (c)‗abc‘+3
Q2. Out of the following operators ,which one scan be used with strings?
=,-,*,/,//,%,>,<>,in, not in,<=
Ans: /,// and %
Q3. From the string S=“CARPEDIEM”.Which ranges return“DIE”and“CAR”?
Ans. S[6:9]forDIEandS[0:3]for CAR
Q4. Given a string S = “CARPE DIEM”. If n is length/2 then what would following return?
(a)S[:n] (b)S[n:] (c)S[n:n] (d)S[1:n] (e)S[n:length-1]
Ans: (a)“CARPE(b)“DIEM” (c)“ “ (d)“ARPE” (e)“DIE”
Q5.Whatwouldfollowingexpressionreturn?
(a) ”HelloWorld”.upper().lower() (b)”HelloWorld”.lower().upper()
(c)”HelloWorld”.find(“Wor”,1,6) (d)”HelloWorld”.find(“Wor”)
(e)”HelloWorld”.find(“wor”) (f)”HelloWorld”.isalpha()
(g) ”HelloWorld”.isalnum() (h)”HelloWorld”.isdigit()
(i)“123FGH”.isdigit()
Ans: (a) 'helloworld' (b)'HELLOWORLD'
(c)-1 (d)6
(e)-1 (f)False
(g) False (h)False
(i)False
Q-6. Find the output:
str="PYTHON@LANGUAGE"
print(str[2:12:2])
Ans. TO@AG
63
Q-7. Find and write the output of the following python code:
x = "abcdef"
i = "a"
while i in x:
print(i, end = " ")
ShortAnswerTypeQuestions
Q1.What is a string slice?How is it useful?
Ans: String Slice is a part of a string containing some contiguous characters from the string.
It is accessed from the string by providing a rangein“[]”bracketsi.e.S[n:m].Python returns all the characters at
indices n,n+1, n+2. . n-1e.g.
S=”Barabanki”
S[4:7]will return ban
Q2.Write a python script that traverses through an input string and prints its characters in different lines–two
characters per line.
Ans:
Q3.Which functions would you chose to use to remove leading and trailing white spaces from a given string?
Ans: Python String strip() function will remove leading and trailing white spaces.If you want to remove
only leading or trailing spaces,use lstrip()or rstrip()function instead.
Q4.Suggest appropriate functions for the following tasks –
(a) To check whether the string contains digits.
(b) To find the occurrence a string within another string.
(c) Toconvertthefirstletterofastringtouppercase.
(d) To convert all the letters of a string toupper case.
(e) To check whether all the letters of the string are in capital letters.
(f) to remove all the white spaces from the beginning of a string.
Ans:(a) isalnum()
(b) find()
(c) capitalize()
(d) upper()
(f) isupper()
(g) lstrip()
64
Q5. Find the errors-
s=”PURAVIDA”
print(s[9]+s[9:15])
Ans: Here the error is:String index out of range.
HOTs Questions
Q.1 WAP to print following pattern without using any nested loop.
#
## Ans:
###
### #
#####
65
Unsolved Questions:
Q1.Find output of the following “abcd”.startswith(“cd”).
Q2. Find output of the following “COMPUTER SCIENCE”.title().
Q3. Differentiate between partition ( ) and split( ) functions.
Q4. Find the length of string: name= “Computer Science”).
Q5. Find the output:
Q6. . Find and write the output of the following python code:
Text1="DIGITAL INDIA2023"
Text2=""
I=0
while I<len(Text1):
if Text1[I]>="0" and Text1[I]<="9":
Val = int(Text1[I])
Val = Val + 1
Text2=Text2 + str(Val)
elif Text1[I]>="A" and Text1[I] <="Z":
Text2=Text2 + (Text1[I+1])
else:
Text2=Text2 + "*"
I=I+1
print (Text2)
Q7. Find and write the output of the following python code:
s="welcome2cs"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)
66
Answers:
Q1. False
Q2. Computer Sceince
Q3. The split() method is used to split a string into a list of substrings based on a delimiter. The delimiter
can be any character or sequence of characters that you specify. By default, if no delimiter is provided, it
will split the string at spaces.
The partition() method is used to split a string into three parts based on the first occurrence of a specified
delimiter. It returns a tuple containing the part before the delimiter, the delimiter itself, and the part after the
delimiter.
Q4. 16
Q5. Python
Output
based
Questions
Q6. IGITAL *NDIA23134
Q7. sELCcME&Cc
LIST MANIPULATION
List: A list is a collection of comma-separated values (items) of same or different type within square ( )
brackets. List is a mutable data type.
Slicing: Slicing is an operation in which we can slice a particular range from a sequence.
List slices are the sub parts extracted from a list.
Nested List: When a list appears as elements of another list, it is called a nested list.
Built-in Function (Manipulating Lists)
Function Syntax Description
list() list(sequence) It returns a list created from the passed
arguments, which should be a sequence
type(string, list, tuple etc.). if no argument is
passed, it will create an empty list.
append() list.append (items) It adds a single item to the end of the list.
extend() list1.extend (list2) It adds one list at the end of another list.
insert() list.insert (index_no, value) It adds an element at a specified index
reverse() list.reverse () It reverses the order of the elements in a list.
index() list.index (item) It returns the index of first matched item from
the list.
len() len (list) Returns the length of the list i.e. number of
elements in a list
sort() list.sort () This function sorts the items of the list.
clear() list.clear () It removes all the elements from the list.
count() list.count (element) It counts how many times an element has
occurred in a list and returns it.
sorted() sorted(sequence,reverse=False) It returns a newly created sorted list; it does not
67
change the passed sequence.
pop() list.pop (index) It removes the element from the specified index
and also returns the element which was
removed.
remove() list.remove (value) It is used when we know the element to be
deleted, not the index of the element.
max() max(list) Returns the element with the maximum value
from the list.
min() min(list) Returns the element with the minimum value
from the list
sum() sum(list) It returns sum of elements of the list.
MCQs
1 1. The data type list is an ordered sequence which is and made
up of one or more elements.
a. Mutable
b. Immutable
c. Both a) and b)
d. None of the above
2 Which statement from the list below will be create a new list?
a. new_l = [1, 2, 3, 4]
b. new_l = list()
c. Both a) and b)
d. None of the above
3 What will be the output of the following python code
new_list = [‘P’,’y’,’t’,’h’,’o’,’n’]
print(len(new_list))
a. 6 b. 7c. 8d. 9
4 Python allows us to replicate a list using repetition operator depicted by
symbol .
a. – b. + c. / d. *
5 We can access each element of the list or traverse a list using a .
a. for loop b. while loop
c. Both a) and b) d. None of the above
6 a single element passed as an argument at the end of the list.
a. append() b. extend()
c. insert() d. None of the above
7 returns index of the first occurrence of the element in the list. If
the element is not present, ValueError is generated.
a. insert() b. index()
c. count() d. None of the above
8 function returns the element whose index is passed as parameter
to this function and also removes it from the list.
a. push() b. remove()
c. pop() d. None of the above
68
9 What will be the output of the following python code.
new_list = “1234”
print(list(new_list))
a. [‘1’, ‘2’, ‘3’, ‘4’] b. (‘1’, ‘2’, ‘3’, ‘4’)
c. {‘1’, ‘2’, ‘3’, ‘4’} d. None of the above
10 Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], which of the following is correct syntax
for slicing operation?
a) print(list1[0]) b) print(list1[:2])
c) print(list1[:-2]) d) all of the mentioned
11 Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1] ?
a) Error b) None c) 25 d) 2
12 Suppose list1 is [1, 3, 2], What is list1 * 2 ?
a) [2, 6, 4] b) [1, 3, 2, 1, 3]
c) [1, 3, 2, 1, 3, 2] d) [1, 3, 2, 3, 2, 1].
13 What is the output when following code is executed ?
>>>list1 = [11, 2, 23]
>>>list2 = [11, 2, 2]
>>>list1 < list2 is
a) True b) False c) Error d) None
14 To insert 5 to the third position in list1, we use which command ?
a) list1.insert(3, 5) b) list1.insert(2, 5)
c) list1.add(3, 5) d) list1.append(3, 5)
In the following questions(15 to 20) , a statement of assertion (A) is
followed by a statement of reason(R) . Make the correct choice as :
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False (or partially True)
(d) A is false( or partially True) but R is True
15 Assertion: In python, unlike other types, you can change elements of a list in
place.
Reason: Lists are mutable sequences.
16 Assertion: Any comma-separated group of values creates a list.
Reason: Only a group of comma-separated values or expressions enclosed in [ ]
, creates a list.
17 Assertion: Lists and strings have similar types of indexing.
Reason: Both lists and strings have two-way indexing , forward indexing and
backward indexing.
18 Assertion :Lists are similar to strings in a number of ways like indexing , slicing
and accessing individual elements.
Reason : Lists, unlike strings , are mutable.
19 Assertion : The membership operators in and not in work in the same way on
lists as they do , with strings.
Reason :Some operators work differently on strings and lists , such as + and * .
20 Assertion: A list slice is an extracted part of a list.
Reason: A list slice is a list in itself.
69
1 a 11 c
2 c 12 c
3 a 13 b
4 d 14 b
5 c 15 a
6 c 16 d
7 b 17 a
8 c 18 b
9 a 19 c
10 d 20 b
Answers:
(a) list[1]=17
(b) list.append(4)
list.append(5)
list.append(6)
(c) list.pop(0)
(d) list.sort()
(e) list=list*2
(f) list.insert(3,25)
Q3. Ifais[1,2,3],what is the difference(ifany) between a*3 and [a,a,a]?
Ans: a*3 will produce [1,2,3,1,2,3,1,2,3],means a list of integers and [a,a,a] will produce[[1,2,3],[1,2,3],
[1,2,3]], means list of lists
Q4. If a is [1,2,3],is a*3 equivalent to a+ a+a?
Ans: Yes, Both a*3and a+a+a will produce same result.
70
Q5. If ai s[1,2,3],what is the meaning of a[1:1]=9?
Ans: This will generate an error―Type Error: can only assign an iterable.
Q6. If a is[1,2, 3],what is the meaning of a[1:2]=4 and a[1:1]=4?
JjAns: These will generate an error―Type Error:can only assign an iterable .
Q7. What are list slices?
Ans: List slices are the sub-part of a list extracted out. You can use indexes of the list elements to create list
slices as per following format. Syntax is as follows:- Seq=ListName [start:stop]
Q8.Does a slice operatoral ways produce a newlist?
Ans: Yes, this will create a new list.
ShortAnswerTypeQuestions
Q1. How are lists different from strings when both are sequences?
Ans: Lists are similar to strings in many ways like indexing, slicing, and accessing individual elements but
they are different in the sense that Lists are mutable while strings are immutable.
Inconsecutive locations, strings store the individual characters while list stores the references of its elements.
Strings store single type of elements-all characters while lists can store elements belonging to different types.
71
True Copy means you can create a copy of a list using New_list=My_list. The assignment just copies the
reference to the list, not the actual list, so both new_list and my_list refer to thesamelistaftertheassignment.
Q7. Predict the output – Ans:
UNSOLVED QUESTIONS
Q1. WAP to find minimum element from a list of elements along with its index in the list.
Q2.WAP to Calculate mean of the given list of numbers.
Q3. WAP to search for an element in a given list of numbers.
Q4. WAP to count the frequency of a given element in the list of numbers.
Q5. Differentiate between append( ) and extend ( ) functions in Python.
UNSOLVED QUESTIONS(ANSWERS)
Q1. WAP to find minimum element from a list of elements along with its index in the list.
72
Q3. WAP to search for an element in a given list of numbers.
Ans.lst=eval(input(“Enter list:”))
length=len(lst)
element=int(input(“Enter element to be searched for:”))
for i in range(0,length):
if element==lst[i]:
print(element,”found at index”,i)
break
else:
print(element,”not found in given list”)
Q4. WAP to count the frequency of a given element in the list of numbers.
Ans . L=[2,58,95,999,65,32,15,1,7,45]
n=int(input("Enter the number : "))
print("The frequency of number ",n," is ",L.count(n))
TUPLES
A tuple is a collection which is ordered and immutable (We cannot change elements of a tuple in place).
Tuples are written with round brackets. Tuples are used to store multiple items in a single variable. Tuples
may have items with same value.
Exp. T = () # Empty Tuple
T = (1, 2, 3) # Tuple of integers
T = (1,3.4,7) # Tuple of numbers
T = (‘a’, ‘b’, ‘c’) # Tuple of characters
T = (‘A’,4.5,’Ram’,45) # Tuple of mixed values
T = (‘Amit’, ‘Ram’, ‘Shyam’) # Tuple of strings
Creating Tuples
A tuple is created by placing all the items (elements) inside parentheses (), separated by commas.
Exp. T = (10,20, ‘Computer’,30.5)
If there is only a single element in a tuple then the element should be followed by a comma, otherwise it will
be treated as integer instead of tuple. For example
T = (10) # Here (10) is treated as integer value, not a tuple
T1 = (10,) # It will create a tuple
73
Difference between List and Tuple
List Tuple
Elements are enclosed in square brackets i.e. [ ] Elements are enclosed in parenthesis i.e. ( )
It is mutable data type It is immutable data type
Iterating through a list is slower as compared to tuple Iterating through a tuple is faster as compared
to list
Elements of a tuple can be accessed in the same way as a list or string using indexing and slicing, for example
If str = (‘C’, ‘O’, ‘M’, ‘P’, ‘U’, ‘T’, ‘E’, ‘R’)
Traversing a Tuple
Traversing a tuple means accessing and processing each element of it. The for loop makes it easy to
traverse or loop over the items in a tuple. For example:
74
Repetition
* Operator is used to replicate a tuple specified number of times, e.g.
>>> T = (10, 20, 30)
>>> T * 2
(10, 20, 30, 10, 20, 30)
Membership:
The ‘in’ operator checks the presence of element in tuple. If the element present it returns True, else it
returns False.
For Exp. str = (‘C’, ‘O’, ‘M’, ‘P’, ‘U’, ‘T’, ‘E’, ‘R’)
‘M’ in str => Returns True
‘S’ in str => Returns False
The not in operator returns True if the element is not present in the tuple, else it returns False.
‘M’ not in str => Returns False
‘S’ not in str => Returns True
Slicing
It is used to extract one or more elements from the tuple. Slicing can be used with tuples as it is used in
Strings and List. Following format is used for slicing:
S1 = T[start : stop : step]
The above statement will create a tuple slice namely S1 having elements of Tuple T on indexes start,
start+step, start+step+step, …, stop-1.
By default value of start is 0, value of stop is length of the tuple and step is 1
For Example:
>>> T = (10,20,30,40,50,60,70,80,90)
>>> T[2:7:3]
(30, 60)
>>> T[2:5]
(30, 40, 50)
>>> T[::3]
(10, 40, 70)
T[5::]
(60, 70, 80, 90)
Built-in functions/methods:
The len( ) function
This method returns length of the tuple or the number of elements in the tuple, i.e.,
>>> T = (10,20,30,40,50,60,70,80,90)
>>> len(T)
9
75
The max( ) function
This method returns element having maximum value, i.e.,
>>> T = (10,20,30,40,50,600,70,80,90)
>>>max(T)
600
>>> T = ('pankaj','pinki','parul')
>>> max(T)
'pinki'
>>> T = ('pankaj','pinki','parul')
>>> min(T)
'pankaj'
>>> T = (10,20,30,20,20,0,70,30,20)
>>> T.count(30)
2
76
The tuple( ) method
This function creates an empty tuple or creates a tuple if a sequence is passed as argument.
>>> L = [10, 20, 30] # List
>>> T = tuple(L) # Creates a tuple from the list
>>> print(T)
(10, 20, 30)
>>> Y = sorted(T, reverse = False) # Make a list of values arranged in ascending order
>>> print(Y)
[10, 23, 30, 40, 65, 78, 98]
>>> Z = sorted(T, reverse = True) # Make a list of values arranged in descending order
>>> print(Z)
[98, 78, 65, 40, 30, 23, 10]
It allows a tuple of variables on the left side of the assignment operator to be assigned respective
values from a tuple on the right side. The number of variables on the left should be same as the number of
elements in the tuple.
Exp.
>>> T = ('A', 100, 20.5)
>>> x,y,z = T
>>> print(x,y,z)
A 100 20.5
Nested Tuple
A tuple containing another tuple in it as a member is called a nested tuple, e.g., the tuple shown below
is a nested tuple:
>>> students = (101,'Punit', (82,67,75,89,90)) # nested tuple
>>> len(students)
3
77
>>> print(students[1]) # 2nd element of tuple
Punit
>>> print(students[2]) # 3rd element of tuple
(82, 67, 75, 89, 90)
>>> print(students[2][3]) # Accessing 4th element of inner tuple
89
Output
(10, 2, 30, 4, 8, 5, 45)
Sum of elements : 104
Output
(10, 2, 30, 4, 8, 5, 45)
Minimum Value : 2
Minimum Value : 45
Output
Tuple : (10, 2, 30, 4, 8, 5, 46)
Mean of elements : 15.0
78
# Write a program to find the given value in a tuple
T = (10,2,34,65,23,45,87,54)
print("Tuple :", T)
x = int(input("Enter value to search:"))
for a in T:
if a == x :
print("Value found")
break
else:
print("Value not found")
Output
Tuple : (10, 2, 34, 65, 23, 45, 87, 54)
Enter value to search:45
Value found
Q) Write a program to find sum of elements of tuple without using sum() function?
T = (10,20,30)
sum = 0
for x in T:
sum = sum + x
print(T)
print(sum)
79
MCQs
Consider a tuple in python named Months = (‘Jul’, ‘Aug’, ‘Sep’). Identify the C
1. invalid statement(s) from the given below statements:-
a) S = Months[0] b) print(Months[2])
c) Months[1] = ‘Oct’ d) LIST1 =list(Months)
Suppose tuple1 = (2, 33, 222, 14, 25), What is tuple1[ ::-1]? D
2. a) [2, 33, 222, 14] b) Error
c) 25 d) [25, 14, 222, 33, 2]
Consider the following declaration of Record, what will be the data type of Record? B
3. Record=(1342, “Pooja” , 45000, “Sales”)
a) List b) Tuple c) String d) Dictionary
Which operator is used for replication? C
4. a) + b) % c) * d) //
What will be the output of following Python Code? Tp = (5) D
5. Tp1 = tp * 2
Print(len(tp1))
a) 0 b) 2 c) 1 d) Error
80
Q6) Which error is returned by the following code:
T = (10,20,30,40,50,60,70)
Print(T[20])
Ans: IndexError : tuple index out of range
Q7) Write a program to create a tuple and find sum of its alternate elements?
Ans:T = (10,23,30,65,70)
sum = 0
for a in T[0:5:2]:
sum = sum + a
print(sum)
81
Dictionaries
A dictionary is an unordered sequence of key-value pairs.
➢ Key and value in a key-value pair in a dictionary are separated by a colon. Further, the key : value
➢ pairs in a dictionary are separated by commas and are enclosed between curly parentheses.
➢ The keys of the dictionaries are immutable types such as Integers or Strings etc.
➢ Indices in a dictionary can be of any immutable type and are called keys.
➢ Dictionaries are mutable.
Creating Dictionaries
A Dictionary can be created in three different ways:
Empty Dictionary
>>>D = { } # Empty Dictionary
Dictionary using literal notation
>>>D = {“Name” : “Mohan”, “Class” : “XI”, “City” : “Gurdaspur”}
>>>print(D)
{“Name” : “Mohan”, “Class” : “XI”, “City” : “Gurdaspur”}
>>>print(D[“City”])
“Gurdaspur”
Dictionary using dict() function
Dict() function is used to create a new dictionary with no items. For example,
>>> Months = dict() # Creates an empty dictionary
>>>print(Month) # Prints an empty dictionary
We can use Square Brackets( [ ] with keys for accessing and initializing dictionary values. For Example:
>>> Months[0] = ‘January’
>>> Months[1] = ‘February’
>>>Months[2] = ‘March’
>>> print(Months)
{0 : ’January’, 1: ’February’ , 2 : ’March’}
>>> Months = dict(Jan = 31, Feb = 28, March = 31) # Creating dictionary by giving values in dict()
function
>>> print(Months)
{‘Jan’ : 31, ‘Feb’ : 28, ‘March’ : 31}
Attempting to access a key that does not exist, causes an error. Consider the following statement
that is trying to access a non – existent key (7) from dictionary D. it raises KeyError.
>>> D[7]
KeyError : 7
82
Traversing a Dictionary
Dictionary items can be accessed using a for loop.
for x in D:
print(D [x])
Output
Sunday
Monday
Tuesday
Mutability of Dictionary
Dictionary like lists are mutable, it means dictionary can be changed, new items can be added and
existing items can be updated.
len() function:
It is used to find the length of the dictionary, i.e., the count of the key : value pair.
Exp.
D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
length = len(D)
print("Length of Dictionary : ", length)
Output
Length of Dictionary : 4
dict() function:
The dict() function creates a dictionary.
Exp.
By giving Key:value pair in the form of separate sequence:
83
Accessing Items, Keys and Values – get(), items(), keys(), values () methods
get( ) Method : it returns value of the given key
>>> D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
>>> value = D.get('Rama', 'Key not Found')
>>> print("Age of Rama is : ", value)
>>> value = D.get('Mohit', 'Key not Found') # if key is not in the dictionary, it shows key not found
>>> print("Age of Mohit is : ", value)
Output
Age of Rama is : 22
Age of Mohit is : Key not Found
items( ) Method :
It returns all items of a dictionary in the form of list of tuple of (key:value)
>>> D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
>>> print(D.items())
Output
dict_items([('Ram', 20), ('Mohan', 30), ('Rama', 22), ('Rashi', 32)])
keys( ) Method :
It returns list of all the keys of the dictionary.
>>> D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
>>> print(D.keys())
Output
dict_keys(['Ram', 'Mohan', 'Rama', 'Rashi'])
values( ) Method :
It returns list of all the values of the dictionary.
>>> D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
>>> print(D.values())
84
Output
dict_values([20, 30, 22, 32])
update( ) Method :
This function merges key : value pairs from the new dictionary into the original dictionary, adding or
replacing
as needed. The items in the new dictionary are added to the old one and override any items already there with
the same keys.
>>> D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
>>> D2 = {'A' : 20, 'Mohan' : 60, 'Rama' : 62, 'B' : 32}
>>> D.update(D2)
>>> print("D => ",D)
>>> print("D2 => ", D2)
Output
D => {'Ram': 20, 'Mohan': 60, 'Rama': 62, 'Rashi': 32, 'A': 20, 'B': 32}
D2 => {'A': 20, 'Mohan': 60, 'Rama': 62, 'B': 32}
{'Ram': 20, 'Mohan': 30, 'Rama': 22, 'Rashi': 32} # Complete Dictionary
{'Ram': 20, 'Rama': 22, 'Rashi': 32} # After deleting “Mohan”
clear ( ) method
It empties the dictionary.
>>> D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
>>> print(D)
>>> D.clear()
>>> print("Dictionary after Clear : ", D)
Output
{'Ram': 20, 'Mohan': 30, 'Rama': 22, 'Rashi': 32}
Dictionary after Clear : {}
pop ( ) method
It removes and returns the dictionary element associated to passed key.
>>> D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
85
>>> print("Removed Item : ", D.pop("Rama"))
Output
Removed Item : 22
popitem ( ) method
It removes and returns the last dictionary element.
>>> D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
>>> print("Removed Item : ", D.popitem())
Output
Removed Item : ('Rashi', 32)
sorted ( ) method
It returns a sorted list of the dictionary keys. It is used as below:
>>> D = {'Ram' : 20, 'Mohan' : 30, 'Rama' : 22, 'Rashi' : 32}
>>> print(sorted(D)) # sort the keys in ascending order
>>> print(sorted(D), reverse = False) # sort the keys in ascending order
>>> print(sorted(D), reverse = True) # sort the keys in descending order
Output
['Mohan', 'Ram', 'Rama', 'Rashi']
['Mohan', 'Ram', 'Rama', 'Rashi']
['Rashi', 'Rama', 'Ram', 'Mohan']
Output
Max = 3
min = 1
Sum = 6
fromkeys ( ) method
This method is used to create a new dictionary from a sequence containing all the keys and common
value, which will be assigned to all the keys. Keys argument must be an interable sequence (First argument).
When value not given, it will take None as the values for the keys (Second Argument)
Exp.
86
>>> D = dict.fromkeys([2,4,5,8],200) # When Value given
>>> print(D)
>>> D = dict.fromkeys([2,4,5,8]) # When value not given, it will take None as the values for the keys
print(D)
Output
{2: 200, 4: 200, 5: 200, 8: 200}
{2: None, 4: None, 5: None, 8: None}
setdefault ( ) method
This method inserts a new key: value pair only if the key does not exist. If the key already exists, it
returns the current value of the key.
Exp.
>>> D = {1: "Monday", 2: "Tuesday", 3:"Wednesday"}
>>> D.setdefault(2,"Tuesday") # Key already exists, it will not insert
>>> print(D)
>>> D.setdefault(4,"Thursday") # New Key, it will be inserted
>>> print(D)
Output
{1: 'Monday', 2: 'Tuesday', 3: 'Wednesday'}
{1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursday'}
87
print(D)
Output:
Count Frequencies...
{'T': 1, 'h': 1, 'i': 3, 's': 3, ' ': 8, 'a': 1, 'b': 2, 'o': 6, 'k': 2, ',': 1, 'v': 1, 'e': 1, 'r': 1, 'y': 1, 'g': 1, 'd': 1}
MCQs
1 Dictionaries are ...................... set of elements. C
(a) sorted (b) Ordered (c) unordered (d) random
2 Which of the following will create a dictionary with given keys and a common value? A
(a) fromkeys() (b) update () (c) setdefault() (d) all of the above
3 What will be printed by the following statements? B
D1 = {“cat”:12,”dog”:6,”elephant”:23,”bear”:20}
Print(25 in D1)
(a) True (b) False (c) Error (d) None
4 What would the following code print? B
D = {‘spring’ : ‘autumn’, ‘autumn’: ’fall’, ‘fall’ : ‘spring’}
Print(d[‘autumn’])
(a) autumn (b) fall (c) spring (d) Error
5 What will be the output of following Python code? C
d1 = {“a” : 10, “b” : 2, “c”:3}
str1 = “ ”
for i in d1:
str1 = str1 + str(d1[i]) + “ “
str2 = str1[:-1]
print(str2[::-1])
(a) 3, 2 (b) 3,2,10 (c) 3,2,01 (d) Error
Question – Answers
Q1) What is a dictionary?
Ans: A dictionary is an unordered sequence of key-value pairs.
➢ Key and value in a key-value pair in a dictionary are separated by a colon. Further, the key : value
➢ pairs in a dictionary are separated by commas and are enclosed between curly parentheses.
➢ The keys of the dictionaries are immutable types such as Integers or Strings etc.
➢ Indices in a dictionary can be of any immutable type and are called keys.
➢ Dictionaries are mutable.
88
Q4) Why a list cannot be used as keys of dictionaries?
Ans: Lists cannot be used as keys in a dictionary because they are mutable and a Python dictionary can have
only keys of immutable types.
Q5) If the addition of new key : value pair causes the size of the dictionary to grow beyond its original size,
an error occurs, True or False?
Ans: False, There cannot occur an error because dictionaries being the mutable types, they can grow or
shrink
on and as needed basis.
Q6) Write the output of following code:
x = {1:10, 2:20, 3:30}
x[4] = 20
print(x)
Ans:
{1: 10, 2: 20, 3: 30, 4: 20}
89
Python Modules
Python Modules:
Modules are the files in python used for grouping similar codes, to get an easy access to those codes.
Python Modules facilitates reusability and easy categorization of codes.
Python Built In Modules:
Python facilitates its users a variety of modules already defined in Python library that makes Python a easy
to use programming language. Some of these modules are:
Importing a Python Module:
Python modules can be imported in three ways, using:
90
sin() The sin() function returns the sine of arg. The value math.sin(val)
of arg must be in radians. (val is a number)
cos() The cos() function returns the cosine of arg. The math.cos(val)
value of arg must be in radians. (val is a number)
tan() The tan() function returns the tangent of arg. The math.tan(val)
value of arg must be in radians. (val is a number)
The math module of Python also makes available two useful constants namely pi and e. Which we can use as
math.pi gives the mathematical constant π = 3.141592…, to available precision.
math.e gives the mathematical constant e = 2.718281…, to available precision.
Random Module
Function Uses Example
random() Used to generate a random floating – point number Import random()
between 0.0 to 1.0 that is, including zero but excluding print(random.random())
one. 0.022353
randint() randint(start, stop) is used to generate a random random.randint(10,15)
number between start and stop where both the it may generate any one of the
numbers are inclusive. values given below
10,11,12,13,14,15
randrange() • random.randrange(<stopvalue>) is used to • random.randrange(35)
generate a random number in the range 0 to It will generate a random
<stopvalue> number from 0 to 35
• random.randrange(start,stop) is used to • random.randrange(11,45)
generate a random number in the range start to It will generate a random
stop number in the range 11 ..
• random.randrange(start,stop,step) is used to 45
generate a random number in the range start to • random.randrange(11,45,
stop, but here, the difference between two such 4)
generated random numbers will be a multiple of it may generate any one
step value. of the values given
below11,15,19,23,27,31,3
5,39,43
91
Statistics Module
mean() This method calculates the mean (average) of the givendata import statistics
set. It add up all the given values, then divide by number of seq =
values in the set. [5,6,7,5,6,5,5,9,11,12,23,5]
statistics.mean(seq)
it gives 8.25
median() This method calculates the median (middle value) of the import statistics
given data set. seq =
[5,6,7,5,6,5,5,9,11,12,23,5]
statistics.median(seq)
it gives 6.0
mode() This method determines the central tendency of numerical import statistics
or nominal data. It is used to find the most frequent number seq =
in a sequence. [5,6,7,5,6,5,5,9,11,12,23,5]
statistics.mode(seq)
it gives 5
MCQs
1. To include the use of functions which are present in the random library, we must use the option:
a) import random b) random.h c) import.random d) random.random
2. The output of the following Python code is either 1 or 2.
import random
random.randint (1 , 2)
a) True b) False
3. What will be the output of the following Python function if the random module has already been
imported?
random.randint(3.5 ,7)
a) b) Any integer between 3.5 and 7, including 7
b) Any integer between 3.5 and 7, excluding 7
c) The integer closest to the mean of 3.5 and 7
d) Error
92
print(x > 0 and math.sqrt(x))
a) True b) 1 c) 10 d) 10.0
Answers:
1 2 3 4 5 6 7 8
A A d b c d c a
Q2) Write a program to generate two random integers between 500 and 760. Print the average of these
number along with these numbers.
Ans:
import random
num1 = random.randint(500,760) - 500
num2 = random.randint(500,760) - 500
avg = (num1 + num2)/2
print("Number 1 : ", num1)
print("Number 2 : ", num2)
93
print("Average : ", avg)
Output
Number 1 : 147
Number 2 : 153
Average : 150.0
Q2) Given a list containing these values [22,13,28,13,22,25,7,13,25] . Write code to calculate mean,
median and mode of this list?
Ans:
import statistics as s
L = [22,13,28,13,22,25,7,13,25]
LMean = s.mean(L)
LMedian = s.median(L)
LMode = s.mode(L)
print("List ....... ")
print(L)
print("Mean : ", LMean)
print("Median : ", LMedian)
print("Mode : ", LMode)
Output
List........
[22, 13, 28, 13, 22, 25, 7, 13, 25]
Mean : 18.666666666666668
Median : 22
Mode : 13
94
DIGITAL FOOTPRINT
A digital footprint – refers to the trail of data you leave while using the internet. It includes websites you visit,
emails you send, and information you submit online. A digital footprint can be used to track a person’s online
activities and devices.
Internet users create their digital footprint either actively or passively. A passive footprint is made when
information is collected from the user without the person knowing this is happening. An active digital
footprint
is where the user has deliberately shared information about themselves either by using social media sites or
by
using websites.
95
These platforms encourage users to share their thoughts and experiences through posts or pictures.
• Be Secure
• Choose password wisely
• Know who you be friend
• Beware of fake information
• Be Reliable
• Think before uploading
DATA PROTECTION
Data protection is a set of strategies and processes you can use to secure the privacy, availability, and integrity
of the data. It is sometimes also called data security. A data protection strategy is very important for any
organisation that collects, handles, or stores sensitive data.
Intellectual Property Right (IPR) is the statutory right granted by the Government, to the owner(s) of the
intellectual property or applicant(s) of an intellectual property (IP) to exclude others from exploiting the IP
commercially for a given period of time, in lieu of the discloser of his/her IP in an IPR application.
Copyright laws protect intellectual property
Copyright It is a legal concept, enacted by most governments giving creator of original work exclusive rights
to it, usually for a limited period.
Patent – A patent is a grant of exclusive right to the inventor by the government. Patent give the holder a right
to exclude others from making, selling, using or importing a particular product or service, in exchange for full
public disclosure of their invention.
96
Trademark – A Trademark is a word, phrase, symbol, sound, colour and/or design that identifies and
distinguishes the products from those of others.
VIOLATION OF IPR
Violation of intellectual property right may happen in one of the following ways:
Plagiarism
Plagiarism It is stealing someone’s intellectual work and representing it as your own work without citing the
source of information.
Any of the following acts would be termed as Plagiarism:
• Using some other author’s work without giving credit to the author
• Using someone else’s work in incorrect form than intended originally by the author or creator.
• Modifying /lifting someone’s production such as music composition etc. without attributing it to the
creator of the work.
• Giving incorrect source of information.
Copyright infringement – When someone uses a copyrighted material without permission, or we have not paid
for it, if it is being sold. it is called Copyright infringement. Suppose we download an image from the Internet
and use it in our project.
Trademark Infringement
Trademark Infringement means unauthorised 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.
The GNU General public license (GPL) and the Creative Commons (CC) are two popular categories of public
licenses.
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. GPL is primarily designed for providing public licence to a 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.
97
CYBER CRIME
Any criminal or illegal activity through an electric channel or through any computer network is considered as
cyber crime.
Eg: Cyber harassment and stalking, distribution of child pornography,types of spoofing, credit card fraud ,. etc
CYBER LAW
It is the law governing cyberspace which includes freedom of expression, access to and usage of internet and
online privacy.
The issues addressed by cyber law include cybercrime, e-commerce, IPR and Data protection.
HACKING
It is an act of unauthorised access to a computer, computer network or any digital system.
Hackers usually are technical expertise of hardware and software.
● Hacking when done with a positive intent is called as Ethical hacking or White hat.
● Hacking when done with a negative intent is called as Unethical hacking or Black hat.
EAVESDROPPING
The term eavesdropping has been derived from the literal practice of secretly listening to the conversations of
people by standing under the eaves of a house. Unlike snooping, where the network traffic can be stored for
later analysis, eavesdropping is an unauthorised real-time interception or monitoring of private
communication between two entities over a network.
Also, the targets are usually the private communication channels like phone calls (VoIP), instant messages,
video conference, fax transmission, etc.
RANSOMEWARE
This is another kind of cyber crime where the attacker gains access to the computer and blocks the user from
accessing, usually by encrypting the data. The attacker blackmails the victim to pay for getting access to the
data, or sometimes threatens to publish personal and sensitive information or
photographs unless a ransom is paid. Ransomware can get downloaded when the users visit any malicious or
unsecure websites or download software from doubtful repositories.
CYBER TROLL
The comments or posts demean other users or people, or their content is called Cyber Troll. An Cyber troll is
an excellent example of social laws and ethics missing out. These are generally done to respond to any person
or their posts negatively. Trolling can be done by sending hate direct through messages, posts, or comments.
Their way of stating things is suppressive and oppressing, and trolls are visible on all social platforms such as
Instagram, Twitter, Facebook, YouTube, etc. The main target of the people who create trolls is people with
98
good fan-following, whether influencers or celebrities
CYBER BULLYING
It is the use of technology to harass , threaten or humiliate a target .
Example: sharing of embarrassing photos or videos, posting false information, sending mean text., etc.
CYBER SAFETY
Cyber safety refers to safe and responsible use of Internet, to ensure safety and security of personal
information and not posing threat to anyone else’s information.
▪ The online world is full of chances to interact and share with others. A lot of what you do and
say online can be seen even if you delete it
▪ Anyone can accesses your profile on social networking sites. keep your material private.
▪ Use strong passwords and change them often. Don’t share with others.
▪ Don't respond to inappropriate requests
Confidentiality of Information
▪ Never share your password or account numbers/Ban Details over an e-mail or message.
▪ Do not follow links from e-mails
▪ Beware of fraud callers, pop-ups, websites, or e-mails asking for personal information.
▪ Use secure passwords and change it regularly.
▪ Use anti-spyware, and antivirus softwares.
Malware
Malware is a short term used for Malicious softWARE. It is any software developed with an intention to
damage hardware devices, steal data, or cause any other trouble to the user.
Viruses, Worms, Ransomware, Trojans, and Spyware are some of the kinds of malware.
Viruses
A virus is a piece of software code created to perform malicious activities and hamper resources of a computer
99
system like CPU time, memory, personal files, or sensitive information.
a computer virus infects other computer systems that it comes into contact with by copying or inserting its
code into the computer programs or software (executable files).
Trojan
A Trojan is a malware, that looks like a legitimate software and once it tricks a user into installing it, it acts
pretty much like a virus or worm. However, a Trojan does not self-replicate or infect other files, it spreads
through user interaction such as opening an email attachment or downloading and executing a file from the
Internet.
Adware
An Adware is a malware that is created to generate revenue for its developer. An adware displays online
advertisements using pop-ups, web pages, or installation screens. Once an adware has infected a substantial
number of computer systems, it generates revenue either by displaying advertisements or using “pay per
click” mechanism to charge its clients against the number of clicks on their displayed ads.
E-waste - MANAGEMENT:
Various forms of electric and electronic equipment which no longer satisfy their original purpose are termed
as Ewaste. This includes Desktop, Laptop, Projectors, Mobiles,etc
● MANAGEMENT: Sell back, gift/donate, reuse the parts giveaway to a certified e-waste
Recycler.
Some of the feasible methods of e-waste management are reduce, reuse and recycle.
• Reduce: We should try to reduce the generation of e-waste by purchasing the electronic or electrical devices
only according to our need. Also, they should be used to their maximum capacity and discarded only after
their useful life has ended. Good maintenance of electronics devices also increases the life of the devices.
• Reuse: It is the process of re-using the electronic or electric waste after slight modification. The electronic
equipment that is still functioning should be donated or sold to someone who is still willing to use it. The
process of re-selling old electronic goods at lower prices is called refurbishing.
• Recycle: Recycling is the process of conversion of electronic devices into something that can be used again
and again in some or the other manner. Only those products should be recycled that cannot be repaired,
refurbished or re-used. To promote recycling of e-waste many companies and NGOs are providing door-to-
door pick up facilities for collecting the e-waste from homes and offices.
100
GENDER AND DISABILITY ISSUES WHILE TEACHING AND USING COMPUTERS GENDER
ISSUES
• Preconceived notions
Notions like ‘boys are better at technical things, girls are good at humanities, arts et girls must take up a career
keeping in mind that they have to raise a family. They must not take up high involvement careers, and
“Teaching is the best option for girls as it gives you half day off and ample number of holidays so that you can
easily take care of your family, etc. have their impact in decision making of girls while taking up subjects.
• Lack of interest
During primitive years, children often play games on computers/ smartphones. Most games available today
are boys-centric that increase their interest in computers Also, at homes boys get to play more on
computers/smartphone (keeping in mind the entire India scenario) and develop more interest in computers
than girls.
• Lack of motivation
Girls are pressurised to choose a career option which will give them ‘work life balance in favour of family
roles they have to play later on. Girls are always told directly/indirectly in households that you have to play
important family role later on and indulging in a subject which will consume most of your time is not
advisable as no matter what, whatever job option you choose, you cannot shy away from your family role.
• Lack of role models
Girls these days see less of role models in the field of ‘Computer Science’ whom they can imitate. TV,
movies, advertisements, every where it is portrayed that is technical fields like ‘Computers Science’, are
men’s fields. All these things influence girls sub-psychologically and they infer that ‘Computer Science’ is for
boys and do not take up the subject.
• Lack of encouragement in class
As there are lesser number of girls in a class, the teachers for most work-assignments end up choosing more
boys. Also, less number of girls means, lesser peer-encouragement. Also, some teachers pin point on their
roles in society such girls will get married and may not take it up as career.
• Unavailability of teaching material / aids
It has been observed that when, in schools, work-partners are chosen, boys prefer boys over girls. And even if
a girl and a boy are made work-partners, boys prefer to work actively and make girls silent observers. Boys
are not comfortable in situations where they are not playing active roles.
Disability Issues
In the specially abled students, there can be one or more disabilities:
101
• There should be teachers who know what types of hardware, software, tools etc. can be used for the
differently able students as per their specific needs, eg, special types of specialized hardware such as Braille
keyboards, monitors, printers, synthetic speech generators etc., software assistants such as Google assistant
etc.
• Lack of supporting curriculum.
Curriculum should be designed while keeping focus on inclusive education. There always should be
possible alternatives keeping in mind special needs of the students. Software and programs should be so used
so that the disabled students can easily work on that. For example, office software based curriculum can easily
be implemented for all types of students as nearly all office software provide accessibility features.
2. Ankit made a ERP - Enterprise resource planning solution for a renowned university and registered and
copyrights for the same. Which of the most important option; Ankit got the copyrights.
a) To get society status
b) To get fame
c) To get community welfare
d) To secure finance protection
5. A is some lines of malicious code that can copy itself and can have detrimental effect on the
computers, by destroying data or corrupting the system.
a. Cyber crime
b. Computer virus
c. Program
d. Software
102
6. Which of the following activity is an example of leaving Active digital footprints?
a) Surfing internet
b) Visiting a website
c) Sending an email to a friend
d) None of the above
7. You are planning to go for a vacation. You surfed the internet to get answers for following queries.
a) Places to visit
b) Availability of air tickets and fares
c) Best hotel deals
d) All of these
Which of the above-mentioned actions might have created a digital footprint?
8. Legal term to describe the rights of a creator of original creative or artistic work is called……..
a) Copyright
b) Copyleft
c) GPL
d) BSD
11. Gaining unauthorised access to a network or computer or digital files with malicious intentions, is
called
a. Cracking
b. Hacking
c. Banging
d. Phishing
12. Legal term to describe the rights of a creator of original creative or artistic work is called
a. Copyright
b. Copyleft
c. GPL
d. None of these
103
14.Any fraudulent business practice that extracts money e from an unsuspecting, ignorant person is
called
a. Stealing
b. Scam
c. Violation of copyright
d. Digital footprint
16.Any work / information that exist in digital form idea on internet or on an electronic device, is
known as property.
a. Licence property
b. digital property
c. source code property
d. software property
104
22. The is the Digital trail of your activity on the internet.
a. Copyleft
b. Digital footprint
c. Digital data
d. Internet property
23.The the are the permissions given to use a product or someone's creator by the copyright holder.
a. Source code
b. Licence
c. Software authority
d. Digital rights
105
30.The generally recognized term for the government protection afforded to intellectual property written
and electronic is called _
a. Computer security law.
b. Aggregate information.
c. Copyright law
d. Data security standards.
33.What is the name of the IT law that India is having in the Indian legislature?
a. India's Technology IT Act 2000
b. India's Digital information technology DIT Act, 2000
c. India's Information Technology IT Act, 2000
d. The technology act, 2008.
35.Every activity you perform on the internet is safe for how long?
a. 1 month
b. 1 year
c. As per my setting
d. Forever
Answers
1. a 2. d 3. d 4. D 5. B 6. C 7. d 8. a 9. D 10. A
11.b 12.a 13.d 14.b 15.b 16.b 17.a 18.b 19.b 20.d
21.b 22.b 23.b 24.c 25.c 26.a 27.c 28.b 29.b 30.c
31.c 32.d 33.c 34.d 35.d
106
CASE STUDY BASED QUESTIONS
1. After practicals, Atharv left the computer laboratory but forgot to sign off from his email
account. Later, his classmate Revaan started using the same computer. He is now logged in as
Atharv. He sends inflammatory email messages to few of his classmates using Atharv’s email account.
Revaan’s activity is an example of which of the following cyber crime?
a) Hacking
b) Identity theft
c) Cyber bullying
d) Plagiarism
2. Rishika found a crumpled paper under her desk. She picked it up and opened it. It contained some text
which was struck off thrice. But she could still figure out easily that the struck off text was the email ID and
password of Garvit, her classmate. What is ethically correct for Rishika to do?
a) Inform Garvit so that he may change his password.
b) Give the password of Garvit’s email ID to all other classmates.
c) Use Garvit’s password to access his account.
3. Suhana is down with fever. So, she decided not to go to school tomorrow. Next day, in the evening she
called up her classmate, Shaurya and enquired about the computer class. She also requested him to explain the
concept. Shaurya said, “Mam taught us how to use tuples in python”. Further, he generously said, “Give me
some time, I will email you the material which will help you to understand tuples in python”.
Shaurya quickly downloaded a 2-minute clip from the Internet explaining the concept of tuples in python.
Using video editor, he added the text “Prepared by Shaurya” in the downloaded videoclip. Then, he emailed
the modified video clip to Suhana. This act of Shaurya is an example of —
a) Fair use
b) Hacking
c) Copyright infringement
d) Cyber crime
4. After a fight with your friend, you did the following activities. Which of these activities is not an example
of cyber bullying?
a) You sent an email to your friend with a message saying that “I am sorry”.
b) You sent a threatening message to your friend saying “Do not try to call or talk to me”.
c) You created an embarrassing picture of your friend and uploaded on your account on a social networking
site.
5. Sourabh has to prepare a project on “Digital India Initiatives”. He decides to get information from the
Internet. He downloads three web pages (webpage 1, webpage 2,webpage 3)containing information on Digital
India Initiatives. Which of the following steps taken by Sourabh is an example of plagiarism or copyright
infringement?
a) He read a paragraph on “Digital India Initiatives” from webpage 1 and rephrased it in his own
words. He finally pasted the rephrased paragraph in his project.
b) He downloaded three images of “Digital India Initiatives” from webpage 2. He made a collage
for his project using these images.
c) He downloaded “Digital India Initiative” icon from web page 3 and pasted it on the front page of his project
report.
107
6. Neerja is a student of Class XI. She has opted for Computer Science. Neerja prepared the project assigned
to her. She mailed it to her teacher. The snapshot of that email is shown below.
Find out which of the following email etiquettes are missing in it.
a) Subject of the mail
b) Formal greeting
c) Self-explanatory terms
d) Identity of the sender
e) Regards
7. You are planning to go on a vacation to Kashmir. You surfed the internet for the following:
i) Weather conditions
ii) Availabilty of air tickets and fares
iii) Places to visit
iv) Best hotel deals
Which of the above mentioned acts might have left a digital footprint?
a) i and ii
b) i, ii and iii
c) i, ii and iv
d) all of these
8. Naveen received an email warning him of closure of his bank accounts if he did not update
his banking information as soon as possible. He clicked the link in the email and entered his banking
information. Next he got to know that he was duped.
i) This is an example of .
a. Online Fraud
b. Identity Theft
c. Phishing
d. Plagarism
ii) Someone steals Naveen’s personal information to commit theft or fraud, it is called
a. Online Fraud
b. Identity Theft
c. Phishing
d. Plagarism
iii) Naveen receiving an Unsolicited commercial emails is known as
a. Spam
b. Malware
c. Virus
d. worms
iv) Naveen’s Online personal account, personal website are the examples of?
a. Digital wallet
b. Digital property
c. Digital certificate
d. Digital signature
v) Sending mean texts, posting false information about a person online, or sharing embarrassing
photos or videos to harass, threaten or humiliate a target person, is called _
a. Eavesdropping
b. cyberbullying
c. Spamming
d. Phishing
108
9. Prathyush has to prepare a project on “Cyber Jaagrookta Diwas”.He decides to get
information from the Internet. He downloads three web pages (webpage1, webpage 2, webpage
3) containing information on the given topic.
1. He read a paragraph from webpage 1 and rephrased it in his own words. He
finally pasted the rephrased paragraph in his project. And he put a citation about the website he
visited and its web address also.
2. He downloaded three images of from webpage 2. He made a collage for his
project using these images.
3. He also downloaded an icon from web page 3 and pasted it on the front page of
his project report.
ANSWERS
CASE STUDY BASED QUESTIONS
1. b 2. a 3. c 4. a 5. b 6. A 7. d
8. i) c ii) b iii) a iv) b v) b
9. i) d ii) a iii) c iv) d v) c
109
SHORT ANSWER QUESTIONS(2 marks)
1. List any two health hazards related to excessive use of Technology
The continuous use of devices like smartphones, computer desktop, laptops, head phones etc cause a lot of
health hazards if not addressed.
These are:
A. Impact on bones and joints: wrong posture or long hours of sitting in an uncomfortable position can
cause muscle or bone injury.
B. Impact on hearing: using headphones or earphones for a prolonged time and on high
volume can cause hearing problems and in severe cases hearing impairments.
C. Impact on eyes: This is the most common form of health hazard as prolonged hours of screen time
can lead to extreme strain in the eyes.
D. Sleep problem: Bright light from computer devices block a hormone called melatonin which helps us
sleep. Thus we can experience sleep disorders leading to short sleep cycles.
2. Priyanka is using her internet connection to book a flight ticket. This is a classic example of leaving a trail
of web activities carried by her. What do we call this type of activity? What is the risk involved by such kind
of activity?
110