11CS
11CS
CHENNAI REGION
Session 2022-23
Class XI
Computer Science
Based on Latest CBSE Exam Pattern
KENDRIYA VIDYALAYA SANGATHAN
CHENNAI REGION
OUR PATRONS
Smt. T RUKMANI
Offg. DEPUTY COMMISIONER
KVS RO CHENNAI
COURSE DIRECTOR
Sh. N. RAKHESH
PRINCIPAL
KV VIJAYANARAYANAM, CHENNAI
INDEX
Sl.No Contents
1 Curriculum 2022-23
2 Computer Systems and Organisation
3 Data Representation
4 Boolean Logic
5 Introduction to Problem Solving
6 Getting Started with Python
7 Flow of Control
8 Strings
9 Lists
10 Tuples
11 Dictionaries
12 Cyber Safety / Security / Society Law And Ethics
Computer:
Computer is an advanced electronic device that takes raw data as input from the user and
processes these data under the control of set of instructions (called program) and gives the
result (output) and saves output for the future use. It can process both numerical and non-
numerical (arithmetic and logical) calculations.
Computer System:
All of the components of a computer system can be summarized with the simple
equations. COMPUTER SYSTEM = HARDWARE + SOFTWARE+ USER
• Hardware = Internal Devices + Peripheral Devices
All physical parts of the computer (or everything that we can touch) are known as
Hardware.
• Software = Programs
Software gives “intelligence” to the computer.
• USER = Person, who operates computer.
Characteristics of computer: Speed, accuracy, diligence, versatility, huge memory, no
IQ, lack of decision making.
Functional Units of a computer: Input Unit, Central Processing Unit (CPU), Storage
Unit and Output Unit.
Input Unit: The data and instructions for their processing are entered into the computer
through the input unit. They are stored in the memory (storage unit). Eg: keyboard,
mouse,
scanner, mic, digital camera, Joystick, Trackball, Light pen, Barcode Reader, OMR,
OCR, MICR etc.
Central Processing Unit: CPU is the brain of the computer. It consists of three
components-
Arithmetic Logic Unit (ALU), Control Unit (CU) and registers. ALU performs
calculations and logical operations such as comparisons and decision making. CU manages
and co-ordinates all other units of the computer. Registers are temporary storage elements
that facilitate the functions of CPU.
Storage Unit: It holds data and instructions required for processing, intermediate results
for ongoing processing and final results of processing.
Output Unit: The information obtained after data processing is supplied to the outside
world through this unit. Monitor, Projector, Sound Speaker, Plotter and printer are the
commonly used output devices.
Memory of Computer
Memory refers to the place where data is stored temporarily or permanently.
Computer Memory is basically of 2 types:
1. Primary Memory
Primary or main memory stores information (data and instruction)
2. Secondary Memory
Stores the data permanently for future retrieval
Primary Memory
❖Random Access Memory (RAM)
● It is the working memory, right from the booting of computer till the computer is
shutdown, this memory is in use to store all the operation done by the computer
● It is used for primary storage in computers to hold active information of data and
instructions.
● It holds data temporarily i.e. Volatile Memory
● Data is lost if Power Off
Units of Memory
4 BITS = 1 NIBBLE
8 BITS = 1 BYTE
1024 BYTES = 1 KILO BYTE(KB)
1024 KB = 1 MEGA BYTE(MB)
1024 MB = 1 GIGA BYTE(GB)
1024 GB = 1 TERA BYTE(TB)
1024 TB = 1 PETA BYTE(PB)
The elementary unit of memory is a bit (binary digit) i.e. Zero(0) & One(1)
1. HARD DISK :
● A hard disk drive (HDD; also hard drive, hard disk, or disk drive) is a device for storing
and retrieving digital information, primarily computer data.
● It consists of one or more rigid (hence "hard") rapidly rotating discs (often referred to
as platters), coated with magnetic material and with magnetic heads arranged to write data
to the surfaces and read it from them.
● Generally hard disks are sealed units fixed in the cabinet. It is also known as fixed disk
2. FLOPPY DISK :
● It is a data storage medium that is made up of a disk of thin, flexible magnetic material
enclosed in a cover. Its capacity is 1.44 MB.
3. COMPACT DISK (CD) :
● Capacity of standard 120mm CD is 700MB. It is a thin optical disk which is commonly
used to store audio and video data. Transfer speed is mentioned as multiple of 150 KB/s.
4x means 600 KB/s.
4. DIGITAL VIDEO DISK (DVD) :
● This is an optical disc storage device. It can be recorded on single side or on double
side. Its capacity may range from 4.7 GB to 8.5 GB.
5. PEN DRIVE :
This is small, portable memory, which can be plugged into a computer with USB Port.
They have capacity lesser than hard disk but much larger than a floppy or CD. They are
more reliable also.
Operating system (OS): A set of programs that acts as an interface between the user and
computer hardware. It controls and co-ordinates the operations of a computer. It acts as
the resource manager of the computer system.
Function of OS: Process management, memory management, file management, device
management, security management and command interpretation.
Computer languages: Broadly classified into low level languages and high level
languages.
Machine language and assembly language are the different low level languages. The
language, which uses binary digits 0 and 1, is called machine language.
Assembly language use mnemonics. Mnemonic is a symbolic name given to an operation.
High Level Languages are like English languages and are simpler to understand.
Language processors: These are the system programs that translate programs written in
high level language or assembly language into its equivalent machine language.
Types of language processors: Assembler (translates the program code written in
assembly language to machine language), Interpreter (converts a HLL program into
machine language line by line) and Compiler (translates a program written in high level
language into machine language).
Utility software: A set of programs which help users in system maintenance tasks. Some
of them are compression tools, disk defragmenter, backup software and antivirus software.
Compression utility: Large files can be compressed so that they take less storage area.
These compressed files can be decompressed into its original form when needed.
Compression of files is known as zipping and decompression is called unzipping. WinZip,
WinRAR, etc. are examples.
Disk defragmenter: A program that rearranges files on a computer hard disk. This enables
the computer to work faster and more efficiently.
Backup utility: These programs facilitate the backing up of disk.
Antivirus programs: A utility program that scans the computer system for viruses and
removes them. Norton Antivirus, Kaspersky, etc. are examples.
General purpose software: These are used to perform tasks in a particular application
area.
General purpose software is classified as word processors, spreadsheet software,
presentation software, database software and multimedia software.
Word processing software: It is designed for creating and modifying documents. It helps
to create, edit, format and print textual matters easily. Formatting features include different
font settings, paragraph settings, bullets and numbering, alignments and more. In addition
to this it can check spelling and grammar in the document, insertion of pictures, charts and
tables. We can specify headers and footers for every page in the document. The most
popular examples of this type of software are MS Word, Open Office Writer, Apple iWork
Pages, etc.
Spreadsheet software: This software allows users to perform calculations using
spreadsheets. It also allows us to insert drawing objects in the worksheet and create
different types of charts for graphical representation of numerical data. Microsoft Excel,
Open Office Calc, Lotus 1-2-3 and Apple iWork Numbers are some examples of
spreadsheet software.
Presentation software: The software is used to display information in the form of a slide
show. Presentation software allows preparing slides containing pictures, text, animation,
video and sound effects. Microsoft PowerPoint, Apple iWork Keynote and Open Office
Impress are examples for presentation software.
Database software: Database is an organised collection of data arranged in tabular form.
Database Management System (DBMS) consists of a collection of interrelated data and a
set of programs to access those data. They provide privacy and security to data and enforce
standards for data. Examples of DBMS software are Microsoft Access, Oracle, Postgres
SQL, My SQL, etc.
Multimedia software: Multimedia is the integration of multiple forms of media. This
includes text, graphics, audio, video, etc. Some multimedia software allows users to create
and edit audio and video files. Audio converters, audio players and video editing software
are some forms of multimedia software. Examples are VLC Player, Adobe Flash, Real
Player, Media Player, etc.
WORKSHEETS
Worksheet- LEVEL-1
1. Name the software required to make a computer functional. Write down its two primary
services.
2. What is the need for secondary memory?
3. Draw the block diagram of a computer system. Briefly write about the functionality of
each component.
4. Why is primary memory termed as “destructive write” memory but “non- destructive”
read memory?
5. Discuss the role of utility software in the context of computer performance?
6. Write equivalent memory units of the following:
1. 596 MB = __________ KB
2. 14 PB = ____________ GB
3. 135 YB = __________ PB
4. 10000 MB = ________ PB
5. 1000000 KB = _______GB
2. 14 PB = ____________ GB
3. 135 YB = __________ PB
4. 10000 MB = ________ PB
5. 1000000 KB = _______GB
Worksheet- LEVEL-3
DATA REPRESENTATION
CONTENT – REVIEW
Number systems are the technique to represent numbers in the computer system architecture,
every value that you are saving or getting into/from computer memory has a defined number
system.
Computer architecture supports following number systems.
1. Binary number system
2. Octal number system
3. Decimal number system
4. Hexadecimal (hex) number system
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 step 1 as a Least Signification Bit (LSB) to Step last as a Most
Significant Bit (MSB).
Decimal Number is :
(12345)10
Binary Number is
(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
Example 1
Example 2
Hexadecimal Number is
Decimal Number is : (725)10 (2D5)16
Convert
to its equivalent... A, B, C, D, E,
F
BINARY TO OTHER
A) Multiply the digit with 2(with place value exponent). Eventually add all the multiplication
becomes the Decimal number.
1. BINARY TO DECIMAL
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
=
Octal: 0 1 2 3 4 5 6 7
3. BINARY TO HEXADECIMAL
An equally easy way to convert from binary to hexadecimal is to group binary digits into
sets of four, starting with the least significant (rightmost) digits.
Binary: 11100101 = 1110 0101
Hexadecimal: 0 1 2 3 4 5 6 7
Hexadecim 8 9 A B C D E F
al:
Hexadecimal = E 5 = E5 hex
OCTAL TO OTHER
1. OCTAL TO BINARY
Converting from octal to binary is as easy as converting from binary to octal. Simply look
up each octal digit to obtain the equivalent group of three binary digits.
Octal: 0 1 2 3 4 5 6 7
2. OCTAL TO HEXADECIMAL
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 345
octal 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 = 1110 0101
Then, look up the groups in a table to convert to hexadecimal digits.
Binary: 0000 0001 0010 0011 0100 0101 011 0111
0
Hexadecimal: 0 1 2 3 4 5 6 7
Hexadecimal 8 9 A B C D E F
:
Therefore, through a two-step conversion process, octal 345 equals binary 011100101
equals hexadecimal E5.
3. OCTAL TO DECIMAL
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. HEXADECIMAL TO BINARY
Converting from hexadecimal to binary is as easy as converting from binary to hexadecimal.
Simply look up each hexadecimal digit to obtain the equivalent group of four binary digits.
Hexadecimal: 0 1 2 3 4 5 6 7
Hexadecimal: 8 9 A B C D E F
Hexadecimal A 2 D E
=
2. HEXADECIMAL TO DECIMAL
Convert 42A.1216 into a decimal number.
Solution-
The hexadecimal number given is 4 2 A. 1 2
Positional weights 2 1 0 -1-2
The positional weights for each of the digits are written in italics below each digit.
Hence the decimal equivalent number is given as:
4 × 162+ 2 ×161 + 10 × 161 + 1 × 16−1 + 1 × 16−2
= 1024 + 32 + 10 + 0.0625 + 0.00390625
= (1066.06640625)10
3. HEXADECIMAL TO OCTAL
ENCODING SCHEMES
American Standard Code for Information Interchange (ASCII)
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 used 7 bits to represent characters. Recall that there are only binary digits (0
or 1). Therefore, total number of different characters on 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.
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 mid 1980s.
It is an 8-bit code representation for Indian languages which means it can represent 28=256
characters. It retains all 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. Hence, text created using one encoding scheme was not recognised by another machine
using different encoding scheme.
Therefore, a standard called UNICODE has been developed to incorporate all the characters
of every written language of the world. UNICODE provides a unique number for every
character, irrespective of device (server, desktop, mobile), operating system (Linux,
Windows, iOS) or software application (different browsers, text editors, etc.). Commonly
used UNICODE encodings are UTF-8, UTF-16 and UTF-32. It is a superset of ASCII, and
the values 0–128 have the same character as in ASCII. Unicode characters for Devanagari
script
WORKSHEETS
BOOLEAN LOGIC
CONTENT – REVIEW
Boolean logic: NOT, AND, OR, NAND, NOR, XOR, truth table, De Morgan’s laws and logic
circuits
● Number system: Binary, Octal, Decimal and Hexadecimal number system; conversion between
number systems.
● Encoding schemes: ASCII, ISCII and UNICODE (UTF8, UTF32)
BOOLEAN LOGIC
● Boolean logic refers to Boolean Algebra which values of variables are the truth values
True or False. These values have two states either on or off denoted by 0 or 1.
● George Boole invented the first way of manipulating symbolic logic, which later
became known as Boolean Algebra. Because of its vast applications in switching
theory, developing basic electronic circuits, and designing digital computers, Boolean
algebra has become a vital tool in computer science.
1. NOT OPERATION:
A A’
0 1
1 0
2. OR OPERATION:
It is also a binary operator that operates on two variables. The result of the OR operator
is also known as logical addition. The symbol is used for OR is plus (+).
The output is true if either one or two inputs are “true”. IF both false it produce false
result.
X Y X+Y
0 0 0
0 1 1
1 0 1
1 1 1
3. AND OPERATION:
It is a binary operator that operates on two variables and the result of the AND operator
is known as logical multiplication. To denote AND operator dot(.) symbol is used.
AND means that A & B. When both inputs are true then it produce true result,
otherwise false.
X Y X.Y
0 0 0
0 1 0
1 0 0
1 1 1
4. NAND OPERATION:
It stands for NOT AND that produce reverse result of AND gate.
X Y (X.Y)’
0 0 1
0 1 1
1 0 1
1 1 0
5. NOR OPERATION:
It stands for NOT OR. It produces reverse output than the OR gate.
X Y (X+Y)’
0 0 1
0 1 0
1 0 0
1 1 0
6. XOR OPERATION:
It produces high output if the input of 1s is odd, otherwise false.
X Y X⊕Y
0 0 0
0 1 1
1 0 1
1 1 0
7. EX-NOR OPERATION:
X Y (X⊕Y)’
0 0 1
0 1 0
1 0 0
1 1 1
Basic Laws
De Morgan's Law:
First De Morgan's Law states that when two or more input variables (A, B) are OR’ed and
then negated, the result is equal to the AND of the complements of the individual input
variables.
(A+B)’ = A’ . B’
To prove this theorem we can use the truth table as given below:
A B A+B (A+B)’ A’ B’ A’.B’
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0
Second De Morgan's Law states that when two or more input variables are AND'ed and
negated, then the obtained result will be equal to the OR of the complements of the individual
variables.
(A.B)’ = A’+B’
Using the truth table, we can prove this as follows:
A B A.B (A.B)’ A’ B’ A’+B’
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0
WORKSHEETS
LEVEL-1
2. State De Morgan’s theorems of Boolean algebra. Give proof for any one theorem.
3. Draw the equivalent logic circuit for the following Boolean Expression:
A.(B+C ̅)
4. Name the law shown below and verify it using a truth table:
A+B.C=(A+B).(A+C)
5. Which are the universal gates ? Why are they called universal gates?
6. Name the following law and verify them using a truth table:
a. x + x’ = 1
b. x + y = y + x
c. x + (y + z ) = (x + y ) + z
d. x + xy = x
e. (x + y)’ = x’.y’
7. Draw logical circuits for the following:
Y = ab + bc + ca
Y = (a+b)’ . (a+b)
Y = a’.b’ + (a.b)’
Worksheet- LEVEL-2
1. Verify using truth table that X +XY =X for each X, Y in (0,1)
2. Design a logic circuit for the Boolean function f(x, y)= x .y + x’ +y’
3. What is a truth table? What is its significance ?
4. Which are the universal gates ? Why are they called universal gates?
5. Name the following law and verify them using a truth table:
a. x + x’ = 1
b. x + y = y + x
c. x + (y + z ) = (x + y ) + z
6. Draw logical circuits for the following:
1. Y = ab + bc + ca
2. Y = (a+b)’ . (a+b)
3. Y = a’.b’ + (a.b)’
7. Which gate returns true if both inputs are similar otherwise false.
8. Which of the following gate is also known as an inverter.
9. Which of the following gate returns a true result if both inputs are true otherwise false.
10.Write logic expression for the following logic diagram:
Worksheet- LEVEL-3
2. x * y = y * x is the __________
Inputs Output
A B Y
0 0 1
0 1 0
1 0 0
1 1 0
COMPETENCY BASED
1. How many two input AND gates and 2 input OR gates are required to realize Y=
BD+CE+AB
2. The output of an EX-NOR gate is 1. Which input combinations correct?
(i) A=1, B=0 (ii) A=0, B=1
(iii) A=0, B=0 (iv) A=0, B’=1
3. Determine the values of A, B, C, and D that make the sum term equal to zero.
4. Surveying the rules for Boolean multiplication, the 0 and 1 values seem to resemble the
truth table of a very common logic gate. Which type of gate is this, and what does this
suggest about the relationship between Boolean multiplication and logic circuits?
5. There are three fundamental operations in Boolean algebra: addition, multiplication,
and inversion. Each of these operations has an equivalent logic gate function and an
equivalent relay circuit configuration. Draw the corresponding gate and ladder logic
diagrams for each:
6. A student makes a mistake somewhere in the process of simplifying the following
Boolean expression: Determine where the mistake was made, and what the proper
sequence of steps should be to simplify the original expression.
AB + A(B + C)
AB + AB + C
AB + C
7. A riddle based on Boolean logic
You are walking and arrive at a dead end with 2 doors. You must get past this, but you
are told that only one door is correct, leading you on your path and the other door is not
correct and leads to something perilous. In front of each door is a guard. One guard
always tells the truth and the other always lies. You may ask one of the guards one
question, and then you must pick your door and go through it. What question do you
ask, which door do you pick based on the answer, and why?
CONTENT – REVIEW
S.NO TOPIC
1. Introduction
3. Algorithm
4. Representation of Algorithms
5. Flow of Control
6. Verifying Algorithms
7. Comparison of Algorithm
8. Coding
9. Decomposition
1. INTRODUCTION
• Computers are used for solving various day-to-day problems.
• It is pertinent to mention that computers themselves cannot solve a problem.
• Precise step-by-step instructions should be given by us to solve the problem.
• Thus, the success of a computer in solving a problem depends on how correctly and
precisely we define the problem, design a solution (algorithm) and implement the
solution (program) using a programming language.
• Thus, problem solving is the process of identifying a problem, developing an algorithm
for the identified problem and finally implementing the algorithm to develop a
computer program.
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.
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 whenever needed and
• stop on reaching the destination.
Example:
Algorithm to find square of a number.
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 showcases 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 flowchart is a visual representation of an algorithm.
• A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by
arrows.
Symbols Functions Descriptions
Also called “Terminator” symbol. It indicates
Start/End
where the flow starts and ends.
Also called “Action Symbol,” it represents a
Process
process, action, or a single step.
A decision or branching point, usually a
yes/no or true/ false question is asked, and
Decision
based on the answer, the path gets split into
two branches.
Also called data symbol, this parallelogram
Input/Output
shape is used to input or output data
Connector to show order of flow between
Arrow
shapes.
Flowchart 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:
Pseudocode for the sum of two numbers will be:
input num1
input num2
COMPUTE Result = num1 + num2
PRINT Result
4.5.1 Sequence
• Sometimes the algorithm to either does some routine tasks in a repeated manner or
behave differently depending on the outcomes of previous steps.
• The statements are executed one after another is known as sequence.
4.5.2 Selection
Let us look at some other examples where decision making is dependent on certain
conditions. For example,
(i) Checking eligibility for voting.
Depending on their age, a person will either be allowed to vote or not allowed to vote:
• If age is greater than or equal to 18, the person is eligible to vote
• If age is less than 18, the person is not eligible to vote
(ii) Let us consider another example
If a student is 8 years old and the student likes Maths put the student in Group A
Otherwise
Put the student in Group B
If <condition> then
steps to be taken when the
condition is true/fulfilled
There are situations where we also need to take action when the condition is not fulfilled (In
above Figure). To represent that, we can write:
If <condition> is true then
steps to be taken when the condition is
true/fulfilled
otherwise
steps to be taken when the condition is
false/not fulfilled
• The software designer should make sure that the functioning of all the components are
defined correctly, checked and verified in every possible way.
• When we were told that the formula for the sum of first N natural numbers is N(N+1)
/ 2 , how did we verify it?
• Well, we can check this for small numbers, for which we can manually calculate the
sum.
• Let N = 6, then the sum is 1 + 2 + 3 + 4 + 5 + 6 = 21 Using formula we get sum =
6x(6+1) / 2
• The method of taking an input and running through the steps of the algorithm is
sometimes called dry run. Such a dry run will help us to:
1. Identify any incorrect steps in the algorithm
2. Figure out missing details or specifics in the algorithm
Write an algorithm to calculate the time taken to go from place A to C (T_total) via B where
time taken to go from A to B (T1) and B to C (T2) are given. That is, we want the algorithm
to add time given in hours and minutes. One way to write the algorithm is:
PRINT value for T1
INPUT hh1
INPUT mm1
PRINT value for T2
INPUT hh2
INPUT mm2
hh_total = hh1 + hh2 (Add hours)
mm_total = mm1 + mm2 (Add mins)
Print T_total as hh_total, mm_total
Now let us verify. Suppose the first example we take is T1 = 5 hrs 20 mins and T2 = 7 hrs 30
mins. On dry run, we get the result 12 hrs and 50 mins. This looks fine.
Algorithm (i) requires large number of calculations (means more processing time) as it checks
for all the numbers as long as the divisor is less than the number. If the given number is large,
this method will take more
time to give the output.
Algorithm (ii) is more efficient than (i) as it checks for divisibility till half the number, and
thus it reduces the time for computation of the prime number.
Algorithm (iii) is even more efficient as it checks for divisibility till square root of the number,
thereby further reducing the time taken.
As algorithm (iv) uses only the prime numbers smaller than the given number for divisibility,
it further reduces the calculations. But in this method we require to store the list of prime
numbers first. Thus it takes additional
memory even though it requires lesser calculations.
Hence, algorithms can be compared and analysed on the basis of the amount of processing
time they need to run and the amount of memory that is needed to execute the algorithm.
These are termed as time complexity and space complexity, respectively. The choice of an
algorithm over another is done depending on how efficient they are in terms of processing
time required (time complexity) and the memory they utilize (space complexity).
4.8 Coding
• Once an algorithm is finalised, it should be coded in a high-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.9 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 pseudocode and draw flowchart to accept numbers till the user enters 0 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 (>=13 but <20) or adult
(>=20),based on age specified:
3. Write an algorithm that accepts four numbers as input and find the largest and smallest
of them.
WORKSHEETS
1. Write pseudocode that reads two numbers and divide one by another and display the
quotient.
5. Write the pseudocode to print the bill depending upon the price and quantity of an item.
Also print Bill GST, which is the bill after adding 5% of tax in the total bill.
6. Write an algorithm that accepts four numbers as input and find the largest and smallest
of them.
ANSWER KEY:
QUESTION 1
Print quotient
QUESTION 2
Print i
QUESTION 3
QUESTION 4
Set sum = 0
While sum = 200
Input money obtained
Sum += money
QUESTION 5
Input Price
Input quantity
Calculate total = price * quantity
Calculate including_GST = total + total* 0.05
Print total bill is including_GST
QUESTION 6
Input number
Set Factorial = 1
For i in range ( 1, number + 1) :
Factorial *= I
Print factorial
QUESTION 8
GETTING STARTED WITH PYTHON
CONTENT – REVIEW
S.NO TOPICS
1. Introduction to Python
2. Python Keywords
3. Identifiers
4. Variables
5. Comments
6. Everything is an Object
7. Data Types
8. Operators
9. Expressions
10. Statement
13. Debugging
5.1 INTRODUCTION TO PYTHON
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.
5.1.3 Execution Modes
a) Interactive mode
b) Script mode
Interactive Mode:
Without passing python script file to the interpreter, directly execute code to Python
(Command line).
Example:
>>>6+3
Output: 91. INTRODUCTION
Thus, the success of a computer in solving a problem depends on how correctly and
precisely we define the problem, design a solution (algorithm) and implement the
solution (program) using a programming language.
Developing an Algorithm
Coding
It is important to clearly understand a problem before we begin to find the solution for
it.
By analysing a problem, we would be able to figure out what are the inputs that our
program should accept and the outputs that it should produce.
The solution for a problem is represented in step by step procedure called an algorithm.
For a given problem, more than one algorithm is possible and we have to select the
most suitable solution.
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.
In case the output generated is incorrect, 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’:
start peddling,
Example:
Once we have an algorithm to solve a problem, we can write the computer program for
giving instructions to the computer in high level language.
If the algorithm is correct, computer will run the program correctly, every time.
So, the purpose of using an algorithm is to increase the reliability, accuracy and
efficiency of obtaining solutions.
• Uniqueness — results of each step are uniquely defined and only depend on the input
and the result of the preceding steps.
4. Representation of Algorithms
• it showcases the logic of the problem solution, excluding any implementational details
A decision or branching point, usually a yes/no or true/ false question is asked, and
based on the answer, the path gets split into two branches.
Input/Output
Also called data symbol, this parallelogram shape is used to input or output data
Arrow
4.2 Pseudocode
pseudocode:
• INPUT
• COMPUTE
• INCREMENT
• DECREMENT
• IF/ELSE
• WHILE
• TRUE/FALSE
Example:
input num1
input num2
PRINT Result
The flow of control depicts the flow of events as represented in the flow chart.
4.5.1 Sequence
Sometimes the algorithm to either does some routine tasks in a repeated manner or
behave differently depending on the outcomes of previous steps.
4.5.2 Selection
Let us look at some other examples where decision making is dependent on certain
conditions. For example,
Depending on their age, a person will either be allowed to vote or not allowed to vote:
Otherwise
If <condition> then
condition is true/fulfilled
There are situations where we also need to take action when the condition is not
fulfilled (In above Figure). To represent that, we can write:
true/fulfilled
otherwise
false/not fulfilled
The software designer should make sure that the functioning of all the components are
defined correctly, checked and verified in every possible way.
When we were told that the formula for the sum of first N natural numbers is N(N+1)
/ 2 , how did we verify it?
Well, we can check this for small numbers, for which we can manually calculate the
sum.
The method of taking an input and running through the steps of the algorithm is
sometimes called dry run. Such a dry run will help us to:
Write an algorithm to calculate the time taken to go from place A to C (T_total) via B
where time taken to go from A to B (T1) and B to C (T2) are given. That is, we want
the algorithm to add time given in hours and minutes. One way to write the algorithm
is:
INPUT hh1
INPUT mm1
INPUT hh2
INPUT mm2
Now let us verify. Suppose the first example we take is T1 = 5 hrs 20 mins and T2 = 7
hrs 30 mins. On dry run, we get the result 12 hrs and 50 mins. This looks fine.
(i) Starting with divisor 2, divide the given number (dividend) and check if there are
any factors. Increase the divisor in each iteration and repeat the previous steps as long
as divisor < dividend. If there is a factor, then the given number is not prime
(ii) In (i), instead of testing all the numbers till the dividend, only test up to half of the
given value (dividend) because the divisor can not be more than half of the dividend
(iii) In method (i), only test up to the square root of the dividend (numbers)
(iv) Given a prior list of prime number till 100, divide the given number by each number
in the list. If not divisible by any number, then the number is a prime else it is not prime
All these four methods can check if a given number is prime or not. Now the question
is which of these methods is better or efficient?
Algorithm (i) requires large number of calculations (means more processing time) as it
checks for all the numbers as long as the divisor is less than the number. If the given
number is large, this method will take more
Algorithm (ii) is more efficient than (i) as it checks for divisibility till half the number,
and thus it reduces the time for computation of the prime number.
Algorithm (iii) is even more efficient as it checks for divisibility till square root of the
number, thereby further reducing the time taken.
As algorithm (iv) uses only the prime numbers smaller than the given number for
divisibility, it further reduces the calculations. But in this method we require to store
the list of prime numbers first. Thus it takes additional
Hence, algorithms can be compared and analysed on the basis of the amount of
processing time they need to run and the amount of memory that is needed to execute
the algorithm. These are termed as time complexity and space complexity, respectively.
The choice of an algorithm over another is done depending on how efficient they are
in terms of processing time required (time complexity) and the memory they utilize
(space complexity).
4.8 Coding
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.9 Decomposition
Define Algorithm
What is decomposition?
Write pseudocode and draw flowchart to accept numbers till the user enters 0 and then
find their average.
Write a pseudocode and draw a flowchart where multiple conditions are checked to
categorize a person as either child (<13), teenager (>=13 but <20) or adult
(>=20),based on age specified:
Write an algorithm that accepts four numbers as input and find the largest and smallest
of them.
REVISION NOTES
CLASS XI
• Python programs are easy to understand as they have a clearly defined syntax
and relatively simple structure.
• Python is case-sensitive. For example, NUMBER and number are not same in
Python.
• Python is portable and platform independent, means it can run on various
operating systems and hardware platforms.
• Python is also helpful in web development. Many popular web services and
applications are built using python.
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.
Script Mode:
In this mode source code is stored in a file with the .py extension and use the
interpreter to execute the contents of the file. To execute the script by the interpreter,
you have to tell the interpreter the name of the file.
Example:
If you have a file name Demo.py , to run the script you have to follow the
following steps:
5.2 PYTHONKEYWORDS
All the keywords are in lowercase except 03 keywords (True, False, None)
5.3 IDENTIFIERS
Identifier: The name given by the user to the entities like variable name, class-name,
function-name etc.
5.4 VARIABLES
• A variable in a program is uniquely identified by a name (identifier).
• Variable in Python refers to an object — an item or element that is stored in the
memory.
• Value of a variable can be a string (e.g., ‘b’, ‘Global Citizen’), numeric (e.g.,
345) or any combination of alphanumeric characters (CD67).
• In Python we can use an assignment statement to create new variables and assign
specific values to them.
gender = 'M'
message = "Keep Smiling"
price = 987.9
Program Write a program to display values of variables in Python.
#To display values of variables
message = "Keep Smiling"
print(message)
userNo = 101
print('User Number is', userNo)
Output:
Keep Smiling
User Number is 101
5.5 COMMENTS
• Comments are not executed.
• Comments explain a program and make a program understandable and
readable.
• All characters after the # and up to the end of the physical line are part of the
comment and the Python interpreter ignores them.
Example
#Variable amount is the total spending on grocery
amount = 3400
#totalMarks is sum of marks in all the tests of Mathematics
totalMarks = test1 + test2 + finalTest
5.7 DATATYPES
5.7.1 Number
Number data type stores numerical values only. It is further classified into three
different types: int, float and complex.
Boolean data type (bool) is a subtype of integer. It is a unique data type, consisting of
two constants, True and False.
Example
>>> num1 = 10
>>> type(num1)
<class 'int'>
5.7.2 Sequence
String
String is a group of characters. These characters may be alphabets, digits or special
characters including spaces.
>>> str1 = 'Hello Friend'
>>> str2 = "452"
We cannot perform numerical operations on strings, even when the string contains a
numeric value, as in str2.
List
List is a sequence of items separated by commas and the items are enclosed in square
brackets [ ].
Example
#To create a list
>>> list1 = [5, 3.4, "New Delhi", "20C", 45]
#print the elements of the list list1
>>> print(list1)
[5, 3.4, 'New Delhi', '20C', 45]
Tuple
Tuple is a sequence of items separated by commas and items are enclosed in
parenthesis ( ). This is unlike list,
where values are enclosed in brackets [ ]. Once created, we cannot change the tuple.
Example
#create a tuple tuple1
>>> tuple1 = (10, 20, "Apple", 3.4, 'a')
#print the elements of the tuple tuple1
>>> print(tuple1)
(10, 20, "Apple", 3.4, 'a')
Set
Set is an unordered collection of items separated by commas and the items are enclosed
in curly brackets { }. A set is similar to list, except that it cannot have duplicate
entries. Once created, elements of a set cannot be changed.
Example
#create a set
>>> set1 = {10,20,3.14,"New Delhi"}
>>> print(type(set1))
<class 'set'>
>>> print(set1)
{10, 20, 3.14, "New Delhi"}
#duplicate elements are not included in set
>>> set2 = {1,2,1,3}
>>> print(set2)
{1, 2, 3}
5.7.4 None
None is a special data type with a single value.
Example
>>> myVar = None
>>> print(type(myVar))
<class 'NoneType'>
>>> print(myVar)
None
5.7.5 Mapping
Mapping is an unordered data type in Python. Currently, there is only one standard
mapping data type in Python
called dictionary.
Dictionary
Dictionary in Python holds data items in key-value pairs.Items in a dictionary are
enclosed in curly brackets { }.
Example
#create a dictionary
>>> dict1 = {'Fruit':'Apple', 'Climate':'Cold', 'Price(kg)':120}
>>> print(dict1)
{'Fruit': 'Apple', 'Climate': 'Cold', 'Price(kg)': 120}
>>> print(dict1['Price(kg)'])
120
5.7.6 Mutable and Immutable Data Types
Mutable Immutable
The objects can be modified after the Objects can not be modified after the
creation as well. creation of the objects.
Classes that are mutable are not considered Classes that are immutable are
final. considered final.
Thread unsafe. Thread-safe.
Classes are not made final for the mutable Classes are made final for the immutable
objects. objects.
Example: Lists, Dicts, Sets, User-Defined Example: int, float, bool, string,
Classes, Dictionaries, etc. Unicode, tuple, Numbers, etc.
5.8 OPERATORS
5.8.1 Arithmetic Operators
5.8.2 Relational Operators
5.8.3 Assignment Operators
5.8.4 Logical Operators
5.9 EXPRESSIONS
1. 100
2. 3.0 + 3.14
3. num
4. 23/3 -5 * 7(14 -2)
5. num – 20.4
6. "Global" + "Citizen"
5.9.1 Precedence of Operators
Example
How will Python evaluate the following expression?
(20 + 30) * 40
Solution:
= (20 + 30) * 40 # Step 1
#using parenthesis(), we have forced precedence of + to be more than that of *
= 50 * 40 # Step 2
= 2000 # Step 3
Example
How will the following expression be evaluated in Python?
15.0 / 4 + (8 + 3.0)
Solution:
= 15.0 / 4 + (8.0 + 3.0) #Step 1
= 15.0 / 4.0 + 11.0 #Step 2
= 3.75 + 11.0 #Step 3
= 14.75 #Step 4
5.10 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
5.13 DEBUGGING
A programmer can make mistakes while writing a program, and hence, the program
may not execute or may generate wrong output. The process of identifying and
removing such mistakes, also known as bugs or errors, from a program is called
debugging. Errors occurring in programs can be categorised as:
i) Syntax errors.
ii) Logical errors
iii) Runtime errors
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.
Example:
Algorithm to find square of a number.
4. Representation of Algorithms
Start/End
Also called “Terminator” symbol. It indicates where the flow starts and ends.
Process
Also called “Action Symbol,” it represents a process, action, or a single step.
Decision
A decision or branching point, usually a yes/no or true/ false question is asked, and
based on the answer, the path gets split into two branches.
Input/Output
Also called data symbol, this parallelogram shape is used to input or output data
Arrow
Connector to show order of flow between shapes.
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:
Pseudocode for the sum of two numbers will be:
input num1
input num2
COMPUTE Result = num1 + num2
PRINT Result
4.5.1 Sequence
Sometimes the algorithm to either does some routine tasks in a repeated manner or
behave differently depending on the outcomes of previous steps.
The statements are executed one after another is known as sequence.
4.5.2 Selection
Let us look at some other examples where decision making is dependent on certain
conditions. For example,
(i) Checking eligibility for voting.
Depending on their age, a person will either be allowed to vote or not allowed to vote:
• If age is greater than or equal to 18, the person is eligible to vote
• If age is less than 18, the person is not eligible to vote
(ii) Let us consider another example
If a student is 8 years old and the student likes Maths put the student in Group A
Otherwise
Put the student in Group B
If <condition> then
steps to be taken when the
condition is true/fulfilled
There are situations where we also need to take action when the condition is not
fulfilled (In above Figure). To represent that, we can write:
If <condition> is true then
steps to be taken when the condition is
true/fulfilled
otherwise
steps to be taken when the condition is
false/not fulfilled
The software designer should make sure that the functioning of all the components are
defined correctly, checked and verified in every possible way.
When we were told that the formula for the sum of first N natural numbers is N(N+1)
/ 2 , how did we verify it?
Well, we can check this for small numbers, for which we can manually calculate the
sum.
Let N = 6, then the sum is 1 + 2 + 3 + 4 + 5 + 6 = 21 Using formula we get sum =
6x(6+1) / 2
The method of taking an input and running through the steps of the algorithm is
sometimes called dry run. Such a dry run will help us to:
1. Identify any incorrect steps in the algorithm
2. Figure out missing details or specifics in the algorithm
Write an algorithm to calculate the time taken to go from place A to C (T_total) via B
where time taken to go from A to B (T1) and B to C (T2) are given. That is, we want
the algorithm to add time given in hours and minutes. One way to write the algorithm
is:
PRINT value for T1
INPUT hh1
INPUT mm1
PRINT value for T2
INPUT hh2
INPUT mm2
hh_total = hh1 + hh2 (Add hours)
mm_total = mm1 + mm2 (Add mins)
Print T_total as hh_total, mm_total
Now let us verify. Suppose the first example we take is T1 = 5 hrs 20 mins and T2 = 7
hrs 30 mins. On dry run, we get the result 12 hrs and 50 mins. This looks fine.
There can be four different ways to write algorithms to check whether a given number
is prime or not as shown below:
(i) Starting with divisor 2, divide the given number (dividend) and check if there are
any factors. Increase the divisor in each iteration and repeat the previous steps as long
as divisor < dividend. If there is a factor, then the given number is not prime
(ii) In (i), instead of testing all the numbers till the dividend, only test up to half of the
given value (dividend) because the divisor can not be more than half of the dividend
(iii) In method (i), only test up to the square root of the dividend (numbers)
(iv) Given a prior list of prime number till 100, divide the given number by each number
in the list. If not divisible by any number, then the number is a prime else it is not prime
All these four methods can check if a given number is prime or not. Now the question
is which of these methods is better or efficient?
Algorithm (i) requires large number of calculations (means more processing time) as it
checks for all the numbers as long as the divisor is less than the number. If the given
number is large, this method will take more
time to give the output.
Algorithm (ii) is more efficient than (i) as it checks for divisibility till half the number,
and thus it reduces the time for computation of the prime number.
Algorithm (iii) is even more efficient as it checks for divisibility till square root of the
number, thereby further reducing the time taken.
As algorithm (iv) uses only the prime numbers smaller than the given number for
divisibility, it further reduces the calculations. But in this method we require to store
the list of prime numbers first. Thus it takes additional
memory even though it requires lesser calculations.
Hence, algorithms can be compared and analysed on the basis of the amount of
processing time they need to run and the amount of memory that is needed to execute
the algorithm. These are termed as time complexity and space complexity, respectively.
The choice of an algorithm over another is done depending on how efficient they are
in terms of processing time required (time complexity) and the memory they utilize
(space complexity).
4.8 Coding
Once an algorithm is finalised, it should be coded in a high-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.9 Decomposition
The basic idea of solving a complex problem by decomposition is to 'decompose' or
break down a complex problem into smaller sub problems
Write pseudocode and draw flowchart to accept numbers till the user enters 0 and then
find their average.
Write a pseudocode and draw a flowchart where multiple conditions are checked to
categorize a person as either child (<13), teenager (>=13 but <20) or adult
(>=20),based on age specified:
Write an algorithm that accepts four numbers as input and find the largest and smallest
of them.
WORKSHEETS
i Serial_no. v Total_Marks
ii 1st_Room vi total-Marks
iii Hundred$ vii _Percentage
iv Total Marks viii True
4. Write logical expressions corresponding to the following statements in Python
and evaluate the expressions (assuming variables num1, num2, num3, first,
middle, last are already having meaningful values):
a) The sum of 20 and –10 is less than 12.
b) num3 is not more than 24
c) 6.75 is between the values of integers num1 and num2.
d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string
‘last’
e) List Stationery is empty
a) 0 == 1 == 2
b) 2 + 3 == 4 + 5 == 7
c) 1 < -1 == 3 > 4
10. 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. Then Simple Interest (SI) = (P x R x T)/ 100.
Amount payable = Principal + SI. P, R and T are given as input to the program.
11. Write a program to enter two integers and perform all arithmetic
operations on them.
12. Write a program to swap two numbers without using a third variable.
ANSWER KEY
QUESTION 1
Keyword is a special word that has a special meaning and purpose. Keywords are
reserved and are few. For example : if, else, elif etc. Identifier is the user-defined
name given to a part of a program like variable, object, functions etc. Identifiers are
not reserverd. These are defined by the user but they can have letters, digits and a
symbols underscore. They must begin with either a letter or underscore. For example :
chess, _ch, etc.
QUESTION 2
Python allows three types of integer literals :
1. Decimal (base 10) integer literals.
2. Octal (base 8) integer literals.
3. Hexadecimal (base 16) integer literals. For example, decimal 12 will be written as
14 as octal integer and as OXC as hexa decimal integer. (12)10 = (14)8 = (OXC)16.
(as hexa decimal)
QUESTION 3
i) Serial_no.: Invalid - Identifier in python cannot contain any special character except
underscore(_).
ii) 1st_Room: Invalid - Identifier in Python cannot start with a number.
iii) Hundred$: Invalid - Identifier in Python cannot contain any special character
except underscore(_).
iv) Total Marks: Invalid - Identifier in Python cannot contain any special character
except underscore(_). If more than one word is used as a variable then it can be
separated using underscore ( _ ), instead of space.
v) Total_Marks: Valid
vi) total-Marks: Invalid - Identifier in Python cannot contain any special character
except underscore(_). If more than one word is used as a variable then it can be
separated using underscore ( _ ), instead of a hyphen ( - ).
vii) _Percentage: Valid
viii) True: Invalid - Identifier in Python should not be a reserved keyword.
QUESTION 4
QUESTION 5
a) ( 0 == (1==2))
b) (2 + (3 == 4) + 5) == 7
c) (1 < -1) == (3 > 4 )
QUESTION 6
a) 2, 5
b) 6, 4
c) Error as num3 is used in RHS of line 2 (num3, num2 = num1, num3 + 1) before
defining it earlier.
QUESTION 7
a) num1 += 3 + 2
The above statement can be written as
num1 = num1 + 3 + 2 = 4 + 3 + 2 = 9
Therefore, print(num1) will give the output 9.
b) num1 = num1 ** (num2 + num3)
The above statement will be executed as per the following steps.
num1 = 4 ** (3 + 5) = 4 ** 5 = 1024
Therefore, print(num1) will give the output 1024.
c) num1 **= num2 + num3
The above statement can be written as
num1 **= 5
num1 = num1 ** 5
num1 = 4 ** 5
num1 = 1024
Therefore, the output will be 1024.
g) num1 = 24 // 4 // 2
#When the operators are same, left to right order will be followed for operation
num1 = 6 // 2
#When floor division is used, return value will be int data type
num1 = 3
Therefore, the output will be 3
h) num1 = float(10)
float(10) will convert integer value to float value and therefore, the output will be
10.0.
i) num1 = int('3.14')
This will result in an error as we cannot pass string representation of float to an int
function.
j) print('Bye' == 'BYE')
As Python compares string character to character and when different characters are
found then their Unicode value is compared. The character with lower Unicode value
is considered to be smaller. Here, 'y' has Unicode 121 and 'Y' has 89. Therefore, the
output will be 'False'.
RHS:
29 >= 29/9
True
LHS :
5 % 10 + 10 < 50
5 + 10 < 50
15 < 50
True
RHS:
29 <= 29
True
QUESTION 8
a) Runtime Error. The syntax for the division is correct. The error will arise only
when 'interpreter' will run this line.
b) Runtime Error. The syntax is correct. The error will arise only when 'interpreter'
will run the line containing these statements.
QUESTION 9
#defining the boiling and freezing temp in celcius
boil = 100
freeze = 0
print('Water Boiling temperature in Fahrenheit::')
#Calculating Boiling temperature in Fahrenheit
tb = boil * (9/5) + 32
#Printing the temperature
print(tb)
OUTPUT:
Water Boiling temperature in Fahrenheit::
212.0
Water Freezing temperature in Fahrenheit::
32.0
QUESTION 10
#Asking the user for Principal, rate of interest and time
P = float(input('Enter the principal: '))
R = float(input('Enter the rate of interest per annum: '))
T = float(input('Enter the time in years: '))
#calculating simple interest
SI = (P * R * T)/100
#caculating amount = Simple Interest + Principal
amount = SI + P
#Printing the total amount
print('Total amount:',amount)
OUTPUT:-
Enter the principal: 12500
Enter the rate of interest per annum: 4.5
Enter the time in years: 4
Total amount: 14750.0
QUESTION 11
#Program to input two numbers and performing all arithmetic operations
OUTPUT:
Enter first number: 8
Enter second number: 3
Results:-
Addition: 11
Subtraction: 5
Multiplication: 24
Division: 2.6666666666666665
Modulus: 2
Floor Division: 2
Exponentiation: 512
QUESTION 12
OUTPUT:
The values of x and y are 5 and 6 respectively.
The values of x and y after swapping are 6 and 5 respectively.
SR NO QUESTIONS
The physical and tangible electronic components of a computer
The programs which provide commands to work upon and govern the
working on the computer is known as _______. (Ans. Software)
Which part of the CPU carries out the arithmetic instructions and logical
comparison to complete the task? (Ans. ALU)
The small units of data storage hold the places of data in the CPU is
_______. (Ans. Register)
When the power is turned off, data will be lost. This is known as
_________. (Ans. Volatility)
The ______ is volatile memory where ________ non-volatile memory.
(Ans. RAM, ROM)
The PROM is call _______, which stands for One Time Programmable
memory. (Ans. OTP)
The EPROM can take _______ minutes for erasing contents written on
them. (Ans. 20)
The output carried out from the mobile system using _____________
systems. (Ans. Display)
The set of some basic applications are provided by _____ type for
application software. (Ans. Packages)
The pre-written code that can be used to develop applications are known
as _______. (Ans. Libraries)
The _______ software rearranges the files in the computers and cleans up
the memory. (Ans. Disk defragmenter)
Answer:
3
Answer:
3
What gets printed?
namesl = [‘Amir’, ‘Barry’, ‘Chales’, ‘Dao’]
if ‘amir’ in namesl:
print 1
7
else:
print 2
Answer:
2
Start with the list[8,9,10].
Do the following using list functions
(a) Set the second entry (index 1) to 17
(b) Add 4, 5 and 6 to the end of the list.
8
(c) Remove the first entry from the list.
(d) Sort the list.
(e) Double the list.
(f) Insert 25 at index 3
answer
(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)
Find out the output generated by following code fragments:
(a) plane = (“Passengers”, ”Luggage”) plane [1] = “Snakes”
(b) (a, b, c) = (1,2,3)
(c) (a, b, c, d) = (1,2,3)
(d) a, b, c, d = (1,2,3)
(e) a, b, c, d, e = (p, q, r, s, t) = t1
9
answer:
(a) TypeError: 'tuple' object does not support item assignment
(b) This will assign 1 to a, 2 to b and 3 to c.
(c) ValueError: not enough values to unpack (expected 4, got 3)
(d) ValueError: not enough values to unpack (expected 4, got 3)
(e) If tuple t1 has 5 values then this will assign first value of t1 in to a and
p , next value to b and q and so on.
What is Authentication and Authorization? Why are these two used
together?
10
Difference between Authentication and Authorization. Both the terms are
often used in conjunction with each other in terms of security, especially
when it comes to gaining access to the system. Authentication means
confirming your own identity, while authorization means granting access
to the system.
FLOW OF CONTROL
CONTENT – REVIEW
Flow control statements are used to control the flow of execution depending upon the
specified condition/logic.
Sequential Flow of control - Sequential execution is when statements are executed one after
another in order. We don't need to do anything more for this to happen as python compiler
itself do it.
There are three types of control statements.
1. Selection Statements
2. Iteration Statements (Loop control statement)
3. Jump Statements (break, continue, pass)
Selection statement
These are used to selectively execute some statements and control the flow of execution of
program depending upon condition.
There are three types of decision making statement.
1. if statements
2. if-else statements
3. if elif statement
Simple if:
The statement inside the if block are executed only when condition is true, otherwise not.
Syntax
if <condition>:
Statement(s)
Example:
if a < b :
print(‘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
Example:
if a < b :
print(‘a is greater’)
else:
print(‘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.
print('****program to find greatest of 3 numbers****')
num1,num2,num3=eval(input('enter 3 unique numbers: '))
if num1 > num2 and num1 > num3:
print('The greatest of the three nos. is : ',num1)
elif num2 > num3 and num2 > num1:
print('The greatest of the three nos. is : ',num2)
elif num3 > num1 and num3 > num2:
print('The greatest of the three nos. is :',num3)
else:
print('any two nos are equal')
Nested if-else Statements
#Check leap year / divisibility
year = int(input("Enter a year: "))
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
Iteration statements(loop)
These are used to execute a block of statements as long as the condition is true. Loops
statements are used when we need to run same code again and again.
print(Counter)
OUTPUT:
4 Loop
For
It is used to iterate over items of any sequence, such as a list or a string.
Syntax
for val in sequence: #here val will take value of each element in the sequence
statements
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)
b. range(start,stop)
c. range(start,stop,step)
Note:
a. range(stop): By default, It starts from 0 and increments by 1 and ends upto stop,
but not including stop value.
Example:
for x in range(4):
print(x)
Output:
0
1
2
3
b. range(start,stop) : It starts from the start value and upto stop, but not including
stop value.
Jump Statements
Jump statements are used to transfer the program's control from one location to
another. Means these are used to alter the flow of a loop like - to skip a part of a loop or
terminate a loop
There are three types of jump statements used in python.
1.break / 2.continue / 3.pass
Break
It is used to terminate the loop.
e.g.
for val in "string":
if val == "i":
break
print(val)
print("The end")
Output
str
The end
Continue
• 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.
• Can be used with both while & for. Eg:
for letter in ‘Python’:
if letter == ‘h’:
continue
print (letter)
Output
Pyton
Pass Statement
This statement does nothing. It can be used when a statement is required syntactically but the
program requires no action.
Use in loop :
while True:
pass # Busy-wait for keyboard interrupt (Ctrl+C)
WORKSHEETS
Sr Question
no
Q1 Can we write if/else into one line in python?
a) Yes
b) No
c) if (a => 22)
d) if a >= 22
b) elseif
c) elif
Q4 What will be the data type of the var in the below code snippet?
var = 10
print(type(var))
var = "Hello"
print(type(var))
b) Indentation
c) Key
a = [1, 2, 3] a =
tuple(a) a[0] = 2
print(a)
a) [1,2,3]
b) (1,2,3)
c) [2,2,3]
d) error
a) [ ‘ab’, ‘cd’ ]
b) [‘AB’, ‘CD’]
c) [None, None]
a) 5 6 7 8 9 10
b) 5678
c) 56
d) error
Q10 What will be the output of the following Python code? i = 1 while
True: if i%3 == 0:
break
print(i)
i+=1
a) 1 2
b) 1 2 3
c) error
III. var = 7
while var > 0:
print (“current variable value: ” , var)
var = var – 1
if var == 3:
break
else:
if var == 6:
var = var – 1
continue
print (“Good bye!”)
2 Write a Python program to find the factorial of a positive number Q6)
What are the four elements of a while loop in Python?
3 What are endless loops ? Why do such loops occur? Give example.
4 Draw flowchart for displaying first 10 odd numbers.
5 What is a flowchart? How is it useful?
6 What is empty statement in Python? What is its need?
7 Write a program to check whether a years is leap year or not.
COMPETENCY BASED
SECTION A: MCQ
1.The first line of Python code can’t have an indentation. Say True or False
Ans: True
2. Which of the following expression is not allowed in if statement
a) arithmetic expression b) relational expression c) logical expression d) none
Ans: a.
3. x=[ ‘P’ , ‘ y’ , ‘t’ , ‘h’ , ‘o’ , ‘n’ ]
for i in x:
print(i,end=’’)
`a) P b) python c) P y t h o n d) PYTHON
Ans: c
4. Function range(3) is equivalent to :
a) range(1,3) b) range(0,3) c) range(0,3,1) d) range(1,3,0)
Ans: b or c
5. The else block of a loop will not get executed if a ……….statement has
terminated
the loop.
Ans: break
6. The range() function can only be used in ……… loops
Ans: for
7. The in and not in operators are also called as ………….
Ans: membership operators
8. For a while loop, an equivalent for loop can always be written. Say True or
False.
Ans: False
9. The range() function generates a sequence of …………type
Ans: list
10. for is a ……. loop whereas while is a ……….loop
Ans: counting, conditional
FUNCTION - MODULES
CONTENT – REVIEW
TOPIC: FUNCTIONS
One of the main advantages of Python is the availability of a vast library of modules that can
be used for different purposes.
A module is a logical organization of Python code. Related code are grouped into a module
which makes the code easier to understand and use. Any python module is an object with
different attributes which can be bind and referenced.
Python programs can get access to code from another python module by importing the
file/function using import. The import statement is the most common way of invoking the
import machinery
There are three ways to access the code of other built-in/user defined modules using import
• import module_name
• from module_name import function_name/constant/object
• from module_name import *
import module_name
EXAMPLE
import math
print(math.pi)
# this searches for the module and links the module code to the module name in local scope.
#The module objects need to be prefixed with the module name to ensure name resolution.
from module_name import *
EXAMPLE:
from math import *
print(pi)
#this searches for the module and copies all the contents of the module into the global
memory of the importing program.
math Module
Python has a built-in module that you can use for mathematical tasks.
The math module has a set of methods and constants. Some of the important ones are:
Method Description
math.ceil() Rounds a number up to the nearest integer
math.cos() Returns the cosine of a number
math.fabs() Returns the absolute value of a number
math.factorial() Returns the factorial of a number
math.floor() Rounds a number down to the nearest integer
math.pow() Returns the value of x to the power of y
math.prod() Returns the product of all the elements in an iterable
Returns the closest value that can make numerator completely
math.remainder() divisible by the denominator
math.sin() Returns the sine of a number
math.sqrt() Returns the square root of a number
math.tan() Returns the tangent of a number
math.trunc() Returns the truncated integer parts of a number
Math Constants
Constant Description
Returns Euler's number
math.e (2.7182...)
Returns a floating-point positive
math.inf infinity
Returns a floating-point NaN
math.nan (Not a Number) value
math.pi Returns PI (3.1415...)
math.tau Returns tau (6.2831...)
Random Module
Python has a built-in module that you can use to make random numbers. Some of the methods
in the random module are:
Method Description
Statistics module
Python has a built-in module that you can use to calculate mathematical statistics of numeric
data.
Method Description
Calculates the harmonic mean (central location) of
statistics.harmonic_mean() the given data
statistics.mean() Calculates the mean (average) of the given data
Calculates the median (middle value) of the given
statistics.median() data
statistics.median_grouped() Calculates the median of grouped continuous data
statistics.median_high() Calculates the high median of the given data
statistics.median_low() Calculates the low median of the given data
Calculates the mode (central tendency) of the given
statistics.mode() numeric or nominal data
Calculates the standard deviation from an entire
statistics.pstdev() population
Calculates the standard deviation from a sample of
statistics.stdev() data
statistics.pvariance() Calculates the variance of an entire population
statistics.variance() Calculates the variance from a sample of data
WORKSHEETS
SL QUESTION
NO
1 Predict the output:
from math import *
x=10
y=pi * sqrt(pow(x,4))
2 Identify the errors and correct them:
Import math
Y=25
S=sqrt(Y)
print(S)
3 Predict the output:
import math
num=90.23
print(math.ceil(num))
print(math.floor(num))
4 Predict the output: (What are the possible values?)
import random
print(random.random(5))
5 Predict the output:
li=[1,2,3,4,5,6,7,8,9,10]
from statistics import *
print(mean(li))
print(median(li))
6 Identify the errors and correct them:
li=[1,2,3,4,5,6,7,8,9,10]
from statistics import *
print(li.mean())
print(statistics.median(li))
7 Predict the output: (What are the possible values?)
import random
print(random.randint(5,10))
8 Predict the output: (What are the possible values?)
import random
print(random.randrange(10,20,2))
9 Write program to find square root of a function using math module
10 Predict the output:
li=[1,2,3,4,4,4,4,4,4,5,5,5,5,5,6,7,8,8,8,8,9,10]
from statistics import *
print(mode(li))
STRINGS
CONTENT – REVIEW
WORKSHEETS
CLASS: XI (LEVEL 1)
1. If first= “FIRE STOP” with string values then what will be the output of first[3] and
first[6].
2. Write the name of membership operators used for string data type.
3. What will be the result of following expression:
a. len(“Papaya”)
b. “Co” in “country
c. “divya”>”Divya
4. Evaluate following expressions for given string :
string1=”My work”
a. string1[3:6]
b. string1[: : 2]
c. string1*2
5. Write differences between upper() and isupper() functions.
6. Asha is using Python idle and try to capitalize first character of each word and using
following code:
address= “ ram sita radha riya”
address.upper()
But all the characters changed in uppercase , so suggest her the built in function name which
can fulfill her requirements.
7. Which of the following operator is used for concatenation of two strings?
a. - b. * c. + d. /
8. Which function will remove leading space from the given string?
9. Find out the errors and write the correct code :
a= “hello”
b=a* ”2”
c=a+b
10. Write a program which can check whether the given character is uppercase or lowercase
letter
CLASS: XI (LEVEL 2)
1. Which of the following function is used for checking whether the given value is number
or not:
a. isalpha() b. isdigit() c. isalnum() d. None of the above
2. How is capitalize() function different from upper() function?
3. What will be the output of following code:
str= “Hello India”
p=2 * str + 2* “wow”
print(p)
4. Write down the output after performing given function:
a. ”Very good”.title()
b. “ Bye Bye”.rstrip()
c. “favourite.index(‘u’)
5. What is the use of endswith() function?
6. Pooja is writing a program for entering mobile number of her friends and try to check
whether the given input is number and writing following code:
a= int(input(“enter phone no.”))
If a.isalnum()==True:
print(“valid number”)
else:
print(“not valid”)
So suggest her the correct function for getting her desired output and write correct code.
7. Find out the error in the given code and write the reason :
name=”priyanshi”
name[4]=a
8. Write the difference between endswith() and endswith()
9. Define slicing and explain with examples.
10.Write a program which replaces all vowels in the string with ’*’ .
CLASS: XI (LEVEL 3)
1. What is the use of join () function and write one example?
2. Write the output of following code:
first=” Programming Language Learning work”
first.partition(“Language”)
3. What is the difference between join and partition?
4. Evaluate the following expression :
a. “$$”.join(“My”, “Godness”)
b. “No need “.rstrip()
c. “Going For walk”.split(“ “)
5. Find the output of following statements:
str1= “Interesting”
print(str1[2:7])
print(str1[-1:-5:-1])
print(str1[: : 2])
print(str1[-5:0:1])
6. Function………………… raises an exception if the substring is not found.
7. s= ‘ ‘ (single space).Then s.isalnum() will return .
a. True b. False c. Error d. None
8. Ravi wanted to search the index of the word “work” in his program and wrote the following
code in Python but it produced a value error. He did not understand what was wrong with the
code .
“My School work”.index(“ Work”)
Suggest him the code(other function name) which will not produce errors.
9. Write a program to input a string and calculate the length of each word present in string
and print length along with the word.
10.a Write a program to input a string and print the total number of uppercase and lowercase
letters in a given string.
COMPETENCY BASED
1. Asha is using Python idle and try to capitalize first character of each word and using
following code:
address= “ ram sita radha riya”
address.upper()
But all the characters changed in uppercase , so suggest her the built in function name
which can fulfill her requirements.
2. Pooja is writing a program for entering mobile number of her friends and try to check
whether the given input is number and writing following code:
a= int(input(“enter phone no.”))
If a.isalnum()==True:
print(“valid number”)
else:
print(“not valid”)
So suggest her the correct function for getting her desired output and write correct code.
3. Ravi wanted to search the index of the word “work” in his program and wrote the
following code in Python but it produced a value error. He did not understand what was
wrong with the code .
“My School work”.index(“ Work”)
Suggest him the code(other function name) which will not produce errors.
COMPETENCY BASED QUESTION
1. Write a program to input a string and calculate the length of each word present in string
and print length along with the word.
2. Write a program to input a string and print the total number of uppercase and lowercase
letters in a given string.
3. A string is given of three or more words, now the task is to write a Python program to
check whether a specific word is present in that given string.
4. program to read a string and display it in reverse order- display one character per line.
FLASH CARDS
LISTS MANIPULATION
CONTENT – REVIEW
WORKSHEETS
1. If L= [15, 25, 30, 5, 10, ‘python’, ‘program’] then what will be the output of L[5] and
L[2].
2. Why are lists called mutable types?
3. Write the name of the joining operator used for list data type.
4. Evaluate following expressions for given list:
a = [5, 4, 3, 10, 6]
i. a[0]
ii. a[-2]
iii. a[2:5]
5. What will be the result of following expression:
L=[20, 3, 5, 11, 15]
a. len(L)
b. L + “abc”
c. L * 3
6. What is the difference between pop( ) and remove( ) method.
7. Which of the following operator is used for replicating a list?
a. - b. * c. + d. /
8. Which function will return the smallest element from a list?
9. Find out the errors and write the correct code :
a=[5, 6, 3, 4, 1]
b=a* ”3”
c=a+b
10. Write a program to find the largest and smallest number in a list.
iii)list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::-2]
list1[:3] + list1[3:]
iv)list1 = [1,2,3,4,5]
list1[len(list1)-1]
8. Find out the error in the given code and write the reason :
sub=[‘eng’, ‘cs’, ‘ip’, ‘maths’, ‘che’]
sub + ‘phy’
9. Write the difference between sort( ) and sorted( ) functions.
10.Define slicing and explain with examples.
11.Write a program to input a list and an element, and remove all occurrences of the given
element from the list.
FLASH CARDS
TUPLES
CONTENT – REVIEW
WORKSHEETS
Tuple – Worksheet L1 1. A tuple is declared as T = (12,5,6,9,8) What will be the value of sum(T)?
2. Which of the following is a Python tuple?
COMPETENCY BASED
1. Write a program to input your friends name and their phone numbers, and store them as key
value pair in Dictionary
Perform the following operations
a) Display name and phone number of all your friends
b) Search for a friends name in your list , if found display their phone number
c) Delete a particular friend
d) Modify the phone number of an existing friend
e) Display the dictionaries in sorted order of friends
2. Write a program to create a dictionary from a String which tracks down no of items a
character is present in the string
3.Write a program to read email IDs of n number of students and store them in a tuple. Create
two new tuples, one to store only the usernames from the email ids and second to store the
domain names from the email ids. Print all three tuples at the end of the program.[Hint : you
may use the function split()]
4. Write a program to print the frequency of a number accepted from the user in the given tuple.
5. Create a dictionary which contains dice combinations as( tuple) keys and the prizes awarded
as values.
Write a program to take lot or ask user to enter the dice combination, check in the dictionary
and print appropriate message
DICTIONARIES
CONTENT – REVIEW
Dictionary
Unordered collection of items / elements. Each item has two parts - key : value
Are optimized to retrieve data using key. So key (values) should be unique.
D[key] can be used for accessing element, also to add element in an existing dictionary.
Creation- Using
built - in function dict()
assignment operator creates deep copy
copy() creates shallow copy
{} to create blank dictionary
Shallow and Deep Copy
Accessing Items
Accessing Items…
Adding an item
Updating an Item
Traversing
Built – in Functions
Built – in Functions
WORKSHEETS
2.
b. a = {}
a[1] = 6
a['1'] = 2
a[1]= a[1]+1
count = 0
for i in a:
count += a[i]
print(count)
CONTENT – REVIEW
• A digital footprint is an impact you create on the Web through your online activity,
which incorporates browsing, interactions with others, and publication of content.
• In other words, it can be considered as the data trail – intentional and unintentional -
you leave behind while you surf the Web or Internet.
• Digital footprint or digital shadow refers to the trail of data left behind through the
utilization of the Web or on digital devices.
• The digital footprint of any person can have a positive as well as a negative impact on
him.
• Anyone who uses digital technology along with Internet is a digital citizen or a netizen.
Being a good netizen means practicing safe, ethical and legal use of digital technology.
A responsible netizen must abide by net etiquettes, communication etiquettes and
social media etiquettes.
→ Net Etiquettes:
o Be Ethical
o Be Respectful
o Be Responsible
→ Communication Etiquettes :
o Be Precise
o Be Polite
o Be Credible
→ Social Media Etiquettes:
o Be Secure
o Be Reliable
Data Protection:
Elements of data that can cause substantial harm, embarrassment, inconvenience and
unfairness to an individual, if breached or compromised, is called sensitive data. Examples
of sensitive data include biometric information, health information, financial information, or
other personal documents, images or audios or videos. All over the world, each country has
its own data protection policies (laws). These policies are legal documents that provide
guidelines to the user on processing, storage and transmission of sensitive information.
Intellectuals Property refers to the inventions, literary and artistic expressions, 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.
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. It prevents others from copying, using or
selling the work.
Patent:
A patent is usually granted for inventions. Unlike copyright, the inventor needs to
apply (file) for patenting the invention. When a patent is granted, the owner gets an exclusive
right to prevent others from using, selling, or distributing the protected invention.
Trademark:
Trademark includes any visual symbol, word, name, design, slogan, label, etc., that
distinguishes the brand or commercial enterprise, from other brands or commercial
enterprises. For example, no company other than Nike can use the Nike brand to sell shoes
or clothes.
Violation of IPR
Violation of intellectual property right may happen in one of the following ways:
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.
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. Suppose we download an
image from the Internet and use it in our project. But if the owner of the copyright of the
image does not permit its free usage, then using such an image even after giving reference of
the image in our project is a violation of copyright.
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.
General Public License(GPL):
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.
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.
Apache:
The Apache License is a permissive free software license written by the Apache
Software Foundation (ASF). It allows users to use the software for any purpose, to distribute
it, to modify it, and to distribute modified versions of the software under the terms of the
license, without concern for royalties.
Cyber crime:
Cybercrime is a crime that involves a computer and a network. The computer may
have been used to commit the crime and in many cases, it is also the target. Cybercrime may
threaten a person or a nation’s security and financial health..
Hacking:
An effort to attack a computer system or a private network inside a computer is
known as hacking. Simply, it is unauthorized access to or control of computer network
security systems with the intention of committing a crime. Hacking is the process of finding
some security holes in a computer system or network in order to gain access to personal or
corporate information. One example of computer hacking is the use of a password cracking
technique to gain access to a computer system. The process of gaining illegal access to a
computer system, or a group of computer systems, is known as hacking. This is
accomplished by cracking the passwords and codes that grant access to systems. Cracking
is the term used to describe the process of obtaining a password or code. The hacker is the
individual who performs the hacking. Following are some of the things that can be hacked:
• Single systems
• Email account
• A group of systems
• LAN network
• A website
• Social media sites, etc
Eavesdropping;
It is the act of secretly listening to a private conversation of others without
their consent. The main purpose of eavesdropping is to steal data.
Phishing:
• It is the way in which an authentic looking webpage or website is created
to get sensitive information of users which may include their name,
password, phone number, email address and bank details.
• So you must look at address bar of web browser to verify the name of
website where you are providing your information .
Ransomware:
• Ransom ware is a malware that hold data of persons at ransom. This data is encrypted
and the user is unable to access his personal files or organizational files. The user has
to pay a ransom price in order to get back his files and data.
• Ransomware attacks can be detected using security parameters like software that can
detect malicious files in the system. Most of these ransomwares are hidden files they
get into the system when certain programs or software’s are being downloaded from
the internet which are unsafe to the users.
Following points can be considered as safety measures to reduce the risk of cyber
crime:
Cyber Safety:
The world is becoming more digital with each passing day. Along with development,
comes the threat of cyber attacks. Through this blog, you will understand what is cyber safety
and the various aspects of cyber safety. You will also understand how cyber safety and
security are important.
One of the prime reasons for implementing Cyber Safety is the protection of
confidential data. Cyber Safety can protect these data to a great extent. These data protection
go a long way, especially in cases of government-related data. Breach of such data of national
importance can cause serious disturbance to the nation.
Data privacy is important in this digital world. For example, breach of personally
identifiable information (PII), intellectual property, and protected health information (PHI)
would make people lose faith in the service and the possibility of recovering lost customers
or building faith again is a herculean task. This is usually applicable in the sectors of hospitals
and other healthcare institutions, financial service programs, and power plants.
However, the most fearsome aspect of the data breach through any cyberattack is the
mishandling of data.Through the following segment, you will understand the various types
of cyber attacks. Based on the understanding of cyber-attacks and why cyber safety is
important, you can implement cyber safety measures accordingly.
Malware:
Malware, or malicious software, is any program or file that is harmful to a computer
user. Malware includes computer viruses, worms, Trojan horses and spyware. These
malicious programs can perform a variety of functions, including stealing, encrypting or
deleting sensitive data, altering or hijacking core computing functions and monitoring users'
computer activity without their permission.
Programs officially supplied by companies can be considered malware if they secretly act
against the interests of the computer user. For example, company ABC sold the rootkit, which
contained a Trojan horse embedded into CDs that silently installed and concealed itself on
purchasers' computers with the intention of preventing illicit copying. It also reported on
users' listening habits, and unintentionally created vulnerabilities that were then exploited by
unrelated malware.
One strategy for protecting against malware is to prevent the malware software from gaining
access to the target computer. For this reason, antivirus software, firewalls and other
strategies are used to help protect against the introduction of malware, in addition to checking
for the presence of malware and malicious activity and recovering from attacks.
Virus:
A computer virus will more than likely have an adverse effect on the device it resides
on and may be discoverable through common signs of performance loss, including:
Speed of System
A computer system running slower than usual is one of the most common signs that
the device has a virus. This includes the system itself running slowly, as well as applications
and internet speed suffering. If a computer does not have powerful applications or programs
installed and is running slowly, then it may be a sign it is infected with a virus.
Pop-up Windows
Unwanted pop-up windows appearing on a computer or in a web browser are a telltale
sign of a computer virus. Unwanted pop-ups are a sign of malware, viruses,
or spyware affecting a device.
Programs Self-executing
If computer programs unexpectedly close by themselves, then it is highly likely that
the software has been infected with some form of virus or malware. Another indicator of a
virus is when applications fail to load when selected from the Start menu or their desktop
icon.
In computing, a Trojan horse is a program that appears harmless, but is, in fact,
malicious. Unexpected changes to computer settings and unusual activity, even when the
computer should be idle, are strong indications that a Trojan is residing on a computer.
A Trojan horse may also be referred to as a Trojan horse virus, but that is technically incorrect.
Unlike a computer virus, a Trojan horse is not able to replicate itself, nor can it propagate
without an end user's assistance. This is why attackers must use social engineering tactics to
trick the end user into executing the Trojan. Typically, the malware programming is hidden in
an innocent-looking email attachment or free download. When the user clicks on the email
attachment or downloads the free program, the malware that is hidden inside is transferred to
the user's computing device. Once inside, the malicious code can execute whatever task the
attacker designed it to carry out.
The Government of India’s Information Technology Act, 2000 (also known as IT Act),
amended in 2008, provides guidelines to the user on the processing, storage and transmission
of sensitive information. In many Indian states, there are cyber cells in police stations where
one can report any cyber crime. The act provides legal framework for electronic governance
by giving recognition to electronic records and digital signatures. The act outlines cyber
crimes and penalties for them.
WORKSHEETS
Level 1
6. What is Malware?
7. What is adware?
8. What is Spyware?
9. What is Phishing?
Worksheet Level 2
3. The transformation of key business processes through the use of digital or Internet
technologies is known as ____________
a) E-business
b) E-Commerce
c) Digital Business
d) Both A and C
4. A _________ community is one where the interaction takes place over a computer
network, mainly the Internet.
a) Online
b) Virtual
c)Internet
d) All of the above
5. _________ has specific objectives to increase profits when increasing its benefits to
society.
a) Digital Business
b) Social Network
c)Social Enterprise
d) Virtual Community
8. Which of the following is an important aspect of creating blogs and posting content?
a) Using a witty user name
b) Posting at least once a month to the blog
c) Social Media Optimization
d) All of the above
10. Which of the following is not specifically required by the search engines?
a) Poor user experience
b) Keyword stuffing
c)Buying links
d) All of the above
COMPETENCY BASED
1. Smridh has recently changed his school so he is not aware of the people, but someone
is posting negative ,demeaning comments on his social media profile. He is also getting
repeated mails from unknown people. Everytime he goes online, he finds someone
chasing him online.
i) Smridh is a victim of …………. :
a) Eavesdropping
b) Stolen identity
c) Phishing
d) Cyber stalking
Ans: d
ii) The action that Smridh should take :
a) He should ONLY share with his friends
b) He should NOT share with anyone as it can cause serious problem
c) He should immediately report to the police
d) He should bring to the notice of his parents and school authorities.
Ans: d
2. 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.
iii) Anonymous online posts/comments can _________ be traced back to the author.
a) Always
b) Never
c) Sometimes
d) Many Times
Ans: a
FLASH CARDS
infect
File Viruses executable files
or BAT files.
Usually in VBA infects
MS office template files
Macro virus
(excel or word) Melissa
was an example
Hacking the
Phlashing software in flash
memory firmware
General Instructions:
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
SECTION A
4. Which function out of the following will return the data type of the 1
object:
a. type() b. id() c. ord() d. str()
SECTION B
21. 2
D = {‘red’:10, ‘blue’:15} is a dictionary in python.
22. 2
Find the output of the following code:
a, b, c=10, 20, 30
b=b+2
a+=2
c-=b
print(a,b,c)
25. Vikas has to make an online transaction through net banking. He wants 2
to make sure that he is opening the genuine bank website and not some
fake page. Write any two ways in which he can identify if his
connection to the banking website is secure.
SECTION C
(i) print(List[2:6:2])
(ii) print(List+['a','b'])
(iii) print(4 in List)
28. Write a Python program to display the sum and mean/average of first 3
n natural numbers.
29. State two differences between lists and tuples with example. 3
30. What are the gender and disability issues while teaching and using 3
computers? What solutions do you suggest to handle such issues?
SECTION D
31. a) Draw the equivalent logic circuit for the following Boolean 5
Expression:
A’.(B+C’)
b) Name the law shown below and verify it using a truth table:
A+B.C=(A+B).(A+C)
c) Convert the following:
(i) (106)10 = ( ? )2
(ii) (111100111100)2 = ( ? )8
(iii) (B2F)16 = ( ? )8
for i in dict.values():
b=b+i
print(b)
33. 5
(i)Write the output of the following Python code-
t = (1,2,3,4,5,3,2,3,4,5,2,1)
print(t.count(2))
print(t.index(2))
SECTION E
list1=[3,2,1,0,1,2,3]
list1.remove(3)
print('SUM OF LIST:',sum(list1))
list1.insert(6,4)
print('UPDATED LIST1:',list1)
newList=L[:3]+list1[3:]
print('NEW LIST:',newList)
35. 4
(a) Match the following:
Column A Column B
Credit card fraud The trail that is created when a person uses the
Internet
(b) In school, Navneet forgot to sign out from his email account
while leaving the computer laboratory. Later, his classmate
Ankit started using the same computer. He is now logged in as
Navneet. He sends inflammatory email messages to few of his
classmates using Navneet’s email account. Ankit’s activity is an
example of which of the following cyber crime? Justify your
answer.
a) Hacking
b) Identity theft
c) Cyber bullying
d) Plagiarism
Class: XI Session: 2022-23
MARKING SCHEME
General Instructions:
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
SECTION A
c. Oracle
b. Utility
a. 5Total
4. Which function out of the following will return the data type of the 1
object:
a. type() b. id() c. ord() d. str()
a. type()
a. 2
c. day
b. //
b. 3
b. ==
10. Which out of the following is immutable data type? 1
a. List b. int c. String d. both b and c
d. both b and c
a. in
b. break
d. pass
a. [0, 2, 4]
Open source software is software with source code that anyone can
inspect, modify, and enhance.
SECTION B
10
T1=(10,)
For correct statement 1 mark
21. 2
D = {‘red’:10, ‘blue’:15} is a dictionary in python.
(i) D[‘black’]=25
(ii) D[‘red’]=15
22. 2
Find the output of the following code:
a, b, c=10, 20, 30
b=b+2
a+=2
c-=b
print(a,b,c)
12 22 8
25. Vikas has to make an online transaction through net banking. He wants 2
to make sure that he is opening the genuine bank website and not some
fake page. Write any two ways in which he can identify if his
connection to the banking website is secure.
SECTION C
[14, 'apple']
False
28. Write a Python program to display the sum and mean/average of first 3
n natural numbers.
n = int(input("Enter number"))
sum = 0
# loop from 1 to n
for num in range(1, n + 1):
sum = sum + num
print("Sum of first ", n, "numbers is: ", sum)
average = sum / n
print("Average of ", n, "numbers is: ", average)
29. State two differences between lists and tuples with example. 3
SECTION D
31. a) Draw the equivalent logic circuit for the following Boolean 5
Expression:
A’.(B+C’)
b) Name the law shown below and verify it using a truth table:
A+B.C=(A+B).(A+C)
c) Convert the following:
(i) (106)10 = ( ? )2
(ii) (111100111100)2 = ( ? )8
(iii) (B2F)16 = ( ? )8
a)
b)distributive law
½ mark for name of law, ½ mark for truth table
c)
(i) 1101010
(ii)7474
(iii) 5457
(i)
1
1 mark- for each correct output
(ii)3 marks
1 mark - for each correct explanation of function with example
SECTION E
list1=[3,2,1,0,1,2,3]
list1.remove(3)
print('SUM OF LIST:',sum(list1))
list1.insert(6,4)
print('UPDATED LIST1:',list1)
newList=L[:3]+list1[3:]
print('NEW LIST:',newList)
ITEM: 20
SUM OF LIST: 9
UPDATED LIST1: [2, 1, 0, 1, 2, 3, 4]
NEW LIST: [10, 30, 1, 2, 3, 4]
1 mark for each correct output
35. 4
(a) Match the following:
Column A Column B
Credit card fraud The trail that is created when a person uses the
Internet
(b) In school, Navneet forgot to sign out from his email account
while leaving the computer laboratory. Later, his classmate
Ankit started using the same computer. He is now logged in as
Navneet. He sends inflammatory email messages to few of his
classmates using Navneet’s email account. Ankit’s activity is an
example of which of the following cyber crime? Justify your
answer.
a) Hacking
b) Identity theft
c) Cyber bullying
d) Plagiarism
a) 2 marks
Hacking
Ransomware
Identity theft
SECTION A
What is phishing?
17. 1
SECTION B
b=7.4
c=1
a-=b
print (a, b)
a*=2+c
print(a)
b+=a*c
print( b )
elif x<2:
if (x!=0):
print(“C”,end=””)
print(“D”)
SECTION C
28. WAP to find minimum and maximum element in the given tuple. 3
What are the gender and disability issues while teaching and using
30. computers? What solutions do you suggest to handle such issues? 3
SECTION D
t = (1,2,3,4,5,3,2,3,4,5,2,1)
print(t.count(2))
32. 5
print(t.index(2))
length = len(str(num))
for i in range(length):
digit = int(num%10)
num = num/10
sum += pow(digit,_________)
if sum==number:
print(_______________)
else:
print(_______________)
SECTION E
Sample Dictionary(n=5):
Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
34. b)Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” 3+1
what command do we use?
a)d.delete(“john”:40)
b)d.delete(“john”)
c)del d[“john”]
d) del d(“john”:40)
35. 4
1. Match the following:
Column A Column B
Q. Question Ma
No rks
SECTION A
1.a 25616 = _______2 1
)
b) Which of the following is/are the universal logic gates? 1
A. OR and NOR B. AND C. NAND and NOR D.
NOT
c) ______________ is the term for a program being run by the computer 1
d) When we work on any document on PC, it is stored temporarily in______ 1
memory
G) Draw the logic circuit for the Boolean expression: F=AB’ +(CD)’ 2
H) Give full form of: 3
i) ISCII
ii) MICR
iii) OCR
SECTION B
2.a identify the valid identifiers from the following: 1
) i) myname1 ii) While iii) 1stname iv) for
b) ‘All the Best!’.__________ will produce the list [‘All’,’the’,’Best!’] 1
c) evaluate the expression: 15+3*2-(9**0.5) 1
d) Value=(“abcd”,[1,2,3],10,”xyz’) 1
Identify the data type of Value
(i) list (ii) dictionary (iii) string (iv) tuple
e). import random 1
X=random.randint(1,4)
In the above code, X will take minimum value______ and maximum
value________
f) Correct the errors in the given code and underline the corrections 2
Num = input("Number:")
Sum = 0
For i in range(10,Num)
Sum+=i
if i%5
print( i*2)
Else:
print ( Sum)
3.a Predict the output of the following code snippet if N is given the value 2: 3
) N=int(input(“enter a number”))
C=1
while (C<8):
if(C==3 or C==5):
C+=1
continue
print(C,’*’,N,’=’,C*N)
C+=1
b) Write a program to get a list of numbers from the user and triple the value of 2
all the elements at the even position. For example, if the list entered is
[1,2,3,4,5,6]
the resultant list should be [3,2,9,4,15,6]
c) Write 2 mutable and 2 immutable datatypes 2
d) Give the output of the following code 2
T=(2,’abc’,39)
X,Y,Z=T
print(X,Y*2,Z//4)
e) Write a program to check if a string given by the user is a palindrome or not 2
and display the result
f) Write any four safety measures that can reduce the risk of cyber crime 2
g) Ms Sharmishtha has many electronic gadgets which are not usable due to 2
outdated hardware and software. Help her to find three best ways to dispose
the used electronic gadgets.
4.a A=100 1
) print(a)
What is the exception that will occur and why?
b) Give the output: 1
import statistics as M
L=[1,2,3,4,5,6,7,8,9,10]
print(M.mean(L))
c) If L =[10,14,18,22,’four numbers’], evaluate and write the output of the 2
following
I) L[1::3]
II) L[4][0:4]
d) What will the output for following code? 3
S='Model Exams 2022. Computer Science'
L=S.split()
for I in L:
if I[0]=='C':
print('CS')
elif I[0]=='E':
print('Experiment')
elif I.isdigit():
print('0000')
else:
print(I)
e) Write the difference between list and dictionary with example 2
f) Write program to find factorial of a given number 2
g) i) ______________ function in list is used to add multiple elements at end 2
of list
SECTION C
5.a Identify the type of cyber crime for the following situations:
)
1. Sabhya quickly downloads a 2-minute clip from the internet explaining the
concept of
dictionary in Python. Using video editor, he adds the text “Prepared by
Sabhya” in the
downloaded video clip. He then emails the modified video clip to Ahaana.
This act of Sabhya is an example of:
(a) Fair use (b) Hacking (c) Copyright infringement (d) 5
Cybercrime
2. Ms. Kavita complains that her debit/credit card is safe with her still
somebody has
done shopping /ATM transaction on this card.
4. Ravi received an email from First Generic Bank (as shown below). On
clicking the link,
he was taken to a site designed to imitate an official looking website. He
uploaded
some important information on it.
5. After a fight with your friend, you created an embarrassing picture of your
friend and
uploaded on your account on a social networking site.
b) Write a Python Program to find max among three input numbers using if - elif
5
statement
c) Results is a dictionary containing Name and Score of students in key: value
pair.
Results= {“A”:240,”B”:340,”C”:350,”D”:280,”E”:370}
Perform following operations on it.
OR 5
Q. Question
No
SECTION A
1.a 0010 0101 01102 1
)
b) C. NAND and NOR 1
c) process 1
d) A) RAM 1
e) (A+B)’ = A’ . B’ 1
(A.B)’= A’ + B’
f) Software used for maintenance and configuration of the computer system is 2
called system utility. Some system utilities are shipped with the operating
system for example disk defragmentation tool, formatting utility, system
restore utility, etc. Another set of utilities are those which are not shipped with
the operating system but are required to improve the performance of the
system, for example, anti-virus software, disk cleaner tool, disk compression
software, etc.
G) 2
SECTION C
5.a Identify the type of cyber crime for the following situations:
)
1 (c) Copyright infringement
2. Card fraud
5
3. Trolling
4. Phishing
5. Cyber bullying
b) print('****program to find greatest of 3 numbers****')
num1,num2,num3=eval(input('enter 3 unique numbers: '))
if num1 > num2 and num1 > num3:
print('The greatest of the three nos. is : ',num1)
elif num2 > num3 and num2 > num1:
5
print('The greatest of the three nos. is : ',num2)
elif num3 > num1 and num3 > num2:
print('The greatest of the three nos. is :',num3)
else:
print('any two nos are equal')
c)
General Instructions:
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in
Q35 against part c only.
SECTION A:
1. Define PROM
4. The operating system that uses two or more CPU’s within a single computer is
called……….
x=12
x=5
x=x+x
print(x)
a) 10 b) 17 c) 5 d) none
6. write the full form of ASCII?
print(x)
12. str=”togetherwithpython”
str.count(“t”)
a) 3 b) 2 c) none d) zero
13. Tuples are……………datatypes
14. item=[‘a’,’b’,’c’,’d’]
name=item.pop()
print(name)
16. Gaining someone else’s identity without his/her knowledge and misuse it
17.A license allows the user to use coprright material. Say true or false
18. The main purpose of pseudocode is…….
SECTION B:
24.Write the for loop to print the values from 1 to 10 in separate lines?
SECTION C:
27. Write any 2 ways to protect personal data on social media…..2 marks
30.mylist=[10,20,30,40]
mylist.append([50,60])
mylist.extend([80,90])
mylist.sort()
SECTION D:
(i) a=110
while a >100:
print(a)
a-=2
print(i)
(iii) country=”INDIA”
for i in country:
print(i)
while i<9:
if i%4==0:
sum=sum+i
i=i+2
print(sum)
33. Write a python program to print the mathematical tables from 1 to 10.
SECTION E:
st=input(“enter a string”)
print(st)
count=0
if character== ch:
count+=1
a) Now she wants to show a copy of the string with uppercase characters converted
into lowercase. Which of the following function will be used?
(i) Count() (ii) partition() c) swapcase() d) strip()
b) She does not know the syntax of doing so, help her in doing by choosing the correct
option.
(i) print(swapcase())
(ii) print(st.swapcase())
(iii) print(st.swapcase)
(iv) print(swapcase.st)
c) She wants to capitalize the first character of the string,then…..must be used
(i) lower() (ii) upper() (iii) capitalize() (iv) find()
d) Now she wants first character of every word in the string must be in uppercase.
(i) st.istitle() b) st.isupper() c) st.islower() d) none
e). She wants to check whether all the character of the string are alphabet or not
SECTION A:
1. Programmable Read Only Memory is a memory chip on which data can be written
only once and remains forever
2. Parallelogram
3. Option d
4. Multi processing
5. Option a
6. American Standard Code for Information Interchange
7. (101)10
8. .py
9. Tokens
10.Option b
11. for loop
12.Option a
13.Immutable datatypes
14.Item=[‘a’, ’b’ , ‘c’]
15.Option a
16.Option b
17.True
18. Option b
SECTION B
19.Primary memory is the computer's main memory and stores data
temporarily. Secondary memory is external memory and saves data permanently.
Data stored in primary memory can be directly accessed by the CPU, which cannot
be accessed in secondary memory.
20.Functions of control unit:
Fetching instructions one by one from primary memory and gather required data and
operands to perform those instructions.
Fetching programs from input and secondary memory and bringing them to primary
memory
21. (5.375)10
22. Python Identifier is the name we give to identify a variable, function, class, module
or other object. Basically, identifiers are the sequences of alphabet or digits
23. Selection: Algorithms can use selection to determine a different set of steps to
execute based on a Boolean expression. Iteration: Algorithms often use repetition
to execute steps a certain number of times or until a certain condition is met.
24. The for loop is as follows:
for i in range(1,11):
print(“%d” %i)
25.In Lists and Tuples, the items are retained in the order in which they are inserted.
The elements can always be accessed based on their position. The element at the
position or 'index' 0 will always be at index 0. Therefore, the Lists and Tuples are
said to be ordered collections.
SECTION C:
26. str= input(“Enter any string”)
dict={ }
for ch in str:
if ch in dict:
dict[ch]+=1
else:
dict[ch]=1
print(dict)
output:
Enter any string: alphabet
{‘a’:2, ‘l’=1, ‘p’=1, ‘h’=1, ‘b’=1, ‘e’=1, ‘t’=1}
27.
o Create strong passwords. ...
o Don't overshare on social media. ...
o Use free Wi-Fi with caution. ...
o Watch out for links and attachments. ...
b) Identity theft
28. The term dynamic typing means that a compiler or an interpreter assigns a type to
all the variables at run-time. The type of a variable is decided based on its value.
29.pop()
clear()
count()
30.mylist=[10,20,30,40,[50,60]]
mylist=[10,20,30,40,[50,60],80,90]
mylist=[10,20,30,40,[50,60],80,90]
SECTION D
31.dict={‘p’:9, ‘y’=20, ‘t’=4, ‘h’=8, ‘o’=1, ‘n’=5}
lst=list()
for a in dict.values():
lst.append(a)
lst.sort()
print(“highest value:”,lst[-1])
print(“second highest value:”, lst[-2])
Output:
Highest value: 20
Second highest value: 9
32.(i) 110
108
106
104
102
(ii) 20
22
24
26
28
(iii) I
N
D
I
A
(iv) 12
33.for i in range(1,11):
print(“table %d” %i)
print(“…………”)
for j in range(1,11):
k=i*j
print(“%d * %d=%4d” %(i,j,k))
34.global plagiarism
paraphrasing plagiarism
verbatim plagiarism
35. a) c
b)(ii)
c) iii
d) b
e) d.
Class: XI Session: 2022-23
Computer Science (083)
SECTION A
(a) /
(b) //
(c) #
(d) *
4. Choose the name of the process in which someone's intellectual work is 1
stolen by someone and represented as its own.
(a) Copying
(b) Plagiarism
(c) Copy and paste
(d) Intellectual steal
x = 100
y = 50
print(x and y)
str1="Hello" # Statement 1
print(str1) # Statement 2
str2=10 # Statement 3
str3=str1+str2 # Statement 4
S=str1*str3" #Statement5
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
10. What is the most widely used method for e-waste disposal? 1
(a) Burning
(b) Recycling
(c) Landfilling
(d) Disintegration
11. Find out the type of error in the following code: 1
x=x+10
y=x*x
print(x,y)
if 1 + 3 == 7:
print("Hello")
else:
print("Bye")
(a) Bye
(b) Hello
(c) HelloBye
(d) hello Bye
13. Fill in the blank: 1
x=0
while(x <4):
print(x)
x = x+1
a=[5,4,9,’a’,’b’]
(a) List
(b) Tuple
(c) String
(d) None of above
16. Python considers the character can be enclosed in triple quotes then 1
choose the option true\false.
(a) True
(b) False
(c) can not say
(d) none of above
Q17 and 18 are ASSERTION AND REASONING based questions. Mark 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
(d) A is false but R is True
17. Assertion: Recycling is the only solution for the treatment of e- 1
waste, provided it is carried out in an environment friendly manner.
Reason: During the recycling process, metals like copper, iron, silicon,
nickel and gold are recovered in developing countries.
Reason (R): We may not get back the data in which order we
had entered the data initially.
SECTION B
i=0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
20. Draw the logic circuit for the following equation: 2
A’B’+(AB)’
OR
number = 5
if number < 5:
number = number + 1
print(number)
23. Write any two possible solutions for special needs students. 2
or
L=[2,3,4,6,9,3,8,9)
print(L.index(4))
print(L.count(3))
L.append(L.count(9))
print(L)
OR
T1=(1,2,3,4,5,6,7,8)
print(T1[0])
print(T1[-1])
print(T1[4-1])
print(T1[2:6:2])
(a) (421.5)10=(?)8
(b) (BAD)16=(?)10
(c) (1101100)2=(?)16
SECTION C
Average Grade
>=80 A
80-70 B
70-55 C
55-33 D
<33 E
27. Proof the Demorgan's Laws with the help of truth tables. 3
OR
28. 3
ASHA making a project on” Environment cleanliness” and
downloading some pages from web browser ,she completed her work
in three steps ,so give your justification for following steps if any ethics
violates or not :
(a) She read a paragraph then she pasted it in her report with the
same words.
(b) She downloaded images and pasted them in her report in the
form of collage.
(c) She copied the logo of one organization related with cleanliness
and pasted on front page of her report
29. Write a program that repeatedly asks the user to enter product names 3
and prices. Store all of them in a dictionary whose keys are product
names and values are prices. And also write a code to search an item
from the dictionary.
For example:
If D={‘eraser’: 10,’pen’:25,’pencil’:10}
otherwise
“ Not found”
30. 3
Write a program for checking whether the given string is palindrome
or not.
OR
Write a program to find the average of the list of the numbers entered
through keyboard.
for Example:
L=[2,6,7,8,9,10]
Output:
SECTION D
31. Write the output for the following statements on the given 5
string:
s= “ interesting facts”
(a) print(s.upper())
(b) print((s.split(‘ ‘ ))
(c) print(s.find(‘CTS’))
(d) print(s.index(‘e’))
(e) print(s.replace(‘sacts’, ‘idea’))
OR
SECTION E
Column A Column B
Plagiarism Fakers, by offering special rewards or money
prize asked for personal information, such as bank
account information
Hacking Copy and paste information from the Internet into
your report and then organise it
Credit card The trail that is created when a person uses the
fraud Internet.
Digital Foot Breaking into computers to read private emails
Print and other files
35. Explain any 4 built in functions which can be performed over a given 4
tuple.
OR
Explain any 4 built in functions which can be performed over a
given list.
KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION
SAMPLE QUESTION PAPER-2022-23
CLASS XI
SUBJECT: COMPUTER SCIENCE
Note: a) All questions are compulsory. Time: 3 HOURS
b) Give examples wherever possible. Max
Marks: 70
Q. Question
No
SECTION A
1.a) 0010 0101 01102 1
b) split() 1
c) 18.0 1
d) (iv) tuple 1
e). In the above code, X will take minimum value 1 and maximum value 4 1
f) Correct the errors in the given code and underline the corrections 2
Num = int(input("Number:"))
Sum = 0
for i in range(0,Num):
Sum+=i
if i%5:
print( i*2)
else:
print ( Sum)
3.a) Predict the output of the following code snippet if N is given the value 2: 3
1*2=2
2*2=4
4*2=8
6 * 2 = 12
7 * 2 = 14
b) N=eval(input('enter a list of numbers:')) 2
for i in range(len(N)):
if i%2 == 0:
N[i] *= 3
c) mutable -- List , diuctionary 2
immutable datatypes – int, string, tuple
d) 2 abcabc 9 2
SECTION C
5.a) Identify the type of cyber crime for the following situations:
2. Card fraud
5
3. Trolling
4. Phishing
5. Cyber bullying
b) print('****program to find greatest of 3 numbers****')
num1,num2,num3=eval(input('enter 3 unique numbers: '))
if num1 > num2 and num1 > num3:
print('The greatest of the three nos. is : ',num1)
elif num2 > num3 and num2 > num1:
5
print('The greatest of the three nos. is : ',num2)
elif num3 > num1 and num3 > num2:
print('The greatest of the three nos. is :',num3)
else:
print('any two nos are equal')
c)
xiii) a) 0
4
xiv) b) Will not effect on the result of the algorithm and it will be same as
earlier.
SECTION A
1. State True or False 1
“Antivirus software is type of system software”
Ans:- False
2. Which of the following is a valid datatype in Python? 1
(a) For (b) None (c) for (d)while
Ans: (a) For
3. Which character is used in Python to make a single line comment? 1
(a) /
(b) //
(c) #
(d) *
Ans: (c) #
4. Choose the name of the process in which someone's intellectual 1
work is stolen by someone and represented as its own.
(a) Copying
(b) Plagiarism
(c) Copy and paste
(d) Intellectual steal
Ans: (b) Plagiarism
str1="Hello" # Statement 1
print(str1) # Statement 2
str2=10 # Statement 3
str3=str1+str2 # Statement 4
S=str1*str3 # Statement 5
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
Ans: (d) Statement 4 and 5
(d) Disintegration
Ans: ( c ) Landfilling
(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
(d) A is false but R is True
17. Assertion: Recycling is the only solution for the treatment of e-waste, 1
provided it is carried out in an environment friendly manner.
Reason: During the recycling process, metals like copper, iron,
silicon, nickel and gold are recovered in developing countries.
Ans : (b)
18. Assertion (A): Items in dictionaries are unordered. 1
Reason (R): We may not get back the data in which order we had
entered the data initially.
Ans: (b)
SECTION B
19. What will be the output of the following Python program? 2
i=0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
Ans: 0
1
2
20. Draw the logic circuit for the following equation: 2
A’B’+(AB)’
2 mark for correct logic circuit
OR
23. Write any two possible solutions for special needs students. 2
Ans: 1-1 mark for any correct answer
or
Define plagiarism and why it is a punishable offense?
Ans: Plagiarism is defined as stealing or presenting someone's ideas or
words of another author as your own.
L=[2,3,4,6,9,3,8,9)
print(L.index(4))
print(L.count(3))
L.append(L.count(9))
print(L)
Ans: 2
2
[2,3,4,6,9,3,8,9,2]
½ mark for each correct answer
OR
Average Grade
>=80 A
80-70 B
70-55 C
55-33 D
<33 E
OR
Write a program to find the average of the list of the numbers entered
through keyboard.
for Example:
L=[2,6,7,8,9,10]
Output:
Average of the numbers is : 7
Ans: Partial marking can be given for correct code
SECTION D
31 Write the output for the following statements on the given string: 5
.
s= “ interesting facts”
(a) print(s.upper())
(b) print((s.split(‘ ‘ ))
(c) print(s.find(‘CTS’))
(d) print(s.index(‘e’))
(e) print(s.replace(‘sacts’, ‘idea’))
Ans: (a) INTERESTING FACTS
(b) ‘interesting’, ‘ facts’
(c) -1
(d) 3
(e) interesting idea
1-1 mark for each correct answer
OR
Write a program for checking whether the given character is
uppercase ,lowercase,digit ,special symbol or white space.
Ans: Partial marking can be given for correct code
32. Write the most appropriate list method to perform the following task: 5
(a) Add 4th element in the given list
(b) Add element in the last position of the list
(c) Delete 2nd element from the given list
(d) Delete the given element from the given list
(e) Add elements (more than one at the end of the given list.
Ans: (a) insert()
(b) append()
(c ) pop()
(d) remove()
(e) extend()
33 Write a program to create a dictionary with the roll number,name and 5
. marks of n students in a class and displays the name of students whose
marks are greater than 70.
Ans: ½ -½ mark for each correct statement
OR
Write a program to print minimum, maximum,sum of keys of numbers
dictionary as given below:
numbers= {1:100,2:200,3:300,4:400}
Ans: ½ -½ mark for each correct statement
SECTION E
34 Match the following: 4
.
Column A Column B
Ans:
Column A Column B
1. Plagiarism (b)
2. Hacking (d)
3. Credit card fraud (a)
4. Digital foot print (C)
1-1 mark for each correct answer
35. Explain any 4 built in functions which can be performed over a given 4
tuple.
Ans: 1-1 mark for each correct function
OR
Explain any 4 built in functions which can be performed over a given
list.
Ans: 1-1 mark for each correct function
Class: XI
Session: 2022-23
SECTION A
Ans: (a) 2
Ans: (b).100
str1="Hi" # Statement
1 print(str1) # Statement
2
str2=10 # Statement 3
str3=str1+str2 # Statement 4
S=str1*str3 # Statement 5
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
break
Ans: (b) 10
B. Both assertion and reason are true but reason is not the correct
explanation of the assertion
Ans: (b).
SECTION - B
19. Following code contains an endless loop. Could you find out why? 2
Suggest a solution.
n=10
result=1
n=n+1
print(result)
Possible solution:
Ans:
(i). D[‘banana’']=20
(ii). D[‘apple’]=10
Or
Ans: 20 17 17
or
Predict the output of the Python code given below:
L=[2,3,4,6,9,3,8,9]
print(L.index(4))
print(L.count(3))
L.append(L.count(9))
print(L)
Ans: 2
2
[2, 3, 4, 6, 9, 3, 8, 9, 2]
(b) 175
(c) 1650.44
SECTION - C
26. Write a program which replaces all vowels in the string with ’*’ 3
i) list1 = [12,32,65,26,80,10]
list1.sort( )
print(list1)
sorted(list1)
print(list1)
iii)list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::-2]
list1[:3] + list1[3:]
iii). [10, 8, 6, 4, 2]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
SECTION - D
32. Write the output for the following statements on the given 5
string:
s= “PYTHON program”
(a) print(s.lower())
(b) print((s.split(‘ ‘ )))
(c) print(s.isalpha( ))
(d) print(s.index(‘o’))
(e) print(len(s))
Ans: (a). python program
(b). ['PYTHON', 'program']
(c). False
(d). 9
(e). 14
OR
Write a program for checking whether the given
character is uppercase ,lowercase,digit ,special symbol or
white space.
Ans: Partial marking can be given for correct code
SECTION - E
Column A Column B