Class XI Python Material KV Sangthan

Download as pdf or txt
Download as pdf or txt
You are on page 1of 143

1

2
Content Developer

1. Mr. Raheesh Khan, PGT CS, KV Suratgarh Cantt

2. Mr. Mahendra Sethi, PGT CS KV BSF Dabla


3. Mr. Birbal Jat, PGT CS, KV Phulera

4. Mr. Vishal Goswami, PGT CS, KV No.1, Bikaner

5. Mr. K.K. Kumawat, PGT CS, KV AFS Jaisalmer

6. Mr. Surendra Mehra, PGT CS, KV Khetri Nagar

7. Mr. Lokesh Saini, PGT CS, KV Jhunjhunu

8. Mr. Gajraj Meena, PGT CS, KV Karauli


9. Mr. Manish Soni, PGT CS, KV No. 1 AFS Suratgarh

10. Mr. Satish Soni, PGT CS KV INDERPURA

Support: Shri Pawan Sihag, PGT CS KV NAL Bikaner

3
SYLLABUS 2022-23
Computer Science
CLASS-XI Code No. 083
1. Learning Outcomes

Student should be able to


a) develop basic computational thinking
b) explain and use data types
c) appreciate the notion of algorithm
d) develop a basic understanding of computer systems - architecture, operating system and
cloudcomputing
e) explain cyber ethics, cyber safety and cybercrime
f) Understand the value of technology in societies along with consideration of gender and
disabilityissues

2. Distribution of Marks
Unit Unit Marks Periods
No Name
Theory Practical
I Computer Systems and Organization 10 10 10
II Computational Thinking and Programming - 1 45 80 60
II Society, Law and Ethics 15 20 ----
I
Total 70 110 70

Unit wise Syllabus


Unit I: Computer Systems and Organisation
● Basic Computer Organisation: Introduction to computer system, hardware, software, input
device, output device, CPU, memory (primary, cache and secondary), units of memory (Bit,
Byte, KB, MB,GB, TB, PB)
● Types of software: system software (operating systems, system utilities, device drivers),
programming tools and language translators (assembler, compiler & interpreter),
application software
● Operating system (OS): functions of operating system, OS user interface
● 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)

4
Unit II: Computational Thinking and Programming – 1
● Introduction to problem solving: Steps for problem solving (analysing the problem,
developing an algorithm, coding, testing and debugging). representation of algorithms using
flow chart and pseudo code, decomposition
● Familiarization with the basics of Python programming: Introduction to Python, features of
Python, executing a simple "hello world" program, execution modes: interactive mode and
script mode, Python character set, Python tokens (keyword, identifier, literal, operator,
punctuator), variables, concept of l-value and r-value, use of comments
● Knowledge of data types: number (integer, floating point, complex), boolean, sequence
(string, list, tuple), none, mapping (dictionary), mutable and immutable data types
● Operators: arithmetic operators, relational operators, logical operators, assignment
operator, augmented assignment operators, identity operators (is, is not), membership
operators (in, not in)
● Expressions, statement, type conversion & input/output: precedence of operators,
expression, evaluation of expression, python statement, type conversion (explicit & implicit
conversion), accepting data as input from the console and displaying output
● Errors: syntax errors, logical errors, runtime errors
● Flow of control: introduction, use of indentation, sequential flow, conditional and iterative
flow control
● Conditional statements: if, if-else, if-elif-else, flowcharts, simple programs: e.g.: absolute
value, sort 3 numbers and divisibility of a number
● Iterative statements: for loop, range function, while loop, flowcharts, break and continue
statements, nested loops, suggested programs: generating pattern, summation of series,
finding the factorial of a positive number etc
● Strings: introduction, indexing, string operations (concatenation, repetition, membership &
slicing), traversing a string using loops, built-in functions: len(), capitalize(), title(), lower(),
upper(), count(), find(), index(), endswith(), startswith(), isalnum(), isalpha(), isdigit(),
islower(), isupper(), isspace(), lstrip(), rstrip(), strip(), replace(), join(), partition(), split()
● Lists: introduction, indexing, list operations (concatenation, repetition, membership &
slicing), traversing a list using loops, built-in functions: len(), list(), append(), extend(),
insert(), count(), index(), remove(), pop(), reverse(), sort(), sorted(), min(), max(), sum();
nested lists, suggested programs: finding the maximum, minimum, mean of numeric values
stored in a list; linear search on list of numbers and counting the frequency of elements in a
list
● Tuples: introduction, indexing, tuple operations (concatenation, repetition, membership &
slicing),built-in functions: len(), tuple(), count(), index(), sorted(), min(), max(), sum(); tuple
assignment, nested tuple, suggested programs: finding the minimum, maximum, mean of
values stored in a tuple; linear search on a tuple of numbers, counting the frequency of
elements in a tuple
● Dictionary: introduction, accessing items in a dictionary using keys, mutability of dictionary
(adding a new item, modifying an existing item), traversing a dictionary, built-in functions:
len(), dict(), keys(), values(), items(), get(), update(), del, clear(), fromkeys(), copy(), pop(),
popitem(), setdefault(), max(), min(), count(), sorted(), copy(); suggested programs : count
the number of times a character appears in a given string using a dictionary, create a
dictionary with names of employees, their salary and access them
● Introduction to Python modules: Importing module using 'import <module>' and using from
statement, Importing math module (pi, e, sqrt, ceil, floor, pow, fabs, sin, cos, tan); random
module(random, randint, randrange), statistics module (mean, median, mode)

5
Unit III: Society, Law and Ethics
● Digital Footprints
● Digital society and Netizen: net etiquettes, communication etiquettes, social
media etiquettes
● Data protection: Intellectual Property Right (copyright, patent, trademark),
violation of
IPR (plagiarism, copyright infringement, trademark infringement), open
source softwares
and licensing (Creative Commons, GPL and Apache)
● Cyber-crime: definition, hacking, eavesdropping, phishing and fraud emails,
● ransomware, preventing cyber crime
● Cyber safety: safely browsing the web, identity protection, confidentiality,
cyber trolls
and bullying.
● Safely accessing web sites: malware, viruses, trojans, adware
● E-waste management: proper disposal of used electronic gadgets
● Indian Information Technology Act (IT Act)
● Technology & Society: Gender and disability issues while teaching and using
computers

6
------------------------Table of Content----------------------------

S.No. Page
No.
Unit 1: Computer System and organization
1. Basic Organization of a Computer System 8
2. Operating System 13
3. Number System 21
4. Boolean Logic and Gates 27
Unit 2: Computational Thinking and programming-1
5. Introduction to problem solving 34
6. Basics of Python Programming 35
7. Operator, Expressions and Errors 36
8. Data Types 40
9. Flow of Controls 43
10. String 51
11. Lists 58
12. Tuples 66
13. Dictionary 73
14. Introduction to Python Modules 84
Unit 3: Society, Law and Ethics
15. Digital Footprints, Digital Society and Netizens 93
16. Data Protection 94
17. Cyber Crime 96
18. Cyber Safety 97
19. Indian Information Technology Act (IT Act) 98
20. E-waste management 98
Solved Practice Papers based on CBSE Pattern 2022-23
21. Solved Practice Paper I 102
22. Solved Practice Paper II 111
23. Solved Practice Paper III 119
24. Solved Practice Paper IV 128
25. Solved Practice Paper V 136

7
UNIT 1: COMPUTER SYSTEMS AND ORGANISATION

INTRODUCTION TO COMPUTER SYSTEM


Computer is an electronic device, which takes input from its user, process it
according to the instructions given and produce a result called output. or we can
say that a computer system is a set of integrated devices that input, output,
process, and store data and information.
IPO cycle (Input Process Output): in this cycle instructions are given, processed
and executed.
Input : This is the first step where instructions or data are given to the computer
through keyboard or mouse. This unit is known as input unit.
Process : This is the second step where processing is carried out i.e. execution of
instructions. This unit is known as Central Processing Unit (CPU).
Output : This is the third step where result of a processing is displayed on the
screen of
the computer.

Now let us see the interconnection between these units

HARDWARE AND SOFTWARE:

The computer is the combination of hardware and software.


Hardware are the physical components of the computer system. They are tangible in
nature (i.e. one can touch the hardware components like motherboard, monitor,
keyboard.)

Software are the logical components of the computer system. They are intangible in
nature (i.e. one cannot touch software). Software is the set of programs or instructions.
it helps in maintaining the computer system and performing the various tasks with the
computer system
Both hardware and software together make the computer system function.

Input Devices:
Devices that help user to give input to a computer are called Input Devices.
8
Name of input Image of Input Device Purpose of use
device
Keyboard Basic input device for key entry

Mouse Pointing device input through clicking


and dragging

BCR (Bar Code Group of dark lines of varying thickness


Reader) used to obtain details of products in
super stores.

OMR (Optical Input through dark spots on paper , used


Mark Reader) for conducting tests based on multiple
choice pattern.

OCR (Optical Mechanism to read printed text or


Character convert printed text into editable form.
Recognition)

MICR (Magnetic used in processing of cheques in Bank


Ink Character
Reader)

Joystick used in playing online games or video


games

Microphone or to provide sound input


Mic

Scanner to convert a hard copy (printed matter)


to soft copy.

9
Digital Camera to obtain photographs or video.

Light pen A light pen is a light-sensitive pointing


input device commonly used to select or
otherwise modify text or data on a
screen.

Touch screen A user interacts with the computer,


tablet, smartphone or touch-controlled
appliance by using hand gestures and
fingertip movements to tap pictures,
moving elements or type words on the
screen.

Output Devices : Devices, which display the result of processing are known as Output
Devices.
Examples:

Name of Image of output Device Purpose of use


output device
Monitor Basic output device which is available in
(VDU) various types some of them are:
Visual Display CRT or Cathode Ray Tube Monitor
Unit LED or Light Emitting Diode Monitor
TFT or Thin Film Transistor

Printers Printers are used to obtain a hard of the


output.
There are various types of printer
• Dot Matrix Printer
• Inkjet/Deskjet Printer
• Laser Printer

Plotters Plotters are heavy duty printers that are


used to print Vector Graphics.

Projector Projectors are used to display the output


on a screen.

Speaker Speakers are used to produce sound


output.

10
CENTRAL PROCESSING UNIT (CPU)
CPU is called brain of the computer. It is also known as processor. It is responsible for
carrying out all activities in a computer. It is further divided into three parts:
• Arithmetic Logic Unit (ALU): This unit is responsible for arithmetic
calculations and comparison.
• Control Unit (CU): This unit is responsible for flow of data and instructions
between different units of computer. It decides whether data should go to ALU,
registers, memory unit, secondary storage or output unit.
• Registers: They are memory cells inside CPU to store data temporarily. They are
mainly used to store frequently used data.
MEMORY UNIT
Memory unit is used to store data and instructions. It stores data in machine language
i.e. in the form of 0 and 1. The binary digits 0 and 1 are known as bits.
PRIMARY MEMORY: Memory unit is also termed as primary memory. It consists of
three parts:
• RAM (Random Access Memory)
• ROM (Read Only Memory)
• Cache Memory

RAM (Random Access Memory): It is used to store data and instructions temporarily.
It retains data in it as long as the power is on. All the contents of RAM get cleared if
power supply is turned off.
Types of RAM:
• DYNAMIC RAM: It consists of capacitors and transistors. It uses electric charge
to store the data.
• STATIC RAM: It consists of flip-flops. It stores data in binary form. It has faster
access time compared to dynamic RAM.

ROM (Read Only Memory) : ROM stands for Read Only Memory. Data is permanently
stored in ROM. it contains instructions needed to start up the computer and load
operating system into RAM.
Types of ROM:
• PROM (Programmable Read Only Memory) : It can be programmed once.
• EPROM (Erasable Programmable Read Only Memory): It can be erased by
keeping ROM chip using Ultraviolet light. It can be reprogrammed..
• EEPROM (Electrically Erasable Read Only Memory): It can be erased by
electrical signal. It can also be reprogrammed.

CACHE MEMORY:
It is special memory used to compensate the speed difference between CPU (very fast)
and RAM (very slow). It stores the copies of frequently used data from RAM. Hence it
reduces the time required to access data from primary memory.

MEMORY UNITS (Measurement of Data):


1 Bit = 0 or 1
1 Nibble= 4 Bits
1 Byte= 8 Bits
1 KB (Kilo Byte)= 1024 Bytes (210)
1 MB (Megabyte) = 1024 KB (1024 X 1024 Bytes)

11
1 GB (Gigabyte) = 1024 MB
1 TB (Terabyte) = 1024 GB
1 PB (Petabyte) = 1024 TB
1 EB (Exabyte) = 1024 PB
1 ZB (Zettabyte) = 1024 EB
SECONDARY STORAGE UNIT:
Secondary storage unit is used to store data permanently. It consists of different types
of storage devices. Most commonly used storage devices are:

1) Hard Disk: It is the most commonly used storage device to store data on a
computer. It consists of multiple magnetic plates and heads to read and write
data. Magnetic plates are further divided into tracks and sectors to store data.
Maximum capacity of hard disk is 15TB.
2) Compact Disk (CD): it is an optical disk to store data. it have a storage capacity
of 700 MB. There are three types of CDs:
➢ CD-ROM (Compact Disk Read Only Memory): These are pre-recorded CDs
provided by manufacturers. Example: CDs containing softwares, games,
ebooks etc.
➢ CD-R (Compact Disk Recordable): Data can be recorded on these CDs only
once.
➢ CD-RW (Compact Disk Rewritable): These types of CDs can be erased and
recorded multiple times.
3) Digital Versatile Disk (DVD): it is an optical disk to store data and have a
storage capacity of upto 17 GB. There are three types of DVDs:
➢ DVD-ROM (Digital Versatile Disk – Read Only Memory): These are
prerecorded DVDs provided by manufacturers. Example: DVDs containing
movies etc.
➢ DVD-R (Digital Versatile Disk – Recordable): Data can be recorded on these
DVDs only once.
➢ DVD-RW (Digital Versatile Disk – Rewritable):These types of DVDs can be
erased and recorded multiple times.

4) Blu Ray Disk: it is optical disk that can store HD (High Definition) videos and
data. They can store up-to 128 GB of data.

5) Pen Drive : It is also called Flash memory. It is a solid state memory that can
store more than 128GB of data.

TYPES OF SOFTWARE:
Software is defined as a collection of programs which are used for different purposes.

There are three types of software:


1) System Software
2) Application Software
3) Utility Software

System software is used to perform functions related to general operations of


computer system. It has two types:
I. Operating System: it is an interface between user and computer. It takes
instructions from user and further instructs hardware components to work. The
results produced by hardware components are sent back to the user.
Example: Windows 10 , Unix, Linux, Android etc.
12
II. Language Translators: These softwares are used to convert the High Level
Language instructions into Machine Language instructions.
Types of language translators:
➢ Compiler: It converts High Level Language program into machine language
in one go.
➢ Interpreter: It converts High Level Language program into machine
language line by line.
➢ Assembler: It converts assembly language into machine language.

Application software: it is used to perform specific operation on computer. It has two


types:
➢ General Purpose software: These softwares can be used by more than one type
of user. Example: MS Word is a general purpose software that can be used by
students, teachers as well as clerks.
➢ Special Purpose / Customized Software: These softwares can be used by only
one type of user. Example: Banking Data Management software can be used only
by bank employees.

Utility Software :
These softwares are used to take backup, remove outdated file, recover data and other
tasks that assist in smooth operation of computer.
Examples : Anti-Virus , Disk Defragmentation, Disk Clean, Backup, etc.

Device Driver: A device driver is a particular form of software application that allows
one hardware device to interact with another hardware device .A device driver may also
be called a software driver. Example connecting a PC to a printer.

OPERATING SYSTEM (OS)


Operating system is an interface between computer hardware and user. It is
responsible for the management of activities and the sharing of the computer resources.
Operating system is divided into two parts:
➢ Shell: It accepts instructions from user and instructs kernel to perform further
operations
➢ Kernel: It accepts instructions from shell and instructs hardware devices to
perform operations.

FUNCTIONS OF OPERATING SYSTEM :

➢ Process Management:- The operating system takes care of the allotment of CPU
time to different processes. it can create and delete processes. It also provides
mechanism for communication among processes. This deals with management of
the Central Processing Unit (CPU). This is known as scheduling.
➢ Memory Management:- The CPU and the I/O devices interact with the memory.
When a program needs to be executed it is loaded onto the main memory till the
execution is complete. Thereafter that memory space is freed and is available for
other programs. The common memory management techniques used by the
operating system are Partitioning and Virtual Memory. Operating System
allocates and de-allocates memory to different softwares.
➢ File Management:- It manages storage, retrieval, naming, sharing, and
protection of files. It also manages the files, folders and directory systems on a
computer. The file manager of the operating system helps to create, edit, copy,
allocate memory to the file.

13
➢ Device Management: The Operating System communicates with hardware
and the attached devices and maintains a balance between them and the CPU.
This is all the more important because the CPU processing speed is much higher
than that of I/O devices. It is responsible allocation and de-allocation of the
hardware devices to different programs. In order to optimize the CPU time, the
operating system employs two techniques - Buffering and Spooling.
➢ I/O System Management: It takes care of allocation and de-allocation of
Input/Output devices to different programs.

Types of Operating System:

Operating system can be classified into the following types:

➢ Single User OS: It is used on a standalone single computer for performing a


single task. Operating systems for Personal Computers (PC) are single-user OS.
Single user OS are simple operating system designed to manage one task at a
time. MS-DOS is an example of single user OS.
➢ Multiuser OS is used in mini computers or mainframes that allow same data and
applications to be accessed by multiple users at the same time. The users can
also communicate with each other. Example: -Linux and UNIX OS
➢ Multiprocessing OS have two or more processors for a single running process.
Processing takes place in parallel and is also called parallel processing. Linux,
Example: UNIX and Windows 7 OS.
➢ Time sharing Operating System: It allows execution of more than one tasks or
processes concurrently. For this, the processor time is divided amongst different
tasks. This division of time is also called time sharing. Example : Windows 95
➢ Real Time Operating System: It is a multitasking operating system designed for
real time applications like robotics.
➢ Distributed Operating System: On a network data is stored and processed on
multiple locations. The Distributed Operating System is used on networks as it
allows shared data/files to be accessed from any machine on the network in a
transparent manner.
➢ Interactive Operating System: This is the operating system that provides a
Graphic User Interface (GUI) through which the user can easily navigate and
interact.

Commonly Used Operating Systems:

• Windows: It is a GUI (Graphic User Interface) and various versions of Windows


have been launched like Windows 95, Windows 98, Win NT, Windows XP,
Windows 7 , 8 and Windows 10.
• Linux: Linux is a free and open software which means it is freely available for
use and since its source code is also available so anybody can use it, modify it and
redistribute it.
• BOSS (Bharat Operating System Solutions): This is an Indian distribution of
GNU/Linux. It consists of Linux operating system kernel, office application suite,
Bharateeya Open Office, Internet browser (Firefox), multimedia applications and
file sharing.
• UNIX: It is a multitasking, multiuser operating system and is widely being used in
a networked environment. It is a free Unix based operating system introduced by
Sun Microsystems in 1992. It is now also known as Oracle Solaris.

14
• SOLARIS is registered as compliant with Single UNIX Specification. It is quite
scalable and is used on virtual machines.

OPERATING SYSTEM USER INTERFACE:

S.No. User Interface Purpose


1 Natural These types of user interfaces use languages like English,
Language French, etc in a very humanistic way so that users don’t feel
Interface like they are talking to a robot. NLI can be verbal or written.
(Voice based) In verbal interfaces, it feels like someone is talking to you and
getting the work done for you.
Examples: Apple’s SIRI, Microsoft’s Cortana, Google’s
Assistant and Amazon’s Alexa.
2 Menu-driven Menu-driven Interface is used for very specific purposes
Interface which only require a few options or a small menu to be given
(Touch to the users. The options can be in the form of buttons which
based) can be either touch-based or physical. It allows users to
interact with the system simply using the touch input.
Examples : ATM machines, Android and iOS.
3 Gesture-based Mobile phones based on Android and iOS as well as laptops
Interface allow users interact with the devices using gestures like
waving, tilting, eye motion and shaking. This technology is
evolving faster and it has promising potential for application
in gaming, medicine and other areas.
4 Graphical User GUI allows users run programs or give instructions to the
Interface computer in the form of icons, menus and other visual
options.
The input devices used to interact with the GUI commonly
include the mouse and the keyboard.
Examples: Microsoft Windows, Ubuntu, Fedora and
Macintosh.

5 Command-Line CLI requires a user to enter the commands to perform


interface different tasks like creating, opening, editing or deleting a file,
etc. The primary input device used by the user for command
based interface is the keyboard.
Examples: MS-DOS and Unix.

Encoding schemes: ASCII, ISCII and UNICODE (UTF8, UTF32):

Computers are designed to work internally with numbers. In order to handle characters,
we need to choose a number for each character. The ability of a computer system to
understand signals or letters depends on its character set
The complete set of characters / symbols are called alphanumeric codes. The complete
alphanumeric code typically includes −
➢ 26 upper case letters (A-Z)
➢ 26 lower case letters (a-z)
➢ 10 digits (0-9)
➢ 7 punctuation marks
➢ 20 to 40 special characters
Following are some forms of character set or encoding schemes:
15
➢ ASCII
➢ ISCII
➢ UNICODE
ASCII Code: (American Standard Code for Information Interchange) most of the micro
computers, mini computers and some mainframe computers use this code.
ASCII code has two versions - ASCII – 7 and ASCII – 8.
➢ ASCII – 7 code use 7 bits for one signal or character. By this, 27 = 128 , different
characters can be used.
➢ ASCII – 8 code use 8 bits for one signal or character. By this, 28 = 256 , different
characters can be used.
ISCII: it stands for Indian Script Code for Information Interchange for Indian languages.
In order to facilitate the use of Indian languages on Computers, a common standard for
coding Indian scripts called ISCII was developed in India.
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. These codes are used for ten
Indian scripts - Devnagari, Punjabi, Gujarati, Oriya, Bengali, Assamese, Telugu, Kannada,
Malayalam and Tamil.
UNICODE: (UNIVERSAL CODE)
This is Universal Character Set which represents a signal or a character in a group of 32
bit. It has the capability to include signals and characters from all scripts of all languages
of world.
The Unicode Standard is the universal character encoding standard for written
characters and text. Each character or symbol is assigned a unique numeric value,
largely within the framework of ASCII. Earlier, each script had its own encoding system,
which could conflict with each other.
The purpose of Unicode is to −
provide a unique number for every character,
no matter what the platform,
no matter what the program,
no matter what the language.
Unicode characters are represented in one of three encoding forms:
➢ an 8-bit form (UTF-8)
➢ a 16-bit form (UTF-16)
➢ a 32-bit form (UTF32)
EXERCISES
(Multiple Choice Questions)
1. The physical and tangible components of the computer are termed as:
a) Hardware b) software c) firmware d) None

2. The smallest memory unit is:


a) bit b) byte c) kilobyte d) megabyte

3. Antivirus is a type of which software:


a) System software b) Application software c) Utility Software d) Firmware

4. A computer program that converts an entire program into machine language is called-
a) Interpreter b) Compiler c) Linker d) Assembler

5. Which of the following is not a multi-user operating system?


a) DOS b) Windows c) Linux d) Unix

16
6. Which of the following are two main components of CPU?
a) ALU & MU b) ALU & CU c) I/O d) None

7. Which keyboard is used by visually impaired users?


a) Analog Keyboard b) Digital Keyboard c) Braille Keyboard d) None

8. Which of the following is volatile memory?


a) RAM b) ROM c) Both a & b d) None

9. Operating system with touch-based interface is……….


a) Andriod b) ios c) both a & b d) None

10. Spreadsheet is an example of ______________


a) Application Software b) System Software c) firmware d) liveware

Answers
1 2 3 4 5 6 7 8 9 10
A A C B A B C A C A

SHORT ANSWER TYPE QUESTIONS

Q. 1. Which part interprets program instructions and initiate control operations ?


Ans. : Control unit.

Q. 2. What is the difference between data and information ?


Ans.: Data means facts and figures. Information means what we get after processing
data i.e., processed data.

Q. 3. What is booting ? What are the types of booting ?


Ans.: Booting is the process of restarting a computer or its operating system software. It
starts with switching on the computer and ends when the operating System is loaded in
main memory and the computer is ready to take commands from the user.
Booting is of two types :
Cold booting : When the computer is started after having been switched off.
Warm booting : When the operating system alone is restarted after a system crash.

Q. 4. What is a bit ? How bit, byte and nibbles are related to each other?
Ans. : A bit is the smallest elementary unit of memory, which can store one binary signal
either 0 or 1. A group of 8 bits is called a byte. A group of 4 bits is called a nibble.

Q. 5. What do you understand by IPO cycle?


Ans. : IPO cycle refers to the Input Process Output cycle where every operation
undergoes the phases namely input, process and output.

LONG ANSWER TYPE QUESTIONS


Q. 1. Explain four characteristics of computer
Ans. :
➢ Speed: The computer can process data very fast, at the rate of millions of
instructions per second. Some calculations that would have taken hours and days
to complete otherwise, can be completed in a few seconds using the computer.
➢ Accuracy: Computer provides a high degree of accuracy. For example : the
computer can accurately give the result of division of any two numbers up to 30
decimal places.
17
➢ Diligence: When used for a longer period of time, the computer does not get tired
or fatigued. It can perform long and complex calculations with the same speed
and accuracy from the start till the end.
➢ Storage Capability: Large volumes of data and information can be stored in the
computer and also retrieved whenever required. A limited amount of data can be
stored temporarily in the primary memory. Secondary storage devices like DVD
and compact disk can store a large amount of data permanently.
Q. 2 Write the classification of computer based on their sizes and types.

Ans.: Computers are broadly classified as micro-computers, mini computers, mainframe


computers, and supercomputers based on their sizes and types.

❖ Micro Computers: These are also known as Personal Computers. These type of
digital computer uses a microprocessor (a CPU on a single chip) and include both
desktops and laptops. These computers can work on small volume of data, are
very versatile and can handle variety of applications. These computers are being
used as work stations, CAD, multimedia and advertising applications. Small
portable computers such as PDAs (Personal Digital Assistants) and tablets with
wireless computing technology are increasingly becoming popular.

❖ Mini Computers: These computers can support multiple users working


simultaneously on the same machine. These are mainly used in an organization
where computers installed in various departments are interconnected. These
computers are useful for small business organizations.

❖ Main Frames: These computers are large and very powerful computers with
very high memory capacity. These can process huge databases such as census at
extremely fast rate. They are suitable for big organizations, banks, industries etc.
and can support hundreds of users simultaneously on the network.

❖ Super Computers: These are fastest and very expensive computers. They can
execute billions of instructions per second. These are multiprocessor, parallel
systems suitable for specialized complex scientific applications involving huge
amounts of mathematical applications such as weather forecasting.

Q. 3 Expand the following terms:


CPU, ALU, VLSI, MSI, LSI, SSI, IC, IPO, HLL, MB.
Ans. :
CPU —> Central Processing Unit
ALU —> Arithmetic Logic Unit
VLSI —> Very Large-Scale Integration
MSI —> Medium Scale Integration
LSI —> Large Scale Integration
SSI —> Small Scale Integration
IC —> Integrated Circuits
IPO —> Input Process Output
HLL —> High Level Language
MB —> Mega Byte

18
Q. 4 Distinguish between internal and external memory.
Ans :-
Internal memory External memory

❖ It is also known as primary storage ❖ It is also known as secondary memory or


or main memory. secondary storage.
❖ It is volatile in nature in the case of ❖ It is non-volatile in nature.
RAM but ROM is non-volatile. ❖ They are used to store data permanently.
❖ It is used to store data temporarily in ❖ It stores data when the power supply is on
case of RAM. after that when the power supply is gone it
❖ It stores data when the power supply saves the data.
is on otherwise it removes data after ❖ External memory is not working memory.
the power supply goes. ❖ Examples are hard disk, floppy disk,
❖ Internal memory is working memory card, cassette etc.
memory.
❖ Examples are RAM and ROM.

Q. 5 What are the types of computers based on technology? Define them.


Ans:
❖ Digital Computers: These computers are capable of processing information in
discrete form. In digital technology data which can be in the form of letters,
symbols or numbers is represented in binary form i.e. 0s and 1s. Binary digits are
easily expressed in a digital computer by the presence (1) or absence (0) of
current or voltage. It computes by counting and adding operations. The digital
computers are used in industrial, business and scientific applications.
❖ Analog Computers: An analog computer works on continuously changeable
aspects of physical phenomenon such as fluid pressure, mechanical motion and
electrical quantities. These computers measure changes in continuous physical
quantities say current and voltage. These computers are used to process data
generated by ongoing physical processes. Some of the common examples are
simulations in aircrafts, nuclear power plants, hydraulic and electronic networks.
❖ Hybrid Computers: These use both analog and digital technology. It has the
speed of analog computer and the accuracy of a digital computer. It may accept
digital or analog signals but an extensive conversion of data from digital to
analog and analog to digital has to be done. Generally, the analog components
provide efficient processing of differential equations while the digital part deals
with logical operations of the system. Hence benefits of both analog and digital
computing are readily available. Hybrid Computers are used as a cost-effective
means for complex simulations.
Q. 6 What is the utility of these software? (i) disk Defragmenter (ii) backup software.
Ans:
(i) Disk Defragmenter: -
A file is fragmented when it becomes too large for your computer to store in a single
location on a disk. When this happens, your computer splits the file up and stores it in
pieces. You can use fragmented files, but it takes your computer longer to access them.
Disk Defragmenter utility program speeds up disk access by rearranging the files and
19
free space on your computer, so that files are stored in contiguous units and free space
is consolidated in one contiguous block.
(ii) Backup Utility :-
This utility program facilitates the backing-up of disk. Back-up means duplicating the
disk information so that in case of any damage or data-loss, this backed up data may be
used.
Q. 7 How do different components of the computer communicate with each other?
Answer:-
Data are transferred between different components of a computer system using
physical wires called bus.
For example:-
Bus is used for data transfer between a USB port and hard disk or between a hard disk
and main memory.

20
NUMBER SYSTEM:
Each number system has a base also called a Radix. A decimal number system is a
system of base 10; binary is a system of base 2; octal is a system of base 8; and
hexadecimal is a system of base 16.
S.No. Number System Base Symbols or digits used
1 Binary 2 0,1
2 Octal 8 0,1,2,3,4,5,6,7
3 Decimal 10 0,1,2,3,4,5,6,7,8,9
4 Hexadecimal 16 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F
where A = 10; B = 11; C = 12; D = 13; E = 14; F = 15
CONVERTING A NUMBER FROM ONE BASE TO ANOTHER
DECIMAL TO BINARY
Method to convert a Decimal number into its Binary equivalent
1. Divide the decimal number by 2.
2. Take the remainder and record it on the side.
3. Divide the quotient by 2.
4. REPEAT UNTIL the decimal number cannot be divided further.
5. Record the remainders in reverse order and you get the resultant binary number.
Example:
Convert the Decimal number 125 into its Binary equivalent.
Number Method Quotient Remainder
125 Divide
125/2 62 1
62/2 31 0
31/2 15 1
15/2 7 1
7/2 3 1
3/2 1 1
1/2 0 1
Answer: (1111101)2
CONVERTING DECIMAL FRACTION TO BINARY
Example:
Convert (0.75)10 to binary
➢ Multiply the given fraction by 2.
➢ Keep the integer in the product as it is and multiply the new fraction in the
product by
➢ Continue the process till the required number of decimal places or till you get
zero in the fraction part.
➢ Record the integers in the products from top to bottom.
Given fraction 0.75
➢ Multiply 0.75 by 2 =1.50
➢ Multiply 0.50 by 2 = 1.00
➢ Reading the integers from top to bottom
0.75 in decimal number system is 0.11 in binary number system.

BINARY TO DECIMAL CONVERSION


Method to convert Binary to Decimal:
1. Start at the rightmost bit.
2. Take that bit and multiply by 2n where n is the current position beginning at 0 and
increasing by 1 each time. This represents a power of two.
3. Sum each terms of product until all bits have been used.
Example:
Convert the Binary number 101011 to its Decimal equivalent.
21
1 * 25 + 0 * 24 + 1 * 23 + 0 * 22 + 1 * 21 + 1 * 20
32 + 0 + 8 + 0 +2 + 1 = (43)10
Binary fraction to decimal conversion
Example:
Convert (11011.101)2 to decimal
1 1 0 1 1 .1 0 1
= (1 x 24)+ (1 x 23)+ (0 x 22)+ (1 x 21)+ (1 x 20)+ (1 x 2-1)+ (0 x 2-2)+ (1 x 2-3)
= 16+8+0+2+1+0.5+0+0.125
= (27.625)10
Decimal to Octal conversation:

The method to convert a decimal number into its octal equivalent:

1. Divide the decimal number by 8.


2. Take the remainder and record it on the side.
3. Divide the quotient by 8.
4. REPEAT UNTIL the decimal number cannot be divided further.
5. Record the remainders in reverse order and you get the resultant binary

Example:
Convert the Decimal number 125 into its Octal equivalent.

125 / 8 = 15 5
15 / 8 =1 7
1 / 8 =0 1
Answer: (175)8
Converting Decimal fraction to Octal
Example
Convert (0.75)10 to Octal
➢ Multiply the given fraction by 8.
➢ Keep the integer in the product as it is and multiply the new fraction in the
product by 8.
➢ Continue the process and read the integers in the products from top to bottom.
Given fraction 0.75
Multiply 0.75 by 8 6.00
Reading the integers from top to bottom 0.75 in decimal number system is 0.6 in octal
number system.

Octal to Decimal Conversion:


Method to convert Octal to Decimal:
1. Start at the rightmost bit.
2 . Take that bit and multiply by 8n where n is the current position beginning at 0
and increasing by 1 each time. This represents the power of 8.
3. Sum each of the product terms until all bits have been used.
Example:
Convert the Octal number 321 to its Decimal equivalent.
3 * 82 + 2 * 81 + 1 * 80
192+16+ 1 = (209)10
Octal fraction to decimal conversion:
Example:
Convert (23.25)8 to decimal
= (2 x 81)+ (3 x 80)+ (2 x 8-1)+ (5 x 8-2)
= (16 + 3 ) + (0.25 + 0.07812)
= (19.32812)10
22
Decimal to Hexadecimal Conversion:
Method to convert a Decimal number into its Hexadecimal equivalent:
1. Divide the decimal number by 16.
2. Take the remainder and record it on the side.
3. REPEAT UNTIL the decimal number cannot be divided further.
4. Record the remainders in reverse order and you get the equivalent hexadecimal
number.
Example:
Convert the Decimal number 300 into its hexadecimal equivalent.
300 / 16 = 18 12 equivalent to C
18 / 16 =1 2
1 / 16 =0 1
Answer: (12C)16
Converting Decimal fraction to Hexadecimal
Example:
Convert (0.75)10 to hexadecimal
➢ Multiply the given fraction by 16.
➢ Keep the integer in the product as it is and multiply the new fraction in the
product by 16.
➢ Continue the process and read the integers in the products from top to bottom.
Given fraction 0.75
Multiply 0.75 by 16 12.00 => C
Reading the integers from top to bottom 0.75 in decimal number system is 0C in
Hexadecimal number system.

Hexadecimal to Decimal Conversion:


Method to convert Hexadecimal to Decimal:

1. Start at the rightmost bit.


2. Take that bit and multiply by 16n where n is the current position beginning at 0 and
increasing by 1 each time. This represents a power of 16.
3. Sum each term of product until all bits have been used.

Example:
Convert the Hexadecimal number AB to its Decimal equivalent.
=A x161 + B x 160
=10 x 161 + 11 x 160
=160+11 = (171)10
Hexadecimal fraction to decimal Conversion
Example:
Convert (1E.8C)16 to decimal

1 E 8 C
= (1 x 16 )+ (14 x 16 )+ (8 x 16-1)+ (12 x 16-2)
1 0

= 16 + 14 + 0.5 + 0.04688
= (30.54688)10

Binary to Hexadecimal Conversion:


The hexadecimal number system uses the digits 0 to 9 and A, B, C, D, E, F.
Method to convert a Binary number to its Hexadecimal equivalent is:

We take a binary number in groups of 4 and use the appropriate hexadecimal digit in it’s
place. We begin at the rightmost 4 bits. If we are not able to form a group of four, insert
23
0s to the left until we get all groups of 4 bits each. Write the hexadecimal equivalent of
each group. Repeat the steps until all groups have been converted.

Example:
Convert the binary number 1000101 to its Hexadecimal equivalent.
0100 0101 (Note that we needed to insert a 0 to the left of 100.)
4 5
Answer: (45)16
In case of a fractional binary number form groups of four bits on each side of decimal
point. Then replace each group by its corresponding hexadecimal number.
Example:
Convert (11100.1010)2 to hexadecimal equivalent.
0001 1100 . 1010
1 C . A
Answer : (1C.A)16
HEXADECIMAL TO BINARY CONVERSION:

Method to convert a Hexadecimal number to its Binary equivalent is:


Convert each digit of Hexadecimal Number to its binary equivalent and write them in
4 bits . Then, combine each 4 bit binary number and that is the resulting answer.
Example:
Convert the Hexadecimal number (10AF)16 to its Binary equivalent.
1 0 A F
0001 | 0000 | 1010 | 1111
Answer: (0001000010101111)2

Binary to Octal and Octal to Binary Conversion


To convert Binary to Octal, as the octal system is a power of two (2 3), we can take the
bits into groups of 3 and represent each group as an octal digit. The steps are the same
for the binary to hexadecimal conversions except we are dealing with the octal base
now.
To convert from octal to binary, we simply represent each octal digit in its 3 bit binary
form.
Example:
Convert the Octal number (742)8 to its Binary equivalent.
7 | 4 | 2
111 | 100 | 010
Answer: (111100010)2
Hexadecimal to Octal and Octal to Hexadecimal
To convert Hexadecimal to Octal, Convert each digit of Hexadecimal Number to it’s
binary equivalent and write them in 4 bits. Then, combine each 3 bit binary number and
that is converted into octal.
Example:
Convert the Hexadecimal number (A42)16 to its Octal equivalent.
A | 4 | 2
1010 | 0100 | 0010
101 | 001 | 000 | 010
Answer: (5102)8
To convert Octal to hexadecimal, convert each digit of Octal Number to it’s binary
equivalent and write them in 3 bits. Then, combine each 4 bit binary number and that is
converted into hexadecimal.
Example:
Convert the Octal number (562)8 to its hexadecimal equivalent.
5 | 6 |2
24
101 | 110 | 010
0001 | 0111 | 0010
Answer: (172)16
The following table summarizes the number representation in decimal, binary, octal and
hexadecimal number system:

Decimal Binary Octal Hexadecimal

0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Exercises
(Multiple Choice Questions)
1. An organized way of representing numbers is called:
a) Character System b) Number system c) Integer system d) None
2. How graphics are represented by the computer?
a) Unicode b) ASCII c) Bitmap d) Binary

3. Using ASCII how many bits are required for 1 character?


a) 11 b) 8 c) 9 d) 14
4. Which of the following is not an example of Octal number?
a) 456 b) 370 c) 788 d) 100
5. Which of the following symbol is not a part of Hexadecimal number system?
a) 0 b) 9 c) 10 d) A
6. 4 bit binary code for binary number 15 is………
a) 1100 b) 1101 c) 1110 d) 1111
7. Binary equivalent of decimal number 32 is……….?
a) 10000 b) 100000 c) 1000 d) 100
8. Which of the following will occupy more memory space?
a A2 b) 12 c) 10 d) 1111
9. Octal number equivalent to binary number 1110101 is……..?
a) 115 b) 165 c) 65 d) 185
10. (1101011.10101)2 can be represented in Hexadecimal number as….. ?
a) 6B.68 b) 6B.A8 c) 6B.A81 d) 6A.A8

Answer :
1 2 3 4 5 6 7 8 9 10
B C B C C D B A B B

25
(Short Anwser Type Questions):

Q.1 Expand the following terms: ASCII, ISCII.


Ans. ASCII: American Standard Code for Information Interchange.
ISCII: Indian Script code for Information Interchange.
Q.2 Explain octal and hexadecimal number.
Ans:
•Octal (base 8) was previously a popular choice for representing digital circuit
numbers in a form that is more compact than binary. Octal is sometimes
abbreviated as oct. Octal counting goes as : 0,1, 2, 3,4, 5, 6,
7,10,11,12,13,14,15,16,17,20, 21 and so on.
• Hexadecimal (base 16) is currently the most popular choice for representing
digital circuit numbers in a form that is more compact than binary. Hexadecimal
numbers are sometimes represented by preceding the value with ‘Ox’, as in 0x1
B84. Hexadecimal is sometimes abbreviated as hex. Hexadecimal counting goes :
0,1,2, 3,4,5, 6, 7, 8,9, A, B, C, D, E, F, and so on.
Q. 3 Explain decimal and binary number.
Ans:
• Decimal (base 10) is the way most human beings represent numbers. Decimal is
sometimes abbreviated as dec. Decimal counting goes :
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 and so on.
• Binary (base 2) is the natural way most digital circuits represent and manipulate
numbers. Binary numbers are sometimes represented by preceding the value
with ‘Ob’, as in Ob1O11. Binary is sometimes abbreviated as bin.
Binary counting goes as : 0,1,10,11,100,101,110, 111, 1000, 1oo1, 1010,1011,
1100, 1101, 1110, 1111,10000,10001 and so on.
Long Answer Type Question:
Q1. Convert the following binary numbers to decimal:
(a) 1010 (b) 111010 (c) 101011111
Answer :-
(a)
1 0 1 0

23 0 21 0 (1010)2=(10)10

(b)
1 1 1 0 1 0

25 24 23 0 22 0 (111010)2=(60)10
(c)
1 0 1 0 1 1 1 1 1

28 0 26 0 24 23 22 21 1 (101011111)2=(351)10

Q2. Convert the following binary numbers to hexadecimal:


10011011101
Answer :-
0100 1101 1101

4 D D

(10011011101)2=(4DD)16

26
BOOLEAN ALGEBRA
INTRODUCTION:-
Boolean algebra was developed by English Mathematician George Boole. It is described
as algebra of logic or algebra of two values i.e True or False.
The term logic means a statement having binary decisions i.e True/Yes or False/No.
APPLICATION OF BOOLEAN ALGEBRA:-
It is used to perform the logical operations in digital computer. In digital computer True
represent by ‘1’ (high volt) and False represent by ‘0’ (low volt). Logical operations are
performed by logical operators. The fundamental logical operators are:
1. AND (conjunction)
2. OR (disjunction)
3. NOT (negation/complement)
AND operator: It performs logical multiplication and denoted by (.) dot.
X Y X.Y
0 0 0
0 1 0
1 0 0
1 1 1
OR operator: It performs logical addition and denoted by (+) plus.
X Y X+Y
0 0 0
0 1 1
1 0 1
1 1 1
NOT operator: It performs logical negation and denoted by (-) bar or single quote ( ‘ ).
It operates on single variable.

X X’ ( ‘ means complement of x)
0 1
1 0
Truth Table
Truth table is a table that contains all possible values of logical variables/statements in
a Boolean expression.
No. of possible combination = 2n, where n=number of variables used in a Boolean
expression. The truth table for XY + Z is as follows:
Dec X Y Z XY XY+Z
0 0 0 0 0 0
1 0 0 1 0 1
2 0 1 0 0 0
3 0 1 1 0 1
4 1 0 0 0 0
5 1 0 1 0 1
6 1 1 0 1 1
7 1 1 1 1 1
TAUTOLOGY & FALLACY:
➢ If the output of Boolean expression is always True or 1 is called
Tautology.
➢ If the output of Boolean expression is always False or 0 is called Fallacy.

Implementation of Boolean Algebra: -


Boolean algebra applied in computers electronic circuits. These circuits perform
Boolean operations and these are called logic circuits or logic gates.

27
Logic Gate:
A gate is a digital circuit which operates on one or more signals and produce single
output. Gates are digital circuits because the input and output signals are denoted by
either 1(high voltage) or 0(low voltage).
There are three basic gates:
AND gate : The AND gate is an electronic circuit that gives a high output (1) only if
all its inputs are high. AND gate takes two or more input signals and produces only
one output signal.

Logic gate Truth Table


Input Input Output
A B A.B

0 0 0

0 1 0

1 0 0

1 1 1

OR gate: The OR gate is an electronic circuit that gives a high output


(1) if one or more of its inputs are high. OR gate also takes two or more input signals
and produce only one output signal.

Logic gate Truth Table

Input Input Output


A B A+B
0 0 0

0 1 1

1 0 1

1 1 1

NOT gate: The NOT gate is an electronic circuit that gives a high output (1) if its
input is low. NOT gate takes only one input signal and produce only one output
signal. The output of NOT gate is complement of its input. It is also called inverter.

Input Output
A A’
0 1
NAND, NOR XOR, XNOR GATES

NAND gate :
The NAND gate or “Not AND” gate is the combination of two basic logic gates, the AND
gate and the NOT gate connected in series. The NAND gate and NOR gate can be called
the universal gates since the combination of these gates can be used to accomplish any
of the basic operations. Hence, NAND gate and NOR gate combination can produce an
inverter, an OR gate or an AND gate.

28
The output of a NAND gate is high when either of the inputs is high or if both the inputs
are low. In other words, the output is always high and goes low only when both the
inputs are high. The logic NAND function is given by the Boolean expression:
Truth Table
Logical Circuit X Y Z
0 0 1
Logical expression: 0 1 1
X
1 0 1
Z Z = ~(X & Y) 1 1 0
nand(Z,X,Y)
Y

NOR gate: The NOR gate is a digital logic gate that implements logical NOR. A HIGH
output (1) results if both the inputs to the gate are LOW (0); if one or both input is HIGH
(1), a LOW output (0) results. NOR is the result of the negation of the OR operator. The
NOR gate is one of the universal gates. A NOR gate combines an OR gate and a NOT gate.

Logical Circuit Logical expression Truth Table


Z = ~(X | Y) X Y Z
nor(Z,X,Y) 0 0 1
0 1 0
1 0 0
1 1 0

XOR gate : The Exclusive-OR gate or XOR gate is achieved by combining standard logic
gates together. XOR gate is used extensively in error detection circuits, computational
logic comparators and arithmetic logic circuits. The Exclusive OR gate gives an output
only if its two inputs are dissimilar, namely if one of them is high (one) and the other is
low (zero).
Truth Table
Logical Circuit X Y Z
Logical expression 0 0 0
Z=X^Y 0 1 1
X xor(Z,X,Y) 1 0 1
Z 1 1 0
Y

BASIC THEOREM OF BOOLEAN ALGEBRA


T1 : Properties of 0
(a) 0 + A = A
(b) 0 . A = 0
T2 : Properties of 1
(a) 1 + A = 1
(b) 1. A = A
T3 : Commutative Law
(a) A + B = B + A
(b) A .B = B A
T4 : Associate Law
(a) (A + B) + C = A + (B + C)
(b) (A .B) C = A (B. C)
T5 : Distributive Law
(a) A (B + C) = A B + AC
29
(b) A + (B C) = (A + B) (A + C)
(c) A+A’B = A+B
T6 : Indempotence (Identity ) Law
(a) A + A = A
(b) A A = A
T7 : Absorption (Redundance) Law
(a) A + A B = A
(b) A (A + B) = A
T8 : Complementary Law
(a) X+X’=1
(b) X.X’=0
T9 : Involution
(a) x’ = x
T10 : De Morgan's Theorem
(a) (X+Y)’=X’.Y’
(b) (X.Y)’=X’+Y’

De Morgan's Theorem:
‘De Morgan’ was one of the Cambridge mathematicians. He recognized that the nature of
algebra is purely symbolic. He was very much aware of the possibility that some
algebras differ from ordinary algebra.
We use De Morgan’s theorems to solve the expressions of Boolean algebra. It is a very
powerful tool used in digital design. De Morgan’s theorems can be used when we want
to prove that the NAND gate is equal to the OR gate that has inverted inputs and the
NOR gate is equal to the AND gate that has inverted inputs. To reduce the expressions
that have large bars, we must first break up these bars.
DeMorgan’s First Theorem:
DeMorgan’s First theorem proves that when two (or more) input variables
are AND’ed and negated, they are equivalent to the OR of the complements of the
individual variables. Thus the equivalent of the NAND function will be a negative-OR
function, proving that

We can show this operation using the following table.

Verifying DeMorgan’s First Theorem using Truth Table

30
We can also show that using logic gates

DeMorgan’s Second Theorem


DeMorgan’s Second theorem proves that when two (or more) input variables
are OR’ed and negated, they are equivalent to the AND of the complements of the
individual variables. Thus the equivalent of the NOR function is a negative-AND function
proving that

and again we can show this operation using the following truth table.

Verifying DeMorgan’s Second Theorem using Truth Table

Verifying DeMorgan’s Second


Theorem using Logic gates

31
EXERCISES
(Multiple Choice Question)
1. When the result of any Boolean statement is always 1 is known as ___________.
a) True
b) Tautology
c) Fallacy
d) False
2. When the result of any Boolean statement is always 0 is known as ______________.
a) True
b) Tautology
c) Fallacy
d) False
3. The logical operations can be carried out by which of the following?
a) Values and Variables
b) Functions and Laws
c) Operators and Operands
d) None of these
4. To denote NOT operation which of the following symbols is used?
a) bar
b) dot
c) plus
d) asterisk
5. The dot symbol is used to represent which of the following operation?
a) AND
b) OR
c) NOT
d) NAND
6. Which of the following are logical statements:
a) The Indian cricket team is a world champion in 2011.
b) The NOT function can be operated on more than one Boolean function.
c) Both a & b.
d) None of the above
7. Which of the following gate is also known as an inverter
a) AND
b) OR
c) NOT
d) NAND
8. Which of the following gate returns a true result if both inputs are true otherwise
false.
a) AND
b) OR
c) NOT
d) None of the above
9. Which gate can be written like A & B
a) AND
b) OR
c) NOT
d) XOR
10. Which gate returns true if both inputs are similar otherwise false.
a) NAND
b) NOR
c) XOR
d) None of the above

32
Answers:
1 2 3 4 5 6 7 8 9 10
B C C A A C C A A C

(Short Anwer Type Question)


Q. 1 What is a truth table? What is its significance?
Answer :- A Truth Table is a table which represents all the possible values of logical
variables / statements along with all the possible results of the given combinations of
values.
Q. 2 What does duality principle state? What is its usage in boolean algebra?
Answer: This states that starting with a boolean relation, another boolean relation can
be derived by:
1. changing each OR sign (+) to an AND sign (.)
2. changing each AND sign (.) to an OR sign (+)
3. replacing each 0 by 1 and each 1 by 0.
The derived relation using duality principle is called dual of original expression.
The postulates and theorems which have been presented can all be divided into pairs.
For example:-
X+X.Y=X
Its dual will be:
X.(X+Y)=X (Remember change . to + and vice-versa; complement 0 and 1.)

Q. 3 What is meant by tautology and fallacy?


Prove that 1+Y is a tautology and 0.Y is a fallacy.
Answer :-
Tautology:- If the result of any logical statement or expression is always TRUE or 1 for
all input combinations, it is called Tautology.
Fallacy:- If the result of any logical statement or expression is always FALSE or 0 for all
input combinations, it is called Fallacy.
• If we put value of Y = 0 or 1 in 1+Y, then result is always 1that's why this is tautology.
• If we put value of Y = 0 or 1 in 1.Y, then result is always 1that's why this is fallacy
Q. 4 Prove the complementarity law of boolean algebra with the help of a truth table.
Answer:
(i) Truth Table for X + X' = 1 (ii)Truth Table for X.X' = 0

X+X’ X.X’
X X’ X.X’
X X’ X + X’

0 1 0
0 1 1
1 0 0
1 0 1

33
Unit II: Computational Thinking and Programming – 1
Introduction to problem solving:
Problem solving is the process in which we identify a problem, developing an algorithm
for the identified problem and finally implementing the algorithm to develop a
computer program.
Steps for problem solving –
Problem solving starts with the identification of the problem and ends with a complete
solution in terms of a program or software. Key steps required for solving a problem
using a computer are-
i. Analysing the problem- we need to read and analyse the problem statement to solve
the problem and decide the core functionalities that our solution should have.
ii. Developing an Algorithm -It is essential to device a solution before writing a
program code for a given problem. Algorithm is a set of exact steps which when
followed ,solve the problem or accomplish the required task. For a given problem, more
than one algorithm is possible and we have to select the most suitable solution.

iii. Coding- convert the algorithm into the format which can be understood by the
computer to generate the desired solution. Different high level programming languages
can be used for writing a program.

iv. Testing and Debugging- The program created should be tested on various
parameters. The program should meet the requirements of the user. It must respond
within the expected time. It should generate correct output for all possible inputs.
Program should be checked for errors, if any.

Algorithm -A sequence of steps to accomplish the task. Such a finite sequence of steps
required to get the desired output is called an algorithm. It will lead to the desired result
in a finite amount of time, if followed correctly. Algorithm has a definite beginning and a
definite end, and consists of a finite number of steps.
Characteristics of a good algorithm are-
• Precision — the steps are precisely stated or defined.
• Uniqueness - results of each step are uniquely defined and only depend on the input
and the result of the preceding steps.
• Finiteness — the algorithm always stops after a finite number of steps.
• Input — the algorithm receives some input.
• Output — the algorithm produces some output.
Flowchart -A flowchart is a pictorial representation of an algorithm. We use boxes,
diamonds and other shapes, connected by arrows in flow chart.
Pseudocode-A pseudocode is a way of representing an algorithm. It is considered as a
non-formal language that helps programmers to write algorithm. It is intended for
human reading and cannot be executed directly by the computer. No specific standard
for writing a pseudocode exists. By writing the pseudocode the programmer safeguards
against leaving out any important step. Besides, for non-programmers, actual programs
are difficult to read and understand, but pseudocode helps them to review the steps to
confirm that the proposed implementation is going to achieve the desire output.

34
Basics of Python programming:
Introduction to Python -Python is a general-purpose Object Oriented Programming
language, High-level language Developed in late 1980 by Guido van Rossum at National
Research Institute for Mathematics and Computer Science in the Netherlands. It is an
Open Source Scripting language and is Case-sensitive language .
Features of Python
• Python is a high level language. It is a free and open source language.
• It is an interpreted language, as Python programs are executed by an interpreter.
• 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 has a rich library of predefined functions.
• Python is also helpful in web development. Many popular web services and
applications are built using Python.
• Python uses indentation for blocks and nested blocks
There are two ways to use the Python interpreter:
a) Interactive mode b) Script mode

Tokens – Smallest individual unit in a program is known as token. Tokens are of


following types-
keyword, identifier, literal, operator, punctuator
Keyword- Keywords are reserved words. Each keyword has a specific meaning to the
Python interpreter, and we can use a keyword in our program only for the purpose for
which it has been defined.
Identifier- Identifiers are names used to identify a variable, function, or other entities
in a program. The rules for naming an identifier in Python are as follows:
• The name should begin with an uppercase or a lowercase alphabet or an underscore
sign (_). This may be followed by any combination of characters a–z, A–Z, 0–9 or
underscore (_). Identifier cannot start with a digit.
• It can be of any length. (preferred to keep it short and meaningful).
• It should not be a keyword or reserved word
• We cannot use special symbols like !, @, #, $, %, etc., in identifiers.
Some valid identifiers are- sno , nam1, f_no, _a , false
Invalid identifiers are – First number , f.no, 1num , for
Variables- A variable in a program is uniquely identified by a name . Variable is an
object / an item or element that is stored in the memory. Variables must always be
assigned values before they are used in expressions. For example –
Num=10
City=”Bikaner”
A variable has three main components: Identity , Type and a Value .
Identity refers to the variable’s address in the memory. The address of an object can be
checked using the method id().
Literal-Literals are data items that have a fixed value. Python supports several kinds
of literals:
• String Literal
• Numeric Literals
• Boolean Literals
• Special Literals – None
35
String Literal is a collection of character(s) enclosed in a double or single quotes. It can
be either Single line strings or Multiline Strings
”456‟
“Rajasthan Bikaner‟
Numeric literals -
Integer Literals: it contain at least one digit and must not contain decimal point. It may
contain (+) or (-) sign.
Floating point Literals: Also known as real literals. Real literals are numbers having
fractional parts.
Complex number Literals: Complex number in python is made up of two floating.
Boolean literals in Python is used to represent one of the two Boolean values i.e. True or
False
Python has one Special literal, which is None. It indicates absence of value. In other
languages it is knows as NULL
Punctuators.-Punctuators are symbols that are used in programming languages to
organize sentence structure, and indicate the rhythm and emphasis of expressions,
statements, and program structure.
Common punctuators are: „ “ # $ @ []{}=:;(),.
Operator - An operator is used to perform specific mathematical or logical operation
on values. The values that the operators work on are called operands. For example, in
the expression 25 + fno, the value 25, and the variable fno are operands and the + (plus)
sign is an operator. Python supports several kinds of operators. They are -
• Arithmetic Operator
• Relational Operator
• Logical operators
• Assignment Operator
• Identity Operators
• Membership Operator
1. Arithmetic Operator

Operator Operation Description Example


+ Addition Adds two numbers >>>a=10
>>>b=4
>>>a+b
4
- Subtraction Subtract the operand >>>a=10
on the right from the >>>b=4
operand on the left >>>a-b
6
* Multiplication Multiplies the two values >>>a=10
>>>b=5
>>>a*b
50
/ Division Divides the operand >>>a=10
on the left with the >>>b=5
operand on the >>>a/b
right 2

36
% Modulus Divides the operand on >>>a=10
the left with the >>>b=3
operand on the right >>>a%b
and returns the 1
remainder
// Floor Division Floor division. To >>>a=10
find the integer part >>>b=6
of the quotient when >>>a/b
one number is 1
divided by the other.
The result is always
the largest integer
less than or equal to
the actual quotient.
** Exponent To raise a number to >>>a=2
the power of another >>>b=3
number. >>>a**
b
8
Relational Operator
Operator Operation Description Example
== Equals to Compares two values. If both are equal >>>x=5
returns true else returns False >>>y=4
>>>z=4
>>>x==y
False
>>>y==z
True
!= Not Equals to Compares two values. If both are not >>>x!=y
equal returns true else returns False True
>>>y!=z
False
> Greater Than If the value of the left operand is greater >>>y>x
than operand on the rightside of False
operator then returns true else return >>>x>z
False True
< Less than If the value of the left operand is smaller >>>y<z
than operand on the rightside of True
operator then returns True >>>x<y
else return False False
>= Greater than or If the value of the left operand is greater >>>z>= y
equal to than or equal to operand on the right True
side of operator then >>> y>= x
returns True else return False False
<= Less than or If the value of the left operand is smaller >>>x<= y
equal to than operand on the rightside of False
operator then returns true else return >>>z <= x
False True
37
Logical operators
Operators Description Example
And Combines two conditions and returnsTrue if >>>a=6
both conditions are True else returns False >>>b=5
>>>a==6 and b==5
True
>>>a1==10 and b==5
False
Or Combines two conditions and returns True if any >>>a==6 or b==0
condition is True else returnsFalse True
>>>a==0 or b==4
False
Not Negates a condition and returns True if the >>>not (a==0)
condition is False, otherwise returns False. True
>>>not (b==5)
False
Assignment Operator
Operator Description Example (x=2,
y=5)
= Assigns value from right side operand to left side >>>z=x+y
operand >>>z
7
+= It adds the value of right-side operand to the >>>x+=2
left-side operand and assigns the result to the
>>>x
left-side operand
4

-= It subtracts the value of right-side operand from >>>x-=2


the left-side operand and assigns the result to >>>x
left-side operand 0

*= It multiplies the value of right-side operand >>>x*=5


with the value of left-side operand and assigns
>>>x
the result to left-side operand
10

/= It divides the value of left-side operand by the >>>x/=y


value of right-side operand and assigns the
>>>x
result to left-side operand
0.4

%= It performs modulus operation using two >>>x%=2


operands and assigns the result to left-side
>>>x
operand
0

//= It performs floor division using two operands >>>x//=3


and assigns the result to left-side operand >>>x
0

38
**= It performs exponential (power) calculation on >>>x**=3
operators and assigns value to the left-side
>>>x
operand 8

Identity operator
Operator Description Example
Is Evaluates True if the variables on either side >>> num1 = 5
of the operator point towards the same >>> type(num1) is int
memory location and False otherwise. var1 True
is var2 results to True if id(var1) is equal to >>> num2 = num1
id(var2) >>> id(num1)
1433920576
>>> id(num2)
1433920576
>>> num1 is num2
True
is not Evaluates to False if the variables on either >>> num1 is not num2
side of the operator point to the same False
memory location and True otherwise. var1
is not var2 results to True if id(var1) is not
equal to id(var2)
6. Membership Operator
Operators Description Example
In It return True in case value exists in >>>N=[5,7,1]
sequence, otherwise false. >>>1 in N
True
>>> 4 in N
False
not in return True if value does not exists in the >>>N=[4,8,7]
sequence, else false. >>>4 not in L
False
>>> 0 not in L
True
Precedence of Operators:
The order in which the operators are executed in an expression is called the operator
precedence. Operator precedence of some common operators are given below:

39
Comments- Comments are used to add a remark or a note in the source code. they
are not executed by interpreter. They are added with the purpose of making the source
code easier for humans to understand. In Python, a comment starts with # (hash sign).
Everything following the # till the end of that line is treated as a comment.

Data Types-
Data Type specifies which type of value a variable can store. type () function is used to
determine a variable's type in Python. Data type in Python can be categorized as
follows:
1. Number: Number data type stores numerical values. A feature Python is that there
is no need to declare a numeric value to define its type. Python can easily
differentiate one data typefrom another when you write and run your statement.
(a) int(integer): Integer represents whole numbers without any fractional part. They
can be positive or negative and have unlimited size in Python. Example: -6, 468, 0, 4, -
43.
(b) float(floating point number): Floating point numbers denote real numbers or
floating point values (i.e., numbers with fractional part). Example: 3.14, 565.34, 0.76, 4.0
(c)Complex Numbers: Complex numbers in Python are made up of pairs of real and
imaginary numbers. They take the form ‘x + yj’ or ‘x + yJ’ Example:
a = complex(50) # convert 50 to a real part val and zero imaginary part
b=complex(87,54) #convert 87 with real part and 54 as imaginary part
print(b)

Output :-
(5+0j)
(101+23j)
2. str(string):A string is a sequence of characters that can be a combination of letters,
numbers and special symbols, enclosed within quotation marks, single, double, or
triple (‘ ‘ or “ “ or ‘‘‘’’’). These quotes are not part of the string.
3. Boolean: Boolean data type represents one of the two possible values, True or False.
Any expressionwhich can be True or False has the data type bool.
4. None: This is a special data type with a single value. It is used to signify the absence
of value/condition evaluating to False in a situation. It is represented by None.
5. List: A list is a collection of values or an ordered sequence of values/items. The
items in a listcan be of any type such as string, integers, float, objects or even a list.
Elements of a list are enclosed in square brackets [ ], separated by commas.
Example: >>> A = [6,8,2,9,100]
>>>print( A )
[6,8,2,9,100]
6.Tuple: Tuple is another sequence data type similar to the list. A tuple consists of a
number of values separated by commas. Unlike lists however, tuples are enclosed
within parentheses. Elements in a tuple need not be of the same type, they can be
heterogeneous.
Example: >>> T = ( 80,40,25, 30, 50 )
>>>print( L )
( 80,40,25, 30, 50)

40
7.Dictionary: -Python-dictionary is an unordered collection of items where each item
is a key-value pair. We can also refer to a dictionary as a mapping between a set of keys
and set of values. The items of a dictionary are enclosed within curly braces and items
are separated by commas.The key value pairs are separated by colon (:).
Example: Dict = { “Hindi” : 96, “English” : 88, “Maths” : 91 }

Mutable and Immutable Types


Mutable data types: Data types where the value can be changed in place. Example:
dictionary, sets, lists etc.
Immutable data types: Data types where the values cannot be changed in place.
Example: integer, float, string, tuples etc.

Expression- An expression is defined as a combination of constants, variables, and


operators. An expression always evaluates to a value. A value or a standalone variable is
also considered as an expression but a standalone operator is not an expression. Some
examples of valid expressions are given below.
(i) 750 (iv) 5.0 + 9.54 (ii) avg (v) 23/3 -5 * 7 +(14 -2*a) (iii) num – 20 (iv) "India" +
"Russia"

Statement- In Python, a statement is a unit of code that the Python interpreter can
execute. For example
a=50
x=sum(4,5)

input/output - input() function is used for taking the user input. The input()
function prompts the user to enter data. It accepts all user input as string.
name = input("Enter your name: ")
print() function is used to output data to the screen. It evaluates the expression before
displaying it on the screen. The print() outputs a complete line and then moves to the
next line for subsequent output. The syntax for print() is:
print(value [, ..., sep = ' ', end = '\n'])
print( "Bikaner")

Type Conversion: It is the process of converting the value of one data type to
another.

There are two types of type conversions in Python:


1. Implicit Type Conversion: In this, Python automatically converts value from one
data type to another Example:
>>> a=2 # a is integer
>>> b=55.4 # b is float
>>> c=a+b # c will be float
>>> print(c) # will print 57.4

2. Explicit Type Conversion or type casting: In this type of conversion, programmer


forces to convert data type of an object to required data type. functions int (), float () or
str ( ) etc. can be used. Example:
>>> a=2 # a is integer
>>> b=55.4 # b is float
>>> c=int(a+b) # c is int
>>> print(c) # will print 57

41
Debugging- The process of identifying and removing errors or mistakes from a
program is called debugging and the mistakes known as errors. Errors can be
categorized as:
i) Syntax errors
ii) Logical errors
iii) Runtime errors
1. Syntax Error:
If a statement is not written as per syntax/ rules of python, syntax errors are there and
interpreter shows error message(s) and stops the execution there. Example 1:
print(“India) #syntax error as right double quote is missing
Example 2: Print(“Hello”) #syntax error due to P is capital

2. Logical Error:
Logical errors are the most difficult to find and fix. These types of error is caused due to
wrong logic. No syntax error /error message will be there.
Example:
x=5
y = 10
m=x+y
print (“Multiplication of x and y = “, m) # results wrong as used + instead of *
3.Runtime Error:
A runtime error causes abnormal termination of program while it is executing. In this
error statement is correct syntactically, but the interpreter cannot execute it. Runtime
errors do not appear until after the program starts running or executing. For example, a
statement having division operation in program, if denominator value is zero then it
will give a runtime error “division by zero”.

42
Flow of Control
The order of execution of the statements in a program is known as flow of control.
Control statements are used to control the flow of execution depending upon the
specified condition/logic. There are three types of control /flow statements-
1. Sequential flow
2. Conditional Flow
3. Iterative flow

Sequential flow- It is the concept, where Python executes one statement after another
from beginning to the end of the program.
Conditional / Decision making statement-Decision making statement used to control
the flow of execution of program depending upon condition. Following conditional
statements available in python -
• if statement
• if-else statement
• if-elif- else statement
• Nested if statement
if statement-In this it checks the condition and execute the statement if the condition is
true and do nothing if the condition is false.
Syntax:
if condition:
Statements
Example-
x=1
if(x==1 ):
print(“x is one”)
if-else statement-if with else is used to test the condition and if the condition is True it
perform /execute true block otherwise false block.
Syntax:
if condition:
Statements #True Block
else:
Statements # False block
Example-
num = int(input("Enter a number= "))
if (num%2==0):
print("even number ")
else:
print("odd number")
if-elif- else statement-In this variant of if multiple chain of condition is to be checked.
Each elif must be followed by condition: and then statement for it. After every elif we
can give else which will be executed if all the condition evaluates to false
Syntax:
if condition:
Statements
elif condition:
Statements
elif condition:
Statements
else:
Statement
43
Nested if statement- In nested type of “if” we use if within another if as a statement of
it. Mostly used in a situation where we want different else for each condition. Syntax:
if condition1:
if condition2:
statements
else:
statements
elif condition3:
statements
else:
statements

Example:
num = float (input ("Enter a number: "))
if num>= 0:
if num == 0:
print("Zero")
else:
print("Positive number")
else:
print("Negative number")

Iterative statements /Loop: To carry out repetition of statements Python provide


2 loop statements- for loop and while loop.

for loop- This loop is used to iterate over a range of values or a sequence. The for loop
is executed for each of the items in the range. These values can be either numeric, or,
they can be elements of a data type like a string, list, or tuple.
Syntax:
for val in sequence:
statements #body of loop
Example-1
city=["Bikaner","Jodhpur,"Jaipur","Sikar"]
for i in city:
print(i)

Example-2 (print all the natural number from 1 to 10)


for i in range(1,11):
print(i)

Usage of Range()-
It is used to create a list containing a sequence of integers from the given start value up
to stop value (excluding stop value), with a difference of the given step value. The range
() is a built-in function in Python. Syntax of range () function is:
range([start], stop[, step])

range (10) will generate set of values from 0-9


range (1,10,2) will produce [1,3,5,7,9]
>>>’a’ in ‘apple’
True
>>>’national’ in ‘international’
True
44
for i in range (5,3,-1):
print(i)
for i in range (3,5):
print(i)
While loop- It is used to execute a block of statement as long as a given condition is true
and when the condition become false, the control will come out of the loop. The
condition is checked every time at the beginning of the loop.
Syntax
while (condition):
statements # body of loop
example-1
x = 10
while (x <= 20):
print(x)
x=x+1

Example-2
x=1
while (x < 3):
print('inside while loop value of x is ',x)
x=x+1
else:
print('inside else value of x is ', x)

Jump Statements- These statements are used to transfer the program's flow from one
location to another. There are two types of jump statements -.
1. break
2. continue
Break- The break statement terminates the current loop and resumes execution of the
statement following that loop.
Example-
for I in range(1,100):
if i == 10:
break
print(i) # the code will print only 1 to 9
Continue- The continue statement skips the current execution of loop and jump for
next execution of the loop.
Example-
for I in range(1,100):
if i == 10:
continue
print(i) # the code will print 1 to 99 without 10
pass -This statement does nothing but can be used if no action in a statement.
for i in range (1,100):
if(i >=50):
pass
else:
print(i)

45
==================================================================
Exercises
(MCQ type Question 1 Marks)
1. Who developed Python Programming Language?
a) Wick van Rossum b) Rasmus Lerdorf
c) Guido van Rossum d) Niene Stom
Answer: c
2. Which of the following is the correct extension of the Python file?
a) .python b) .pys
c) .py d) .p
Answer: c
3 What will be the value of the following Python expression?
1 + 10 % 4
a) 3 b) 2
c) 11 d) 1
Answer: a
4. Which of the following character is used to give single-line comments in Python?
a) @ b) #
c) ! d) /*
Answer: b
5. Which one of the following is not a keyword in Python language?
a) for b) evals
c) while d) false
Answer: d
6. What will be the output of the following Python program?
i=1
while i < 5:
i += 1
print(i)
a) 5 b) 0
c) 1 d) none of the mentioned
Answer:a
7. run tyme error in a code means:
(a)You have not used correct logic.
(b) There was error while running the program.
(c) There is an error with your typing and code structure
(d) None of above.
Answer: b
8. Which of the following is not a core data type in Python programming?
a) Tuples b) Lists
c) Class d) Dictionary
Answer: c
9. What will be the output of the following Python code?
x = 'abcd'
for i in x:
print(i.upper())
a) a B C D b) a b c d
c) error d) A B C D
Answer: d
10.What will be the output of the following Python statement?
>>>"a"+"bc"
a) bc b) abc
c) a d) bca
Answer: b
46
(VSA type Question 2 Marks)
1. What are data types? How are they 2. What are immutable and mutable
important? types? List immutable and mutable
Answer = representation of many types types of python.
of data in by provided facilities is called Answer = immutable type :- those
data type . types whose value never change is
Example = integer, string , list etc. known as immutable type.
They are play very important role in Example = integer , string , Boolean,
programming because without any tuples , e.c.t
data of program , program can cause Mutable type: - those type whose value
error , so program needed data can be change is known as mutable
type.Example = list, dictionary, set
3. What are tokens in Python? How 4. What will the result given by the
many types of tokens are allowed in following ?
python? Exemplify your answer. (a)type(6+3)
Answer =Token are smallest individual (b)type(6-3)
unit in a program. (c)type(6*3)
Type of tokens (d)type(6/3)
keywords : False, True, for, while (e)type(6//3)
identifiers : a, A, lst, dic (f)type(6%3)
literal : “python”, 5, 9, ‘class11’ Answer =
operator : +, -, /, *, **, %, // (a)int (b)int (c)int
punctuators :&, ^, ?, #, @, ! (d)float (e)int (f)int

5. What are variables? How are they 6. In Python, strings are immutable
important for a program? while lists are mutable. What is the
Answer =Variable is a label that can difference?
used in process of program. it can Answer =(i) In consecutive locations,
contain numeric values, character, strings store the individual characters
string is called variable. while list stores the references of its
Variable play very important role in elements
programming because they enable (ii) Strings store single type of
programmers to write flexible elements - all characters while lists can
programs. without variable we can not sore elements belonging to different
enter the data directly in the program. types.

7. What is a cross-platform software? 8. How are these numbers different


Answer =Cross-platform software from one another? 33, 33.0, 33j, 33 +j
means that software that can work Answer --
easily in all type of operating system. 33 = integer
Example – windows, Linux, 33.0=floating point number
smartphone etc. 33j = complex number
33+j = complex number
9. What is the difference between 10. What is debugging?
implicit type conversion and explicit Answer= The process of identifying
type conversion? and removing errors or mistakes from
Answer = the basic difference between a program is called debugging and the
implicit and explicit type conversion is mistakes known as errors.
that implicit is taken care by compiler
itself , while explicit is done by the
programmer .

47
(Short answer type Question 2 Marks)

Q-1 Rewrite the following code Q-2 Find the output of the following code
fragments using for loop: segments:
i = 10 x = 40
while (i > 0) : y=x+1
print (i) x = 20, y + x
i -= 3 print (x, y)
Answer = Answer =
for i in range (10,0,-3): Output:
print (i) (20, 81) 41

Q-3 What will be the output Q-4 What will be the output produced by
produced by following code following code?
fragment (s)? (a)
X = 10 >>> str(print()) + "One"
X = X + 10 (b)
X=X-5 >>> str(print("hello")) + "One"
print (X) Answer =
X, Y = X- 2, 22 (a)
print (X, Y) 'NoneOne'
answer= (b)
5 hello
13 22 'NoneOne'
Q-5 Rewrite the following code Q-6 Find the output of the following code
fragment that saves on the number segments:
of comparisons: var = 7
if (a == 0) : while var > 0:
print ("Zero") print ('Current variable value: ', var)
if (a == 1) : var = var -1
print("One") if var == 3:
if (a == 2) : break
print ("Two") else:
if (a == 3) : if var == 6:
print ("Three") var = var -1
Answer = continue
if (a == 0) : print ("Good bye!")
print ("Zero") Answer :-
elif (a == 1) : Current variable value: 7
print("One") Current variable value: 5
elif (a == 2) : Good bye!
print ("Two") Current variable value: 4
elif (a == 3) :
print ("Three")
Q-7 How is break statement different Q-8 Find out the error(s) in following code
from continue? fragments:
Answer = a, b, c = 2, 8, 9
Break :- A break statement skips the print (a, b, c)
rest of the loop and jumps over to thec, b, a = a, b, c
statement following the loop. print (a; b; c)
answer=
Continue :- The continue statement a, b, c = 2, 8, 9
skips the rest of the loop statements print (a, b, c)

48
and causes the next iteration of the c, b, a = a, b, c
loop to take place. print (a, b, c)

Q-9 What is the purpose of range() Q-10 Write Pseudo code to calculate area of
function? Give one example. circle.
Answer :-It is used to create a list Answer:-
containing a sequence of integers t = input "Enter Radius of circle "
from the given start value up to stop Area = pi * r * r
value (excluding stop value), with a Display Area
difference of the given step value.
Example :-
for i in range(100) :
It will run from 0 to 99.
Q-11Find the output of the following Q-12 Find the output of the following code
code segments: segments:
a = 110 i = 0; sum = 0
while a > 100: while i < 9:
print(a) if i % 4 == 0:
a -= 2 sum = sum + i
Answer :- i=i+2
110 print (sum)
108 Answer :-
106 0
104 0
102 4
4
12
Q-13 Find the output of the following Q-14 Find the output of the following code
code segments: segments:
country = 'INDIA' for i in range(20,30,2):
for i in country: print(i)
print (i)
Answer :-
Answer :- 20
I 22
N 24
D 26
I 28
A
Q-15 Find the output of the following Q-16 What will be output produced by
code segments: following code? State reason.
for x in range(1,4): a=5-4-3
for y in range(2,5): b = 3 ** 2 ** 3
if x * y > 10: print(a)
break print(b)
print (x * y) Answer =
Answer :- Line 1:
2 a = -2
3 Line 2:
4 b = 3 ** 2 ** 3
4 = 3 ** 8
6 So for:
8 b = 6561
6
49
9
Q-17 Draw flow chart to calculate Q-18 Write algorithm to calculate simple
simple interest. interest.
Answer :-
1. Start
2. Input principal
3. Input rate
4. Input time
5. Simple interest principal * rate * time
6. Print simple interest
7. Stop

50
STRING IN PYTHON

Definition: String is a collection of characters. Strings can be created by enclosing


characters inside a single quote or double-quotes. Even triple quotes can be used in
Python but generally used to represent multiline strings. Python does not have a
character data type, a single character is simply a string with a length of 1.

Basics of String:
• Strings are immutable means that the contents of the string cannot be changed
after it is created. At the same memory address, the new value cannot be stored.
Python does not allow the programmer to change a character in a string.
Example:
>>>str='jaipur'
>>>str[0]='J'
TypeError: 'str' object does not support item assignment
As shown in the above ex

ample, str has the value “jaipur”. An attempt to replace ‘j’ in the string by
‟J‟ displays a TypeError.
• Each character has its index or can be accessed using its index.
• String in python has two-way index for each location. (0, 1, 2, ……. In the forward
direction and -1, -2, -3, …….. in the backward direction.)
Example:
0 1 2 3 4 5 6
T E A C H E R
-7 -6 -5 -4 -3 -2 -1

• The index of string in forward direction starts from 0 and in backward direction
starts from -1.
• The size of string is total number of characters present in the string. (If there are
n characters in the string, then last index in forward direction would be n-1 and
last index in backward direction would be –n.)
• String are stored each character in contiguous location.
• The character assignment is not supported in string because strings are
immutable.

Accessing Characters in a String


As we know, string is a collection of characters and individual character can be accessed
by its position called index. Square brackets can be used to access elements of the string.

Example:
>>>s=”TEACHER”
>>>s[1]
‘E’ # returns index 1 position
>>>s[-4]
‘C’ #returns index -4 position

Traversing a String: Access all elements of string, one character at a time.

51
s=”TEACHER” s=”TEACHER”
for ch in s : for i in range(len(s)):
print(ch) print(s[i])

>>>len(s) # returns length of string.

String Operators:
A). String concatenation Operator: Concatenation means to join two values. In
Python, + symbol is used to concatenate the strings.
>>>name="Jay"
>>>msg="Hello "
>>>print(msg+name)
'Hello Jay' #concatenated string
Note: You cannot concate numbers and strings as operands with + operator.
Example:
>>>7+’4’ # unsupported operand type(s) for +: 'int' and 'str'
It is invalid and generates an error.
B). String repetition Operator: It is also known as String replication operator.
Replication can be performed by using * operator between the string. It will repeat the
string n times, where n is the integer providedple:
>>>s="Ha"
>>> s*3
'HaHaHa' #Replication
Note:You cannot have strings as n=both the operands with * operator.
Example:
>>>”Ha” * “Ha” # can't multiply sequence by non-int of type 'str'
It is invalid and generates an error.
C). Membership Operators: In and not in are two membership operators to find the
appearance of a substring inside the string.in – Returns True if a character or a substring
exists in the given string; otherwise, False
not in - Returns True if a character or a substring does not exist in the given string;
otherwise, False
Example: >>> "T" in "TEACHER"
True
>>> "ea" in "TEACHER "
False
>>>"CH" not in "TEACHER "
False
D). Comparison Operators: These operators compare two strings character by
character according to their ASCII value. ASCII Values can be finding out by given
functions.
Characters ASCII (Ordinal) Value
‘0’ to ‘9’ 48 to 57
‘A’ to ‘Z’ 65 to 90
‘a’ to ‘z’ 97 to 122

Function Description
ord(<character>) Returns ordinal value of a
character
chr(<value>) Returns the corresponding
character

52
Example:
>>> 'abc'>'abcD'
False
>>> 'ABC'<'abc'
True
>>> 'abcd'>'aBcD'
True
>>> 'aBcD'<='abCd'
True
>>> ord('b')
98
>>> chr(65)
'A'

Slicing in Strings: Extracting a subpart from a main string is called slicing .It is done
by using a range of indices.
Syntax:
>>>string-name[start:stop:step]
Note: it will return a string from the index start to stop-1.
Example:
>>> s="TEACHER"
0 1 2 3 4 5 6
T E A C H E R
-7 -6 -5 -4 -3 -2 -1

>>> s[2:6:1]
'ACHE'
>>> s[6:1:-1]
'REHCA'
>>> s[0:10:2]
'TAHR'
>>> s[-8:-3:1]
'TEAC
>>> s[ : 6 : 1] # Missing index at start is considered as 0.
'TEACHE'
>>> s[2 : :2] # Missing index at stop is considered as last index.
'AHR'
>>> s[3:6: ] # Missing index at step is considered as 1.
'CHE'
>>> s[ : :-1]
'REHCAET'
>>> s[2: :]+s[ :2 :]
'ACHERTE'
>>> s[1: 5:-1]
‘‘

Built-in functions of string:

str=”data structure” s1= “hello365” s2= “python” s3 = ‘4567’


s4 = ‘ ‘ s5= ‘comp34%@’

53
S. Function Description Example
No.
1 len( ) Returns the length of a string >>>print(len(str))
14
2 capitalize( ) Returns the copy of the string with its >>> s1.capitalize()
first character capitalized and the rest 'Hello365'
of the letters are in lowercased.
3 find(sub,start,en Returns the index of the first >>>s2.find("thon",1,7)
d) occurence of a substring in the given 3
string (case-sensitive). If the >>> str.find("ruct",8,13)
substring is not found it returns -1. -1
4 isalnum( ) Returns True if all characters in the >>>s1.isalnum( )
string are alphanumeric (either True
alphabets or numbers). If not, it >>>s2.isalnum( )
returns False. True
>>>s3.isalnum( )
True
>>>s4.isalnum( )
False
>>>s5.isalnum( )
False
5 isalpha( ) Returns True if all characters in the >>>s1.isalpha( )
string arealphabetic. False otherwise. False
>>>s2.isalpha( )
True
>>>s3.isalpha( )
False
>>>s4.isalpha( )
False
>>>s5.isalpha( )
False
6 isdigit( ) Returns True if all the characters in >>>s1.isdigit( )
the string aredigits. False otherwise. False
>>>s2.isdigit( )
False
>>>s3.isdigit( )
True
>>>s4.isdigit( )
False
>>>s5.isdigit( )
False
7 islower( ) Returns True if all the characters in >>> s1.islower()
the string arelowercase. False True
otherwise. >>> s2.islower()
True
>>> s3.islower()
False
>>> s4.islower()
False
>>> s5.islower()
True

54
8 isupper( ) Returns True if all the characters in
>>> s1.isupper()
the string areuppercase. False False
otherwise. >>> s2.isupper()
False
>>> s3.isupper()
False
>>> s4.isupper()
False
>>> s5.isupper()
False
9 isspace( ) Returns True if there are only whitespace
>>> " ".isspace()
characters in the string. False
True
>>> "".isspace()
False
10 lower( ) Converts a string in lowercase >>> "HeLlo".lower()
characters. 'hello'
11 upper( ) Converts a string in uppercase >>> "hello".upper()
characters. 'HELLO'
12 lstrip( ) Returns a string after removing >>> str="data structure"
the leading characters. (Left side). >>> str.lstrip('dat')
if used without any argument, it ' structure'
removes theleading whitespaces. >>> str.lstrip('data')'
structure'
>>> str.lstrip('at')
'data structure'
>>> str.lstrip('adt')
' structure'
>>> str.lstrip('tad')
' structure'
13 rstrip( ) Returns a string after removing the >>> str.rstrip('eur')
trailingcharacters. (Right side). 'data struct'
if used without any argument, it >>> str.rstrip('rut')
removes thetrailing whitespaces. 'data structure'
>>> str.rstrip('tucers')'data
'
14 split( ) Splits the string from the specified >>> str="Data Structure"
separator and returns a list object >>> str.split( )
with string elements. ['Data', 'Structure']

Exercise Questions: String

1 Mark Questions
Q.No Question Answer
1. print the string “India” 10 times. >>>”india”*10
2. What is the output of the following code False
>>>‘a’ in “computer”
3. What is the output of the following code ‘cmue’
Strg=”computer”
print(Strg[ 0: 8 : 2]
4. What is the output of the following? “India”
print('INDIA'.capitalize())
5. Which of the following is not valid string (iii) “Hello’
in Python?
55
(i) “Hello” (ii) ‘Hello’
(iii) “Hello’ (iv) None of the above
6. Suppose word = ‘amazing’, the what will ‘giaa’
be word[: : -2]?

2 Mark Questions
Sr. Question Answer
1. If you give the following for str1=”Hello” String is immutable data type.So it
why does python report error str1[2]=’p’ does not support item assignment
2. Identify the output of the following Vidya
Python statements.
x="Vidyalaya"
y="Vidya"
if(y in x):
print(y)
3. Look at the code sequence and select the kvsrojAIPUR
correct output
str="KVS RO Jaipur"
for i in str:
if(i.isupper()==True):
print(i.lower(),end="")
if(i.islower()==True):
print(i.upper(), end="")
4. Find the correct output of the following -1
>>>str="The planet earth looks like a
blue marble from outer space"
>>>print(str.find('marble',50))
5. Find the value stored in ctr at the end of 12
this code snippet:
mystr="Darjeeling Tea has a strong
flavour"
ctr=0
for i in mystr:
if i in 'aeiouAEIOU':
ctr += 1
print(ctr)

3 Mark Questions
Sr. Question Answer
1. Write a Python program to input a line of line=input ("Enter a line of text :")
text and a character from user to print ch=input ("Enter a character to
the frequency of the character in the line. search ")
For example k=line.count(ch)
Line entered is : this is a golden pen print ("Frequency is :",k)
The character to search : e
Then output is : Frequency is 2
2. Write a Python Program to input a string s=input("Enter a word :")
to check whether it is a Palindrome string print ("You entered :", s)
or not. (A Palindrome string is that which length=len(s)
is same from both ends like – NITIN, rev=""
MALAYALAM, PULLUP) for i in range (-1,-length-1,-1):
rev=rev+s[i]
if s==rev:
print ("Yes, palindrome")
56
else:
print ("Not a palindrome")
3. Using string replication techniques print for a in range(1,4):
the following pattern using any loop. print("hello " * a)
Hello
Hello Hello
Hello Hello Hello

4 Mark Questions
Sr. Question Answer
1. Find Output: Jhu
my_string = 'Jhunjhunu' J@H@U@N@J@H@U@N@U@
print(my_string[:3]) Jhunjhunu
for i in range(len(my_string)): Njh
print(my_string[i].upper(),end="@")
print()
print (my_string)
print (my_string[3:6])
2. Consider the following string mySubject: Computer Science
mySubject = "Computer Science" Scienc
What will be the output of the following Cmue cec
string operations : e
print(mySubject[0:len(mySubject)]) Computer ScienceComputer Science
print(mySubject[-7:-1]) eniSrtpo
print(mySubject[::2])
print(mySubject[len(mySubject)-1])
print(2*mySubject)
print(mySubject[::-2])
3. Consider the following string country: a)Great India
country= "Great India" b)t Indi
What will be the output of the following c)GetIda
string operations(Any Four):- d)a
a) print(country[0:len(country)]) e)Great IndiaGreat India
b) print(country[-7:-1]) f)Great India
c) print(country[::2])
d) print(country[len(country)-1])
e) print(2*country)
f) print(country[:3] + country[3:])

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

57
Lists in Python
List is a standard data type of Python. It is a sequence which can store values of any
kind. In Python, list and dictionary are mutable data types.

➢ List is represented by square brackets “ [ ] “


For ex -
➢ [ ] Empty list

➢ [1, 2, 3] integers list

➢ [1, 2.5, 5.6, 9] numbers list (integer and float)

➢ [ ‘a’, ‘b’, ‘c’] characters list

➢ [‘a’, 1, ‘b’, 3.5, ‘zero’] mixed values list

➢ [‘one’, ’two’, ’three’] string list


Access Items From A List
List items can be accessed using its index position.
List is a sequence like a string.

•List also has index of each of its element.

•Like string, list also has 2 index, one for forward indexing (from 0, 1, 2, 3, ….to n-1) and
one for backward indexing(from -n to -1).

•In a list, values can be accessed like string.


Example:
L=[ 10,20,30,40,50,60,70,80,90,100]

0 1 2 3 4 5 6 7 8 9  Forward
Indexing
10 20 30 40 50 60 70 80 90 100
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1  Backward
Indexing
>>>L[2] Shows : 30
>>>L[-1] Shows : Last element of list i.e. 100.
Traversal of a list :Traversal of a list means to access and process each and every
element of that list. Traversal of a list is very simple with for loop –
L=[10,20,30,40,50,60,70,80,90,100]
for i in L :
print(i)

10
20
30
40
50
60
.
.
Operators in List :
A).Concatenation (+ Operator): Python allows us to join two or more lists using

58
Concatenation operator depicted by the symbol +.
Example :
>>> list1 = [1,3,5,7,9]
>>> list2 = [2,4,6,8,10]
>>>list1+list2 # + operator
[1,3,5,7,9,2,4,6,8,10]

B). Repetition/ Replication Operator (* operator): Python allows us to replicate a


list using repetition operator depicted by symbol *.
Example:
>>> s = ['Hello']
>>> s * 4
['Hello', 'Hello', 'Hello', 'Hello']

C). Membership( in / not in operator) : Like strings, the membership operators in


checks if the element is present in the list and returns True, else returns False.
Example:
>>> list1 = ['Red', 'Green', 'Blue']
>>> 'Green' in list1
True
>>> 'Cyan' in list1
False

The not in operator returns True if the element is not present in the list, else it returns
False. Example:

>>> list1 = ['Red', 'Green', 'Blue']


>>> 'Cyan' not in list1
True
>>> 'Green' not in list1
False

Slicing : Like strings, the slicing operation can also be applied to lists. List elements
can be accessed in subparts.
>>>list_name[start:stop:step]
Examples:

l=[10,20,30,40,50,60,70,80,90,100]
>>> l[2:6:1]
[30, 40, 50, 60]
>>> l[0:20:2]
[10, 30, 50, 70, 90]
>>> l[-8:-1:1]
[30, 40, 50, 60, 70, 80, 90]
>>> l[ : 6:1]
[10, 20, 30, 40, 50, 60]
>>> l[2 : : 2]
[30, 50, 70, 90]
>>> l[ : : -1]
[100, 90, 80, 70, 60, 50, 40, 30, 20, 10]
>>> l[1:6:-1]
[]
>>> l[ : : 2]
[10, 30, 50, 70, 90]

59
List Methods and Built-in Functions :- Python provides some built-in
functions for list manipulation .
>>>List_name.functionname()
Ex : l=[10,20,30,40,50,60,70,80,90,100]

Function/Method Description Example


Name
len(list) Returns number of elements in >>>len(l)
given list. 10
list(sequence) It converts a sequence into list >>>list(“python”)
format. [‘p’,’y’,’t’,’h’,’o’,’n’]
List.index(<item>) Returns the index of passed >>> list1 = [10,20,30,20,40,10]
items. >>> list1.index(20)
1
>> list1.index(90)
ValueError: 90 is not in list
List.append(<item>) Appends a single element passed >>> list1 = [10,20,30,40]
as an >>> list1.append(50)
argument at the end of the list >>> list1
The single element can also be a [10, 20, 30, 40, 50]
list >>> list1 = [10,20,30,40]
>>> list1.append([50,60])
>>> list1
[10, 20, 30, 40, [50, 60]
List.extend(<list>) Append the list (passed in the >>> list1 = [10,20,30]
form of argument) at the end of >>> list2 = [40,50]
list with which function is called. >>> list1.extend(list2)
>>> list1
[10, 20, 30, 40, 50]
List.insert(<pos>, Insert the passed element at the >>> list1 = [10,20,30,40,50]
<item>) passed position. >>> list1.insert(2,25)
>>> list1
[10, 20, 25, 30, 40, 50]
>>> list1.insert(0,5)
>>> list1
[5, 10, 20, 25, 30, 40, 50]
List.pop(<index>) Delete and return the element of >>> list1 = [10,20,30,40,50,60]
passed index. Index passing is >>> list1.pop(3)
optional, if not passed, element 40
from last will be deleted. >>> list1
[10, 20, 30, 50, 60]
>>> list1 = [10,20,30,40,50,60]
>>> list1.pop()
60
List.remove(<value>) It will delete the first occurrence >>> list1 = [10,20,30,40,50,30]
of passed value but does not >>> list1.remove(30)
return the deleted value. >>> list1
[10, 20, 40, 50, 30]
>>> list1.remove(90)
ValueError:list.remove(x):x
not in list

60
List.clear ( ) It will delete all values of list and >>> list1 = [10,20,30,40,50,30]
gives an empty list. >>> list1.clear()
>>> list1
[]
List.count (<item>) It will count and return number >>> list1 = [10,20,30,10,40,10]
of occurrences of the passed >>> list1.count(10)
element. 3
>>> list1.count(90)
0
List.reverse ( ) It will reverse the list and it does >>> list1 = [34,66,12,89,28,99]
not create a new list. >>> list1.reverse()
>>> list1
[ 99, 28, 89, 12, 66, 34]
List.sort ( ) It will sort the list in ascending >>>list1 =
order. To sort the list in ['Tiger','Zebra','Lion',
descending order, we need to 'Cat', 'Elephant' ,'Dog']
write----- list.sort(reverse >>> list1.sort()
=True). >>> list1
['Cat', 'Dog', 'Elephant', 'Lion',
'Tiger', 'Zebra']
>>> list1 = [34,66,12,89,28,99]
>>> list1.sort(reverse = True)
>>> list1
[99,89,66,34,28,12]
List.sorted() It takes a list as parameter and >>> list1 = [23,45,11,67,85,56]
creates a >>> list2 = sorted(list1)
new list consisting of the same >>> list1
elements [23, 45, 11, 67, 85, 56]
arranged in sorted order >>> list2
[11, 23, 45, 56, 67, 85]
min() Returns minimum or smallest >>> list1 = [34,12,63,39,92,44]
element >>> min(list1)
of the list 12
max() >>> max(list1)
Returns maximum or largest 92
element of >>> sum(list1)
sum() the list 284

Returns sum of the elements of


the list
Nested Lists
When a list appears as an element of another list, it is called a nested list.
Example :
>>> list1 = [1,2,'a','c',[6,7,8],4,9]
>>> list1[4]
[6, 7, 8]

To access the element of the nested list of list1, we have to specify two indices list1[i][j].
The first index I will take us to the desired nested list and second index j will take us to
the desired element in that nested list.

Some Programs on List


# find the max value in a list
l=[]
61
n=int(input("Enter number of elements:"))
for i in range(1,n+1):
b=int(input("Enter element:"))
l.append(b)
l.sort()
print("Largest element is:",l[n-1])

Run:
Enter number of elements: 4
Enter element: 10
Enter element: 5
Enter element: 8
Enter element: 9
Largest element is: 10

# find the mean of a list


l=[]
n=int(input("Enter number of elements:"))
for i in range(1,n+1):
b=int(input("Enter element:"))
l.append(b)
avg=sum(l)/n
print("Average:",avg)

Run:
Enter number of elements: 4
Enter element: 10
Enter element: 5
Enter element: 7
Enter element: 2
Average: 6.0

* Frequency of an element in list


my_list= [101,101,101,101,201,201,201,201]
print("Original List : ",my_list )
n=int(input("enter the element which you want to count:"))
print( my_list.count(n))

Run:
Original List : [101, 101, 101, 101, 201, 201, 201, 201]
enter the element which you want to count: 201
4
Exercise Questions: List Manipulation

1 Mark Questions
Sr. Question Answer
1. Suppose a list is L=[2, 33, "KVS", 14, 25], “KVS”
what is L[-3]?
2. Find output: 2
List1=[13,18,16,16,13,18]
print(List1.index(16))
3. Given a list L=[1, 2, [“COMPUTER”, “SCIENCE”
“SCIENCE”], “IS”, “TUPLE”]
What will be the value of L[- 3][1]
62
4. What is the output when we execute [‘h’,’e’,’l’,’l’,’o’]
list(“hello”)?
2 Mark Questions
Sr. Question Answer
1. Find the output of the following Python
Code:
>>> L1=[10,20,30] [10, 20, 30, 110]
>>> L2=[110, 220, 330]
>>> L3=L1+L2
>>> L4=L3[0:4] [100, 100, 100, 100]
>>> print (L4)
>>> L4[0]=L4[0]*10
>>> L4[2]=L4[1]*5
>>> L4[1]=L4[2]
>>> L4[3]=L4[3] - 10
>>> print (L4)
2. How the pop( ) function is different from pop() function removes the last
remove( ) function working with list in value and returns the same.
python ? Explain with example. >>>l=[10,20,30,20]
>>>l.pop()
20
The remove() method removes the
first matching value from the list.
>>>l.remove(20)
3. Write a Python program to find and l=["Miao", "Tawang", "Chabua",
display those place names, in which there "Kimin", "Imphal", "Dimapur","Goa"]
are more than 5 characters. for i in l:
For example : if(len(i)>=5):
If the list l= ["Miao", "Tawang", "Chabua", print(i)
"Kimin", "Imphal", "Dimapur",”Goa”]
The following should get displayed :
Tawang
Chabua
Imphal
Dimapur
4. What is the output when following code N
is executed ?
>>>names = ['Amir', 'Bear', 'Charlton',
'Daman']
>>>print(names[-1][-1])

3 Mark Questions
Sr. Question Answer
1. Write a program that will take a number List1=[10,20,30,40,50,60]
from the key board and find its presence Num=int(input(“enter a number”))
in the list [10,20,30, 40,50,60]. It will if Num in List1:
print “Availabe” or “Not available” print(“Available”)
else:
print(“Not Available”)
2. What is the output when following code is 12
executed ?
names1 = ['Amir', 'Bear', 'Charlton',
'Daman']
names2 = names1
63
names3 = names1[:]
names2[0] = 'Alice'
names3[1] = 'Bob'
sum = 0
for ls in (names1, names2, names3):
if ls[0] == 'Alice':
sum += 1
if ls[1] == 'Bob':
sum += 10
print (sum)
3. Write a program to check if a number is lst = eval(input("Enter first list :-"))
present in the list or not. If the number is num = int(input("Enter the number
present, print the position of the number. which you want to search :-"))
if num in lst :
Print an appropriate message if the
print(lst.index( num ) )
number is not present in the list. else :
print("Number not found")
4. Crate the following lists using a for loop: a)
lst = [ ]
(a). A list consisting of the integers 0 for i in range(50):
through 49. lst = lst + [ i ]
print(lst)
(b). A list consisting the square of the b) lst = [ ]
integer 1 through 50 for i in range(51):
lst = lst + [ i**2 ]
print(lst)
5. Write a program to increment the lst = [ ]
while True :
elements of a list with a number.
num = int(input("Enter a number :"))
lst.append(num)
ch = input("for quit enter y or Y =")
if ch == "Y" or ch=='y':
print(lst)
break

4 Mark Questions
Sr. Question Answer
1. Write a Python program to input 10 L=list()
numbers to store in the list and print the for i in range (10):
third largest number. k=int(input("Enter a number :"))
For example, if the entered numbers in L.append(k)
the list are List are L.sort()
36, 25, 14, - 951, 75, - 85, 654, 88, 9521, print ("List is ", L)
657, then output will be print ("The third largest number is
The third largest number is : 654 :", L[-3])
2. Create the following lists using a for loop: (a)>>>L=list()
(a) A list containing of the integers 0 >>> for i in range (50):
through 49. L.append(i)
>>> print (L)
(b) >>>L=list()
(b) A list containing squares of the >>> for i in range (51):
integers 1 through 50. L.append(i*i)
>>> print(L)
3. Find the output of the following code:
64
>>> L=["These", "are", "a", ["few",
"words"], "that", "we", "will", "use"] [['few', 'words']]
>>> print (L[3:4]) words
>>> print (L[3:4][0][1]) r
>>> print (L[3:4][0][1][2]) False
>>> print ("few" in L) True
>>> print ("few" in L[3]) ['These', 'a', 'that', 'will']
>>> print (L[0::2]) ['that', 'we', 'will', 'use']
>>> print (L[4:]) ['These', 'are', 'a', ['few', 'words'],
>>> print (L) 'that', 'we', 'will', 'use']
4. Find and write the output of the 1
following Python code : [3, 'KVS', 4]
x= [1, 2, [3, "KVS", 4], "KV"] KV
print(x[0]) [1]
print(x[2]) True
print(x[-1]) False
print(x[0:1]) 4
print(2 in x) 7
print(x[0]==8)
print(len(x))
x.extend([12,32,4])
print(len(x))
5. The record of a student (Name, Roll No., (a)>>>sr[3] or >>>sr[-1]
Marks in five subjects and percentage of (b)>>>sr[2][4]
marks) is stored in the following list: (c)>>>max(sr[2])
sr = ['Raman','A-36',[56,98,99,72,69], (d)>>>sr[1]
78.8] (e)>>>sr[0]=”Raghav”
Write Python statements to retrieve the
following information from the list sr.
(a) Percentage of the student
(b) Marks in the fifth subject
(c) Maximum marks of the student
(d) Roll no. of the student
(e) Change the name of the student
from ‘Raman’ to ‘Raghav’

65
Tuples in Python
➢ A tuple is a standard data type of Python that can store a sequence of values
belonging to any type.
➢ Tuple is a collection of elements which is ordered and unchangeable
(Immutable). Immutable means you cannot change elements of a tuple in place.
➢ Allows duplicate members.
➢ Consists the values of any type, separated by comma.
➢ Tuples are enclosed within parentheses ( ).
➢ Cannot remove the element from a tuple.
For Example
() empty tuple
( 1, 2, 3) integers tuple
( 1, 2.5, 3.7, 7) numbers tuple
(‘a’, ’b’, ’c’ ) characters tuple
( ‘a’, 1, ‘b’, 3.5, ‘zero’) mixed values tuple
(‘one’, ’two’, ’three’, ’four’) string tuple

Creation of Tuple
a) Empty Tuple : >>>T=()
b) Single element tuple: >>>t=(10,)
#Here comma is necessary in single value tuple. Without comma it will be a value, not
a tuple.
c) Long tuple: >>>a=(5,10,15,20,25,30,35,40)
d) Nested Tuple : >>>b=(2,4,6,(8,10),12)
e) tuple() function is used to create a tuple from other sequences.

Example: From String From List


>>>s=”Hello” >>>l=[5,10,15,20]
>>>t=tuple(s) >>>p=tuple(l)
>>>t >>>p
(‘H’,’e’,’l’,’l’,’o’) (5,10,15,20)

Traversing a Tuple: A tuple can be traverses using loop. Accessing each element.
Example:
>>> a=(2,4,6,8,10) Output: 2
>>> for i in a: 4
print(i) 6
8
10

Accessing Tuples:
Elements of a tuple can be accessed in the same way as a list or string using
indexing and slicing.
T[ i ] returns the item present at index i.
>>>T=(5,10,15,20,25,30,35,40)
>>>T[0] #shows 0 index element
5
>>>T[4] #Fifth element of tuple
25

66
>>>T[-2] #Backward indexing similar to >>>T[6] element
35
>>>T[10] #returns error as index is out of range
IndexError: tuple index out of range

Tuple is Immutable: Tuple is an immutable data type. It means that the elements of a
tuple cannot be changed after it has been created. An attempt to do this would lead to an
error.

>>> t1 = (5,10,15,20,25,30)
>>> t1[2] = 100
TypeError: 'tuple' object does not support item assignment.

Operators in Tuple:
A). Concatenation (+ Operator): Python allows us to join two or more tuples using
Concatenation operator depicted by the symbol +.
Example :
>>> t1 = [1,3,5,7,9]
>>> t2 = [2,4,6,8,10]
>>>t1+t2 # + operator
(1,3,5,7,9,2,4,6,8,10)

B). Repetition/ Replication Operator (* operator): Python allows us to replicate a


tuple using repetition operator depicted by symbol *.
Example :
>>> s = (2,4,6)
>>> s * 3
(2,4,6,2,4,6,2,4,6)

C). Membership( in / not in operator) : Like strings & lists, the membership operators
in checks if the element is present in the tuple and returns True, else returns False.

>>> t1 = ('Red', 'Green', 'Blue')


>>> 'Green' in t1
True
>>> 'Cyan' in t1
False
The not in operator returns True if the element is not present in the tuple, else it
returns False.
>>> 'Cyan' not in t1
True
>>> 'Green' not in t1
False

Slicing : Like strings & lists, the slicing operation can also be applied to tuples. Tuple
elements can be accessed in subparts.
>>>Tuple_name[start:stop:step]
Examples: t=(10,20,30,40,50,60,70,80,90,100)

67
>>> t[2:6:1]
(30, 40, 50, 60)
>>> t[0:20:2]
(10, 30, 50, 70, 90)
>>> t[-8:-1:1]
(30, 40, 50, 60, 70, 80, 90)
>>> t[ : 6:1]
(10, 20, 30, 40, 50, 60)
>>> t[2 : : 2]
(30, 50, 70, 90)
>>> t[ : : -1]
(100, 90, 80, 70, 60, 50, 40, 30, 20, 10)
>>> t[1:6:-1]
()
>>> t[ : : 2]
(10, 30, 50, 70, 90)

Tuple Methods and Built-in Functions :-


Python provides some built-in functions for tuple manipulation .
>>>tuple_name.functionname()

Function/Method Description Example


Name
len(tuple) Returns number of elements in >>> t=(10,20,30,40,50,90,100)
given tuple. >>>len(t)
7
tuple() Creates an empty tuple if no >>> t1 = tuple()
argument >>> t1
is passed ()
>>> t2 = tuple('aeiou')#string
>>> t2
('a', 'e', 'i', 'o', 'u')
Creates a tuple if a sequence is >>> t3 = tuple([1,2,3]) #list
passed as argument >>> t3
(1, 2, 3)
>>> t4 = tuple(range(5))
>>> t4
(0, 1, 2, 3, 4)
count (<item>) It will count and return number of >>> t.count(10)
occurrences of the passed 1
element. >>> t.count(200)
0
index(<item>) Returns the index of the first >>> tuple1 = (10,20,30,40,50)
occurrence of the element in the >>> tuple1.index(30)
given tuple 2
>>> tuple1.index(90)
ValueError: tuple.index(x): x not
in tuple
sorted() Takes elements in the tuple and >>> t1 = (10,100,50,60,30,40)
returns a new sorted list. It should >>> sorted(t1)
68
be noted that, sorted() does not [10, 30, 40, 50, 60, 100]
make
any change to the original tuple
min() Returns minimum or smallest >>> tuple1 =
element of the tuple (19,12,56,18,9,87,34)
>>> min(tuple1)
max() Returns maximum or largest 9
element >>> max(tuple1)
sum() of the tuple 87
>>> sum(tuple1)
Returns sum of the elements of 235
the
Tuple
Nested Tuples : A tuple inside another tuple is called a nested tuple.
In given example information of a student is shown in a tuple form where address part is in
another tuple.
>>>t=(“Suresh”, 15, (115,”Jaynagar”,”Jaipur”), 75.5)

Tuple Comparison: Elements of tuples Tuple unpacking: The way


are compared and returns True/False. by which a tuple can be edited.
>>>t1=(2,3,4) >>>t=(20,40,50,80) #50 to be 60
>>>t2=(2,3,4) >>>a, b, c, d =t
>>>t3=(1,2,3) >>>print(a)
>>>t1 == t2 20
True >>>c= 60 #assigned new value
>>>t1>t2 >>>t=(a,b,c,d) #again packing
False >>>print(t)
>>>t1>t3 (20,40,60,80)
True

Delete a tuple: The del statement is used to delete elements and objects but as you
know that tuples are immutable, which also means that individual element of a tuple
cannot be deleted.
Example:
>> T=(2,4,6,8,10,12,14)
>>> del T[3]
TypeError: 'tuple' object doesn't support item deletion
But you can delete a complete tuple with del statement as:
Example:
>>> T=(2,4,6,8,10,12,14)
>>> del T
>>> T
NameError: name 'T' is not defined

Program: the maximum and minimum number from a tuple


t=(10,20,100,50,60,80,90,40)
print(max(t))
print(min(t))
output: 100
10
69
Exercise Questions: Tuple
1 Mark Questions
Sr. Question Answer
1. What will be the output of the following 4
code:
Employee=(‘rajesh’,100,23,[1,2,3])
len(Employee)
2. How tuple is different from list? The tuples are immutable sequences
while lists are mutable. The lists can
shrink or grow while tuples cannot.
3. Which of the following creates a tuple? (a)t1=(“a”,”b”)
(a)t1=("a","b") (b) t1[2]=("a","b")
(c) t1=(5)*2 (d) None of the above
4. What is the length of the tuple shown 3
below:
T = ( ( ( ( ‘a’, 1 ), ’b’ , ’c’ ), ’d’ , 2 ) , ’e’ , 3 )
5. What is the difference between (30) When we use type function then (30) is
and (30,)? type of 'int' class where (30,) is a type
of tuple which contain one element.

2 Mark Questions
Sr. Question Answer
1. Write a python program to create tuple=(6,3,1,8,4,9,2,20)
tuple of 10 integer type elements and M=max(tuple)
find the largest element in tuple. print("Largest Value in Tuple: ",M)
2. t1 = (3, 4) (3, 4, '3', '4')
t2 = ('3', '4')
print(t1 + t2)
3. t2 = (4, 5, 6) (6, 7, 4, 5, 6)
t3 = (6, 7) (4, 5, 6, 6, 7)
t4 = t3 + t2
t5 = t2 + t3
print(t4)
print(t5)
4. Discuss the utility and significance of It is a type of arrays . it play very
Tuples, briefly. important role in python . in python it
is immutable type of container which
store any kind of data types it is short
in memory size in comparison of list .
5. Does the slice operator always produce No ,it will print a part of tuple .
a new tuple ?

6. Lists and Tuples are ordered. Lists and Tuples are ordered sequences
Explain. as each element has a fixed position.

70
3 Mark Questions
Sr. Question Answer
1. Find the output of the following Python (10, 20, 30, 40, 50, 60, 70, 20, 30, 50)
Code: 70
t=(10,20,30,40,50,60,70,20,30,50) 2
>>> print (t) 15
>>> print (max(t)) 3
>>> print (t.count(20)) 20
>>> print (t[0]+5)
>>> print (t.index(40))
>>> print (min(t) + len(t))
2. Write a program that inputs two tuples tup1 = eval(input("Enter First tuple :-"))
tup2 = eval(input("Enter second tuple :-"))
and creates a third, that contains all
tup3 = tup1 + tup2
elements of the first followed by all print(tup3)
elements of the second.
3. Create a tuple names as given here: a) names [2 : 5 ]
names = ('jai', 'rahul', 'maya', 'kia', 'Dav',
(b) names [ 0 ]
'Lalit')
Write proper code for getting : (c) names [3 : ]
(a) ('maya', 'kia', 'Dav')
(b) ('jai')
(c) ('kia', 'Dav', 'Lalit')
4. TypeError occurs while statement 2 is Because tuple1 is integer not a tuple. So,
running. Give reason. How can it be we cannot find the length of integer.
If you want to make tuple then you
corrected?
should write ( 5, )
>>> tuple1 = (5) #statement 1
>>> len(tuple1) #statement 2
4 Mark Questions
Sr. Question Answer
1. What will be stored in variables a, b, c, d, ()
e, f, g, h after following statements? (80, 88, 83, 86)
perc = (88, 85, 80, 88, 83, 86) (88, 85)
(88, 85, 80, 88)
a = perc[2:2]
83
b = perc[2:] (80, 88)
c = perc[:2] ()
d = perc[:-2] (88, 85, 80, 88, 83, 86)
e = perc[-2]
f = perc[2:-2]
g = perc[-2:2]
h = perc[:]

71
2. Write a program to input n numbers tup= ()
from the user. Store these numbers in a while True :
tuple. Print the maximum and minimum n = int(input("Enter a number :- "))
number from this tuple. tup += (n,)
ch = input("To quit enter y/Y =")
if ch == "y" or ch=="Y":
print(tup)
print("Max :-",max( tup ))
print("Min :-",min( tup ))
break
3. Consider the following tuples, tuple1 I. 2
and tuple2 and find the output of the II. 3
following statements: III. (23, 1, 45, 67, 45, 9, 55, 45, 100, 200)
IV. 2
tuple1 = (23,1,45,67,45,9,55,45) V. 67
tuple2 = (100,200) VI. 1
i. print(tuple1.index(45)) VII. 300
ii. print(tuple1.count(45)) VIII. [1, 9, 23, 45, 45, 45, 55, 67]
iii. print(tuple1 + tuple2) IX. (23, 1, 45, 67, 45, 9, 55, 45)
iv. print(len(tuple2))
v. print(max(tuple1))
vi print(min(tuple1))
vii. print(sum(tuple2))
viii. print( sorted ( tuple1 ) )
ix.print(tuple1)
4. Write a program to input names of n def find( name):
students and store them in a tuple. Also, if name in tup :
input a name from the user and find if return name, "is present in ",tup
else :
this student is present in the tuple or not.
return name, "is not present in
",tup
We can accomplish these by:
(a) Writing a user defined function tup = eval( input ("Enter a tuple
(b) Using the built-in function containing name of student :-"))
nam = input("Enter name of student :-")
print( find( nam ) )

72
Dictionary
Dictionaries are used to store data values in key: value pairs. It is a collection which is
ordered*, changeable and do not allow duplicates. Dictionaries are written with curly
brackets, and have keys and value.

Creating the dictionary: -The dictionary can be created by using multiple key-
value pairs enclosed with the curly brackets {}, and each key is separated from its value by
the colon (:)

For example:
# Creating an empty Dictionary
student = { }
print("Empty Dictionary: ")
print(student)
# Creating a Dictionary with dict() method
student = dict({1: 'Mahesh', 2: 'Sunil', 3:'Vikash'})
print(Dict)

Accessing items in a dictionary using keys: -


The elements o f dictionaries are accessed through the keys defined in the key: value
pairs

Syntax:-<dictionary-name>[<key>]
Student ={'Name': 'Manish', 'Age': 15, 'Class': 11,
'Totalmarks':400} student['Name']
Output:- Manish

Accessing Keys or Values:


Student ={'Name': 'Manish', 'Age': 15, 'Class': 11,
'Totalmarks':400} print(Student.keys())
print(Student.values())

Adding and updating dictionary elements


#To update an Item in a Dictionary

Student ={'Name': 'Manish', 'Age': 15, 'Class': 11,


'Totalmarks':400}
Student['age'] = 16
print(Student)
#To add an Item in a Dictionary
Student['Totalmarks'] = '500'
print(Student)
Output:-
73
{'Name': 'Manish', 'age': 16, ‘Class’:11,’Totalmarks’:400}
{'Name': 'Manish', 'age': 16, ‘Class’:11,’Totalmarks’:500}
get() method:-
car = {"brand": "Ford","model": "Mustang","year": 1964}
x = car.get("model")
print(x)
Output: Mustang
Traversing a dictionary: - Traversal means accessing individual element
one by one: Student ={'Name': 'Manish', 'age': 16, ‘Class’:11,’Totalmarks’:400}
for k, v
in
Stud
ent.
Item
s( ):
print
(k, '-
---',
v)
Output: -
Name ---- -Manish
Age - ----16
Class----11
Totalmarks----400
Built-in functions in Dictionary

SN Function Function Details and working


1. len( ) Returns the length of the Dictionary(key-value pair will be count as 1
)
Len(Mydict)
2. dict( ) Creates Dictionary
X=dict(name=”sunil”,age=30,country=”India”
3. keys( ) Returns all available keys
x.keys()
output: dict.keys([‘name’,’age’,’country’])
4. values() Returns all the available values.
x.values( )
output: dict_values([‘sunil’,30,’India’])
5. get( ) The get() method returns the value of the item with the specified key
Mydict ={'Name': 'Raj', 'Age': 15, 'Class': 12,'Totalmarks':450}
print(Mydict.get('Class'))
print(Mydict['Name'])
6. update():- updates the dictionary with the elements from another dictionary
objector from an iterable of key/value pairs
mydict = {'Africa':200,'australia':300,'England':400}
mydict.update({'China':500})
7. del() The del keyword can be used to in-place delete the key that is
present inthe dictionary in Python.
test_dict = {"Arushi": 22, "Mani": 21, "Haritha": 21}
74
removes Mani
del test_dict['Mani']
8. pop() method removes the specified item from the dictionary and return
thecorresponding value.
Mydict = {'Name': 'Raj', 'Age': 15, 'Class': 12, 'Totalmarks':450}
Mydict.pop('Name')
9. popitem():- The popitem() method removes the item that was last inserted into
thedictionary.
Mydict = {'Name': 'Raj', 'Age': 15, 'Class': 12, 'Totalmarks':450}
K= Mydict.popitem()
print("Last item of dictionary = ", K)
10. fromkeys() The dict.fromkeys() method creates a new dictionary from the
given iterable (string, list, set, tuple) as keys and with the specified
value.
keys = ('Mumbai','Bangalore','Chicago','New York')
value = 'city'
dictionary = dict.fromkeys(keys, value)
11. copy( ) copy() method returns a copy (shallow copy) of the original
dictionary
original={'Name': 'Raj', 'Age': 15, 'Class': 12, 'Totalmarks':450}
new = original.copy()
print('Orignal: ', original)
print(‘New:’,new)
12. setdefault( ) The setdefault() method returns the value of a key (if the key is in
dictionary). If not, it inserts key with a value to the dictionary.
romanNums = {'I':1, 'II':2, 'III':3, 'IV':4, 'V':5 }
value = romanNums.setdefault('I')
print("The return value is: ", value)
value = romanNums.setdefault('VI')
print("The return value is: ",value)
print("Updated dictionary: ",romanNums)
13. max( ) & Used to find maximum and minimum respectively fromthe
min( ) dictionary.
my_dict = {'x':500, 'y':5874, 'z': 560}
key_max = max(my_dict.keys(),
key=(lambda k: my_dict[k]))
key_min = min(my_dict.keys(),
key=(lambda k: my_dict[k]))
print('Maximum Value: ',my_dict[key_max])
print('Minimum Value: ',my_dict[key_min])
14. clear() removes all items from the dictionary.
Mydict ={'Name': 'Raj', 'Age': 15, 'Class': 12, 'Totalmarks':450}
Mydict.clear()
print(Mydict)
15. sorted( ) The sorted() function returns a sorted list of the specified iterable
object
dict = {6:'George' ,2:'John' ,1:'Potter' ,9:'Micheal' ,7:'Robert' ,8:'Gayle' }
b = sorted(dict.keys())
print("Sorted keys",b)
c = sorted(dict.items())
print("Sorted Values",c)
75
Programs on Dictionary:
1. Count the number of times, a character appears in a given string
using a dictionary :

#initializing string
test_str = "AMARDEEP"
# using dict.get() to get count# of each element in string
res = {}
for keys in
test_str:
res[keys] = res.get(keys, 0) + 1
# printing result
print ("Count of all characters in GeeksforGeeksis : \n" , res)

2. Create a dictionary with names of employees, salary and


access them.

Mydict = { }
while True :
name = input("Enter employee name :-")
sl = int(input("Enter employee salary :-"))
Mydict[ name] = sl
user = input("Do you want to quit then enter yes :-")
if user == "yes" :
break;
print(Mydict)
Short Answers type questions[1 mark]

Q1. Keys of dictionary must be


(a) antique (b)unique (c) mutable (d) integers
Q2. We can repeat the values of Key in Dictionary?
a. True
b. False
Q3. Key – value concept is in
(a) List (b)String (c)Dictionary (d)Tuple
Q4. What type of error is returned by the following code :
a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"}
print(a[1])
Q5. Write the two ways to construct an empty
dictionary.

76
Q6. Write the output of following code:
sales = {'Audi':45, 'BMW':32,
'Ferrari':12}
for x in sales:
print(x)

Q7. Suppose a dictionary days is


declared as:
days={1:"Sun", 2:"Mon",
3:"Wed"}
Write a statement in Python to change Wed to Tue.
Q.8. is used to remove all items form a particular dictionary.
Q.9. What will be
the output:-
d1=
{‘rohit’:56,”
Raina”:99}
print(“Raina” in
d1)
Q10. Which of the following function create a dictionary from sequence of key -
valuePairs.
(a) dictionary( ) (b) dict( ) (c) create( ) (d) convert( )

Short Answer Type Questions [2 marks]


Q1. Parth wants to display the value corresponding to the key “3” in dictionary given
below. As a friend of Parth, help him to find the correct code.
D={1: ‘Amit’, 2: ‘Suman’, 3: ‘Ravi’, 4: ‘Anuj’}
(a) print(D.get(3)) (b) print(D[3]) (c) Both of the above (d) None of the above
Q2. Write Python code to convert following two list into one
dictionary :-
keys = ['Ten', 'Twenty', 'Thirty']
values = [10, 20, 30]
Q3. Print the value of key ‘physics’ from the following dictionary
MyDict = {"class": {"student": {"name": "Mike","marks": {"physics": 70,"history": 80}}}}
Q4. Get the key of a minimum value from the following dictionary

My_dict = {'Physics': 82,'Math': 65,'CS': 75}

77
Q5. Find the output of the following python code:-
a = {}
a[1] = 1
a['1'] = 2
a[1]= a[1]+1
count = 0for i in a:
count += a[i]
print("count=", count)
Q6. What is the output of the
following of code?
a = {i: i*i*i for i in
range(6)}
print (a)
Q7. What will be output of following python program :-
dict = {(3,4,8):4,(5,6,9):3}
print(dict)
print('output:',dict[5,6,])
Q8. Find the output of the following
code:-
dictlang = {'c#': 6, 'GO': 89, 'Python':
4,'Rust':10}cpydict = dictlang.copy()
print(cpydict)
Q9. Find the output of the following code:-
fruitsDict = {'Apple': 100,'Orange': 200,'Banana': 400, 'pomegranate':600 }
if 'Apple' in fruitsDict:
del fruitsDict['Apple']
print('Dict after deleting key =',fruitsDict)
Q10. Create a dictionary ‘ODD’ of odd numbers between1 and 10, where the key is the
decimal number and the value is the corresponding number in words.

Long Answer Type Question[3 & 4 mark Questions]


1) Answer the following question on the given
dictionary Employee= {'Name': 'Aman', 'Salary':
10000, 'Gender': 'Male'}
(i) Add a new key(‘City) with value “Jaipur” in Employee dictionary
(ii) Display all the keys of the Employee dictionary
(iii) Write code to delete all the items of the Employee dictionary
2) What are the differences between dictionary and list?
3) Consider the following dictionary capitals

capitals ={ "Maharashtra": "mumbai","Delhi" : "New Delhi","Uttar pradesh":"Lucknow"}


78
Find the output of the following statements:-
(i) print(capitals.get("Lucknow"))
(ii) print(capitals.keys())
(iii) print("Delhi" in capitals)
4) Write a program to convert a number entered by the user into its
corresponding number in words. for example if the input is 876 then the
output should be ‘Eight Seven Six’.
5) Python Program to Multiply All the Items in a Dictionary.
6) Write a Python program to print all unique values in a dictionary.
Sample Data : [{"V":"S001"}, {"V": "S002"}, {"VI": "S001"}, {"VI": "S005"},
{"VII":"S005"}, {"V":"S009"},{"VIII":"S007"}]
Expected Output : Unique Values: {'S005', 'S002', 'S007', 'S001', 'S009'}
7) Write a program to create a dictionary namely Mydict with 10 keys 0 to 9,
each having value as 20. Update the first and last values by adding 100 to
each of them.
8) Write a python function to print sum of all items in a dictionary.

Case Based Questions

1. Mohan is student who is learning python programming. Mohan is unable to find out
the output of the following python program. Help the Mohan by finding outputof the
following :-
Mydict= {'A':10,'B':20,'a':30, 'D':40}
Val_A= ''
for i in Mydict:
if (i>Val_A):
Val_A= i
Val_B= Mydict[i]
print(Val_A) # Line1
print(Val_B) # Line2
print(20 in Mydict) # Line3
print('D' in Mydict)
Mylist.sort() # Line5
print(Mylist[-1]) # Line6

(i) What output does Line1 produce ?


(ii) What output does Line2 produce ?
(iii) (iii)What output does Line3 produce ?
(iv) (iv)What output does Line4 produce ?
79
(v) What is the return value form the list sort() function (line5)
(vi) What output does Line6 produce ?
2. Mr. Rajesh Kumar is a teacher in a school. He is doing his work manually .
As a python learner solve the problems of Rajesh Kumar by python
programs:-
(i) Create a dictionary student which ask Student roll number, Name
and Marksof students and display them in tabular format.
(ii) Display the names of those students who have secured marks more
than 75.
(iii) Delete those students who have secured less than 50 marks

ANSWER KEY

Short Answer Type Questions [1 Marks]


1. B
2. A
3. C
4. KEY ERROR
5. (i) Use of
{} symbol
dict()function
6. Audi
BMW
Ferrari
7. Days[3]=”Tue”
8. clear()
9. A
10. True
Short Answer Type Questions [2 Marks]
1. D
2. keys = ['Ten', 'Twenty', 'Thirty']values = [10, 20, 30]
res_dict = dict(zip(keys, values))
print(res_dict)
3. print(MyDict['class']['student']['marks']['physics'])
4. print(min(My_dict, key=My_dict.get))
5. count= 4
6. {0: 0, 1: 1, 2: 8, 3: 27, 4: 64, 5: 125}
7. {(3, 4, 8): 4, (5, 6, 9): 3}
output: 3
8. {'c#': 6, 'GO': 89, 'Python': 4, 'Rust': 10}
9. Dict after deleting key = {'Orange': 200, 'Banana': 400,'pomegranate': 600}
10. ODD = {1:'One',3:'Three',5:'Five',7:'Seven',9:'Nine'}
print(ODD)

80
Long Answer type questions
(i) Employee['City']= "Jaipur"
1. print(Employee)
(ii) Employee.keys()
(iii) Employee.clear()
2. 1. List is an ordered set of elements. But, a dictionary is a data structure that is used
for matching one element (Key) with another (Value).
2. The index values can be used to access a particular element. But, in dictionary key
represents index. Remember that, key may be a number of a string. 3. Lists are used to
look up a value whereas a dictionary is used to take one value and look up
another value.
3. (i) None
(ii) dict_keys(['Maharashtra', 'Delhi', 'Uttar pradesh', 'Tamil Nadu '
(iii) True
4. num = input("Enter any number: ") #number is stored as string#numberNames is a
dictionary of digits and corresponding number#names
numberNames = {0:'Zero',1:'One',2:'Two',3:'Three',4:'Four',\
5:'Five',6:'Six',7:'Seven',8:'Eight',9:'Nine'}
result = ''
for ch in num:
key = int(ch) #converts character to integerrvalue =
numberNames[key]
result = result + ' ' + value print("The number is:",num)
print("The numberNameis:",result)
5. My_dict = {'A':10, 'B':20, 'C':30}
Multiply= 1
for i in My_dict:
Multiply= Multiply*My_dict[i]print(Multiply)
6. L = [{"V":"S001"}, {"V": "S002"}, {"VI": "S001"}, {"VI":"S005"}, {"VII":"S005"},
{"V":"S009"},{"VIII":"S007"}]
print("Original List: ",L)
u_value = set( val for dic in L for val in dic.values())
print("Unique Values: ",u_value)
7. Mydict= dict.fromkeys(range(10), 20)
Mydict[0]+=20
Mydict[9]+= 20
print(Mydict)
8. # Function to print sum def
ReturnSum(myDict):
list = []
for i in myDict:
list.append(myDict[i])
final = sum(list)

81
return final
dict = {'a': 100, 'b': 200, 'c': 300}
print("Sum :", ReturnSum(dict))
9. def CountFrequency(my_list): # Function definition#
#Creating an empty dictionary
freq = {}
for item in my_list:
if (item in freq):
freq[item] += 1
else:
freq[item] = 1
for key, value in freq.items():
print ("% d : % d"%(key, value))

my_list=[1, 1, 1, 5, 5, 3, 1, 3, 3, 1, 4, 4, 4, 2, 2, 2, 2]
CountFrequency(my_list) # Function calling
10. D1= { }
i=1
Num= int (input("Enter number of entries: "))
while (i<=Num):
a= input("Enter name: ")
b= input("Enter age:")
D1[a]=b
i= i+1
L= D1.keys()
for i in L:
print(i, '\t', D1[i])
Case Based Question
1. (i) A
(ii) 30
(iii) False
(iv) True
(v) None
(vi) ('a', 30)
2. (i) n=int(input("How many student data you want to enter ..."))
Student={}
for i in range(n):
roll_no=int(input("Enter roll no: "))
name=input("Enter name: ")
marks=int(input("Enter marks: "))
Student[roll_no]=[name,marks]
print("{:<10} {:<10} {:<10}".format('Rollno','Name','Marks'))
for k, v in d.items():
name, num = k, v
print(name, marks))
(ii)
n=int(input("Enter n: "))
82
d={}
for i in range(n):
roll_no=int(input("Enter roll no: "))
name=input("Enter name: ")
marks=int(input("Enter marks: "))
d[roll_no]=[name,marks]
for k in d:
if(d[k][1]>75):
print(d[k][0])
(iii)
n=int(input("How many student data you want to enter ..."))
Student={}
for i in range(n):
roll_no=int(input("Enter roll no: "))
name=input("Enter name: ")
marks=int(input("Enter marks: "))
Student[roll_no]=[name,marks]
for k, v in list(Student.items()):
if v[1] < 50:
del Student[k]
print("Remaining students: ", Student)

83
Introduction to Python Module

A python program consists of three main Component:


1. Library or package
2. Module
3. Function/Sub Modules

RELATIONSHIP BETWEEN A MODULE, PACKAGE AND LIBRARY IN PYTHON

● A module is a file containing python definitions, variables and classes and


statementwith .py extension
● A Python package is simply a directory of python modules.
● A library in python is collection of various packages. Conceptually there is
nodifference between package and python Library.

Advantages of Python Modules

● Putting code into modules is useful because of the ability to


import the modulefunctionality.
● Reusability: A module can be used in some other python code.
Hence it providesfacility of code reusability
● A module allows us to logically organize our python code.
● Grouping related code into a module makes the code easier to
understand and use.
● Categorization: Similar types of attributes can be placed in a single
module.

Creation of Module:

The following point must be noted before creating a module.

1. A module name should always end with .py extension


2. We will not able to import module if it does not end with .py
3. A module name must not be a Python keyword

A module is simply a python file which contains functions, classes and


variables.
Let us consider the following example of a module name area.py
which contains three functions name area_circle(r), area_square(s),
area_rect(l,b)

import math
def area_circle(r):
return math.pi*r*r
def
area_s
quare
(s):
r
etur
n
s*s
84
def area_rect(l,b):
return l*b
importing Modules: There are two ways to import a module(s) :
1) Using import statement: we can import single as well as multiple modules
i. For importing Single Module
Syntax: import module name
ii. For importing Multiple modules
Syntax: import modulename1, modulename2,

modulename3

To Use function inside module

Syntax modulename.function name

2) Using from Statement: -To import some particular Function(s) from module
we will useimport statement

2.1 To import Particular Function

Syntax: From <module name> import <write name of

Function(s)>OR

From <module name> import *

(This statement will import all the functions from modules)

To use a function inside a module you have to directly call function if you are
importing themodules using from statement.
Example : Let us consider the following code. In this program we import the
module with the help of from statement and directly use the function instead of
specifying Module name.

from
area.py
import
area_rect
area_rect
(5,4)

Importing math module:-In order to use the various constants of


mathematics andoperations, we have to import math module in our program.
Example : import math

Commonly-used constants and functions in math module.

pi: - It is a mathematical constant, the ratio of the circumference of a circle to its


diameter(3.14159...)

For example
>>> print ("The value of pi is :", math.pi)
The value of pi is: 3.141592653589793
85
e: - It is a mathematical constant that returns e raised to the power x, where
e=2.718281.It is the base of natural logarithms. It is also called Euler's number.

For example :
>>>print("The value of e is :", math.e)
The value of e is :2.718281828459045
ceil(x): - Returns the smallest integer that is greater than or
equal to x.For example :
>>>print("ans :",math.ceil(7.3))
Output: ans :8
floor(x): - Returns the largest integer that is less than or equal to x.
>>>math.floor(-45.17)
-46
>>>math.floor (100.12)
100
pow(x,y): - It returns the value of xy, where x and y are numeric expressions.
>>> print ("ans :",
math.pow (3, 3))
Ans :27.0
>>>math.pow (2, 4)
16.0
>>>math.pow (5, 0)
1.0
sqrt(x): - Returns the square root of x.
>>> print ("Squre root of 65=:", math.sqrt (65))

Squre root of 65=:8.06225774829855


>>>math.sqrt (36)
6.0
fabs(x): - Returns the absolute value of x, represented as –
math.fabs (x)
where, x can be any numeric value.For example,
>>> print (math.fabs (500.23))
500.23
>>> print (math.fabs (-200))
200
cos(x): - Returns the cosine of x in radians.
>>>math.cos(3)
-0.9899924966004454
86
sin(x): - Returns the sine of x in radians.
>>>math.sin (3)
0.14112000806
tan(x): - Returns the tangent of x in radians.
>>>math.tan (3)
-0.1425465430742778

Random Module: - This module contains functions that are used for
generating random numbers. import statement is the first statement to be given in
a program for generating random numbers:

import random

The various functions associated with this module are as follows: -

(1) random():- It is floating point random number generator between 0.0 to


1.0. Here lower limit is inclusive where as upper limit is less than 1.0. i.e.
0<=N<1 where N is generated random number.

Example: -

>>>import random
>>>n=random.random()
>>>print(n)

0.1738135764235368

(2) randrange():- This method generates an integer between its lower and
upperargument. By default, the lower argument is 0.

Example :-
>>> import random
>>>Number=random.randrange (30)
>>>print(Number)
15

Note: - This line of code shall generate any one random integer number from
0 to 29excluding upper argument.

(3) randint () : - This method generates random integer number. Both the
given rangevalues are inclusive.

Example :-
>>> import random
>>>Number=random.randint (100,500)
>>>print(Number)
151

87
Statistical Module: - This module provides functions for calculating
mathematical staticsof numeric (real valued) data. There are 3 basic functions
under this module.

1. mean()
2. median()
3. mode()

In order to use these functions, we have to import statistics module in our code.

1. mean(): - It calculate the average of all


given numbers.Example: -
>>> import statistics
>>>L=[1,2,3,4,5,6]
>>>print(statistics.mean(L))
3.5 [Note: - 3.5 is the average of all numbers in the list]

median(): - The median is the middle number in a group of numbers. If


group has odd numbers of element then it will return the middle position
value, otherwise will return theaverage of values at mid and mid-1 position.

Example: -
>>> import statistics
>>>L=[10,20,30,40,50,60,70]
>>>print(statistics.median(L))
40

2. mode(): - The mode function returns number that occurs most often within a
set of numbers.

Example:-
>>> import statistics
>>>L=[10,5,30,5,5,60,70]
>>>print(statistics.mode(L))
5

(1 MARK QUESTIONS)

Q1. Which of these definitions correctly describe a module?


a) Denoted by triple quotes for providing the specifications of certain program
elements.
b) Design and implementation of specific functionality to be incorporated into a
program
c) Defines the specifications of how it is to be used.
d) Any program that reuses code.

88
Q2. If a,b,c=3,4,1 then what will be the value of

math.sqrt(b)*a-c

a) 5.0
b) 5
c) 2
d) 4.0
Q3. What is displayed on executing
print(math. fabs(-3.4))?
a) -3.4 b) 3.4 c) 3
d) -3
Q4. What is the file extension of python module file?
Q5. Which of the following is not an advantage of
using modules?
a) Provides a means of reuse of program code
b) Provides a means of dividing up tasks
c)Provides a means of reducing the size of the
program
d) Provides a means of testing individual parts of
the program

Q6. Which operator is used in the python to import all modules from packages?
(a) . operator (b) * operator
(c) ‐> symbol (d) , operator

Q7. In python which is the correct method to load a module math?


(a) include math (b) import math
(c) #include<math.h> (d) using math
Q8. Which is the correct command to load just the tempc method from a module
calledusable?
(a) import usable, tempc (b) Import tempc from usable
(c) from usable import tempc (d) import tempc
Q9. Which of the following can not be returned by random.randrange(4)
a) 0
b) 3
c) 2.3
d) None of the mentioned
Q10. What does random.seed(3) return?
a) True
b) None
89
c) 3
d) 1
(2 MARKS QUESTIONS)
Q1. Write two forms of import statement.
Q2. Write a python program to calculate the square root of given number n.
Q3. What is the utility of Python standard library's math module and random
module?

Q4. Define 'module' and 'package'.


Q5. Which of the following is the same as math.exp(p)? Also give the explanation.
a) e ** p b) math.e ** p
c) p ** e d) p ** math.e
Q6. List any two advantages of modules?
Q7. How is math.ceil (89.7) different from math.floor (89.7)?
(3 MARKS QUESTIONS)

Q1. Select the possible output(s) of the following code from the given option. Also,
specify the maximum and minimum value that can be assigned to variable NUM.
import random
cities = [‘Agra’, ‘Delhi’, ‘Chennai’, ‘Bhopal’]
NUM = random.randint(1,2)+1 for city in cities:
for I in range(1,NUM):
pint(city, end=‘’)print(‘\n’)
a) Agra C) Agra
DelhiDelhi Delhi
ChennaiChennaiChennai Chennai
BhopalBhopalBhopalBhopal Bhopal
b) Agra d) ChennaiChennai
Agra BhopalBhopal
DelhiDelhi

Q2.What is the utility of Python standard library's math module, random module and
statistics module?
Q3. Consider the following code:
import math import random
print(str(int(math.pow( random.randint (2,4),2) )), end = ‘ ’)
print(str( int ( math.pow(random.randint(2,4), 2))) , end = ‘ ’)
print( str ( int (math.pow( random .randint (2,4),2))))
What would be possible outputs out of the
given six choices?
(i) 2 3 4
(ii) 9 4 4
(iii) 16 16 16
(iv) 2 4 9
(v) 4 9 4
(vi) 4 4 4
90
Case Study Based Questions
1. Write a python program that takes a number from 1 to 9 and stored inside
the variable “guess_num”. If the user guesses wrong then the prompt
appears again and the user continues to input another number repetitively
until the guess is correct. On successful guess, the user will get a “Well
guessed!” message, and the program will exit.Write a program to perform
insertion sorting on a given list of strings, on the basis of length of strings.
That is, the smallest length string should be the first string in the listand the
largest length string should be the last string in the sorted list.
Answers (1 Mark Questions)
A1 :-b) Design and implementation of specific functionality to be incorporated
into aprogram
A2. :- a) 5.0
A3. :- b) 3.4
A4. The file extension of python module file is .py
A5. Answer: c
A6. * operator.
A7. import math
A8. C) from usable import tempc
A9. C) 2.3
A10. b) None
Answers (2 Marks Questions)

A1. There are two forms of import statements:

1. import <modulename>
2. from <module> import <function>

A2.

import math
n=float(input('Enter n='))
ans=math.sqrt(n)
print('Square root of',n,' = ',ans)
A3.
(i) The math module is used for math related functions that work with all
numberexcept complex numbers.
(ii) The Random module is used for different random number generator
functions.
A4.
Each python program file is a module which imports other modules like
objects and attributes. A python program folder is a package of modules. A
package can have modulesor sub folders.
A5.

Answer: b

EXPLANATION: math.e is the constant defined in the math module.


91
A6. Advantages of modules are:-
1. Reusability : Working with modules makes the code reusable.
2. Simplicity: Module focuses on a small proportion of the problem,
rather than focusing onthe entire problem.

A7.
Ceil: The function 'ceil(x)' in Python returns the smallest integer not less than
x i.e., the next integer on the RHS of the number line. Hence, 'math. ceil(89.7)'
will return 90whereas 'math. floor(89.7)' will return 89.
Answers (3 Marks Questions)

A1. Options b and c are correct. Maximum and Minimum value assigned to NUM
are 3 and2 respectively.
A2.
(i) Math module: The math module is used for math-related
functions that workwith all number types except for complex
numbers.
(ii) Random module: The random module is used for different
random numbergenerator functions.
(iii) Statistics module:- The statistics module is used statistic-related
functions likemean, mode, median etc.
A3. Options ii, iii, v and vi are possible outputs
Answers (Case Study based Questions)
A1.
import random

target_num, guess_num =

random.randint(1, 10), 0while

target_num != guess_num:

guess_num = int(input("Guess a number between 1 and 10 \ until you get it

right:"))print(target_num)

target_num = random.randint(1, 10)

print('Congratulation both target and guess numbers are

same',target_num,guess_num)

print('Well guessed!')

92
Society, Law and Ethics-1

Digital Footprint –
A digital footprint is data that is left behind when users have been online. There
are two types of digital footprints which are active and passive.

An active digital footprint is where the user has deliberately shared information
about themselves either by using social media sites or by using websites.
A passive digital footprint is made when information is collected from the user
without the person knowing this is happening.
Examples of active Digital Footprints
• Posting on Instagram, Facebook, Instagram, Twitter, and other social media
platforms
• Filling out online forms, i.e. when signing up to receive emails or texts
• Agreeing to install cookies on our devices when prompted by the browser
Examples of passive Digital Footprints
• Websites that install cookies in our device without disclosing it to us
• Apps and websites that use geolocation to pinpoint our location
• Social media news channels and advertisers that use our likes, shares, and
comments to profile us and to serve up advertisements based on our
interests

How digital footprint is being used for marketing purposes


Digital footprints are also known as cyber shadow, electronic footprint, or digital
shadow are generally collected with the help of tracking cookies. these cookies
are created while using popular sites. Whatever we search is stored in these
along with our dates, GPS relevant data. These are shared by actual site we are
visiting to the popular sites.
Popular sites in turn analyze these data and revert back in the form of advertise later
on.
we should care about managing our digital footprint by following ways:
1. To protect our reputation
2. To make safe personal information
3. To prevent financial loss
4. To preserve our freedom
Risk due to digital footprint
• Privacy concern
• Scam
• Identity theft

How to manage digital footprints


• Enter name into several search engines
• Double-check privacy settings, but don't trust them
• Create strong, memorable passwords
• Keep all our software up to date.
• Review our mobile use. Delete useless files (temp.)
• Build reputation through behavior.

Net or communication etiquettes


Netiquette is short for "Internet etiquette” or communication etiquettes over
internet. It is Just like etiquette - a code of polite behavior in society, netiquette
is a code of good behavior on the Internet. It includes several aspects of the
93
Internet, social media, email, online chat, web forums, website comments,
multiplayer gaming, and other types of online communication.

Social Media Etiquettes


• Avoid over-automation.
• Be authentic and genuine.
• Don’t be overly promotional.
• Handle your hashtags carefully.
• Don’t bad-mouth your competition

Data protection – It refers to the practices, safeguards, and binding rules put
in place to protect our personal information and ensure that it remain in control.
In short, we should be able to decide whether or not we want to share some
information, who has access to it, for how long, for what reason, and be able to
modify some of this information, and more.
Consequences of Unprotected Data/Data breaches
• Suffer from security breach/attack
• Physical data loss
• Hit with a virus
• Targeted by hackers
• Suffer from DDoS(Distributed denial of service)
• Lose of money
• Intellectual property at risk
• Damage downtime

How we can protect our personal data online


• Through Encrypt our Data
• Keep Passwords Private
• Don't overshare on Social Networking Sites
• Use Security Software
• Avoid Phishing Emails
• Be Wise About Wi-Fi
• Be Alert to Impersonators
• Safely Dispose of Personal Information

Intellectual Property (IP) – This is a property created by a person or group


of persons using their own intellect for ultimate use in commerce and which is
already not available in the public domain.
Examples of IP Property which are, an invention relating to a product or any
process, a new design, a literary or artistic work and a trademark (a word, a
symbol and / or a logo etc.)
Intellectual Property Right (IPR) is the statutory right granted by the
Government, to the owner(s) of the intellectual property or applicant(s) of
an intellectual property (IP) to exclude others from exploiting the IP
commercially for a given period of time, in lieu of the discloser of his/her IP
in an IPR application.

Kinds of IPRs
• Patent (to protect technologies - The Patent Act)
• Trade Mark (to protect words, signs, logos, labels –The Trade Mark Act)
• Design (to protect outer ornamental configuration –The Designs Act)
• Geographical Indications (GI) (to protect region specific product –The
Geographical Indications of Goods Act)
• Copyright (to protect literary and artistic work –The Copyright Act)
94
Plagiarism is “the act of presenting the words, ideas, images, sounds, or the
creative expression of others as it is your creation or your own.” The word
plagiarism is derived from the Latin word plagiare, which means to kidnap or
abduct.

Why is it important to understand Plagiarism?

• Plagiarism is stealing of intellectual property


• Plagiarism is cheating
• Plagiarism is an Academic offence
• Plagiarism is Academic theft!

How to avoid plagiarism


1: Use your own ideas
2: Cite the sources-When someone else's ideas are used, always acknowledge the
sources and tell your reader WHERE THE IDEAS ARE FROM.
3: Rewrite other's ideas in your own words
4: Take careful notes
5: Develop your writing skills

Licensing and Copyright


A software license is a document that provides legally binding guidelines to the
person who holds it for the use and distribution of software.
Difference between Licensing and Copyright
Copyright is a type of intellectual property protection and licensing is a kind of
risk control measure that can be applied to control copyright loss exposure, so
the licensor (copyright owner) can grant permission that usually takes the form
of a licensing agreement to use its copyrighted material. This agreement
specifies the exact material to be used, purposes the work could be used for and
the duration of the license.
Free and Open-Source software (FOSS)
FOSS is a kind of software that all allows users to not only freely run the program
for any purpose, but also provides users access to its source code. Moreover, it also
allows us to modify as we wish, as well as freely distribute copies of the original
version or their altered version.
Following criteria must be met for FOSS
• Source code must be included.
• Anyone must be allowed to modify the source code.
• Modified versions can be redistributed.
• The license must not require the exclusion of other

Types of Software based on use:


Free Software – Free Software are those which are freely accessible, freely
accessible, freely used, changed, improved, copied and distributed. It provides
all types of freedom. The term ‘Free’ means ‘Freedom’ at very little or No cost.
The Source Code is also available with Free Software.
Open-Source Software: Open-Source Software can be freely used, changed,
improved, copied and Re-distributed but it may have some cost for the media
and support for further development. Source Code is also available with OSS. It
can be modified and redistributed with some guidelines. The License may
restrict source-code from being distributed and modification to maintain the
Author’s integrity. A software which is FREE as well as OPEN, called Free &
95
Open Source Software (FOSS) or Free Libre & Open Source Software (FLOSS).

Types of Software based on use:


• Proprietary Software: These Software are neither open nor freely
available. They must have some cost and Source code is also not given since it is
property of the developer organization. No change, copy and distribution are
allowed.
• Freeware: These are available free of cost. They can be used, copied,
distributed but no modification is allowed because Source Code is not available.
• Shareware: These software are freely used, copied and distributed for a
certain period of time. After expiry, you have to purchase or uninstall them.
Modification is not possible due to non-availability of the source code. These are
the Demo version and freely distributed for trial

Cyber Crime
Any crime that involves a computer and a network is called a “Computer Crime”
or “Cyber Crime or in other term, it is a crime in which a computer is the object
of the crime (hacking, phishing, spamming) or is used as a tool to commit an
offense (child pornography, hate crimes).

STEPS TO PROTECT YOURSELF AGAINST CYBER CRIME


1. Make sure your security software is current – and update it regularly.
2. Lock or log off your computer when you step away.
3. Go offline when you don’t need an internet connection.
4. Consider sharing less online.
5. Think twice about using public Wi-Fi.
6. When in doubt, don’t click.

Hacking
Hacking is the process of gaining unauthorized access into a computing device,
or group of computer systems. This is done through cracking of passwords and
codes which gives access to the systems.
Difference between hacker and cracker is that a cracker breaks the security of
computer systems, and a hacker is a person who likes to explore computer
systems and master them.

Types of Hackers

Black hat hackers or crackers are individuals with extraordinary computing


skills, resorting to malicious / destructive activities. Black hat hackers use their
knowledge and skill for their own personal gains probably by hurting others.
White hat hackers are those individuals who use their hacking skills for
defensive purposes. This means that the white hat hackers use their knowledge
and skill for the good of others and for the common good. Ethical hacking also
known as penetration testing or white-hat hacking, involves the same tools,
tricks, and techniques that hackers use, but with one major difference that
Ethical hacking is legal.
Grey-Hat Hackers These are individuals who work both offensively and
defensively at different times. Their behavior can’t be predicted. Sometimes
they use their skills for the common good.

Eavesdropping
It is the unauthorized real-time interception of a communication, such as a phone

96
call, instant message, video conference or fax transmission.

Phishing is a cyber-attack that uses disguised email as a weapon. The attackers


masquerade as a trusted entity of some kind, The goal is to trick the email
recipient into believing that the message is something they want or need —
recipient fills/send sensitive information like account no, username, password
etc. ,then attacker use these.
Ransomware is a type of malware that prevents users from accessing their system or
personal files and demands ransom payment.

Preventing cyber crime


• Use strong password
• Secure your computer
• Protect your data
• Secure your mobile devices
• Secure wireless network

Introduction-Cyber Safety
Cyber safety is the safe and responsible use of Internet & ICT (Information &
Communication Technology). Cyber safety is about to not only keeping
information safe and secure, but also being responsible with that information,
being respectful of other people online. As per Cyber safety people are advised
to use good 'netiquette'.

Cyberbullying is the use of technology to harass, threaten or humiliate a target.


Examples of cyberbullying is sending mean texts, posting false information
about a person online, or sharing embarrassing photos or videos.

Different Types of Cyber Bullying


• Doxing – publishing revealing personal information about an individual
online, for purposes of defaming, humiliating, or harassing the victim
• Harassment – posting threatening, hurtful, or intimidating messages online,
or sending them directly to someone, with the intention of harming that person
• Impersonation – creating fake accounts or gaining access to a person’s real
social media accounts and posting things to damage the victim’s reputation
• Cyberstalking – tracking and monitoring a person’s online activity, and
using the internet to stalk or harass an individual.

Cyber Trolling has become a more common term for any kind of purposeful
online abuse on social media sites like Twitter or Facebook.

Computer Security Threats


Malware: Malware could be computer viruses, worms, Trojan horses,
dishonest spyware, and malicious.
Computer virus: It is a small piece of software that can spread from one
infected computer to another. It can corrupt, steal, or delete data on your
computer/hard drive.
Trojan horse: can do anything from record your passwords by logging
keystrokes (known as a keylogger) to hijacking your webcam to watch and
record your every move.
Computer worm: A computer worm is a software program that can copy
itself from one computer to another, without human interaction.
97
Spam: unwanted messages in your email inbox sent through computer
generated program.
Phishing: Phishing are fraudulent attempts by cybercriminals to obtain private
information. For e.g. a message prompt your personal information by
pretending that bank/mail service provider is updating its website.
Spyware: spyware is used to spy on their victims. An e.g. is keylogger software
that records a victim’s every keystroke on his or her keyboard.
Adware: unwanted ads shown while surfing internet.
Eavesdropping: is the act of intercepting communications between two points.

Indian Information Technology (IT) Act 2000

Some key points of the Information Technology (IT) Act 2000 are as follows:
• Act has given birth to new business to companies to issue digital
certificates by becoming the Certifying Authorities.
• This Act allows the government to issue notices on internet through e-
governance.
• E-mail is now considered as a valid and legal form of communication.
• Digital signatures are given legal validity within the Act.
• The communication between the companies or between the company and
the government can be done through internet.
• Addressing the issue of security is the most important feature of this Act. It
introduced the construct of digital signatures that verifies the identity of an
individual on internet.
• In case of any harm or loss done to the company by criminals, the Act
provides a remedy in the form of money to the company

E-Waste -Whenever an electronic device covers up its working life, or


becomes non-usable due to technological advancements or becomes non-
functional, it is not used anymore and comes under the category of e-waste or
electronic waste. As the technology is changing day by day, more and more
electronic devices are becoming non-functional and turning into e-waste.
Managing such non-functional electronic devices is termed as e-waste
management.
E-waste Hazards -on environment
• Acidification of soil
• Air pollution
• Pollution of ground water
• Landfills with lead and heavy metals On Human Health
• Lung cancer
• DNA damage
• Asthmatic bronchitis
• Chronic damage to the brain

Proper Disposal of used Electronic Gadgets


E-waste is a growing problem for us in India. As an 132cr strong economy, we
produce e- waste in large quantities. It is very important to dispose off waste in
a pragmatic manner.
Ways to dispose off e-waste:
1. Give Back to Your Electronic Companies and Drop Off Points
2. Visit Civic Institutions
3. Donating Your Outdated Technology
4. Sell off Your Outdated Technology

98
Awareness of Health concerns related to the usage of technology.
Physical Problems:
• Repetitive Strain Injury: the pain exists even when resting and that the
lightest work becomes hard to do.
• Carpal Tunnel Syndrome: This is an illness caused by injuries that occur
due to force on the median nerve found in the wrist. Its symptoms can
occur as tingling in hands and fingers and the feeling of lethargy, sudden
pain in wrists and arms and sometimes even in shoulders, neck and in the
body
• Computer Vision Syndrome: Experts stated that people blink their eyes
more frequently while using a computer than they do at other times and
that they face some problems related to this situation.
• Radiation: Computer screens produce radiations of various types. There
have always been doubts that Individuals will have illnesses such as
headaches and inattentiveness
• Sleeping Disorders and Decrease in Productivity
• Loss of Attention and Stress
Awareness of Health concerns related to the usage of technology.
Psychological Problems:
• Fear of technology
• Computer anxiety
• Internet addiction

Multiple Choice Questions of Cyber Law [1-Mark]


1. Tampering with Computer Source Documents is ______ offence.
(a) Bailable (b) Non-bailable (c) Non-cognizable (d) Both (a) and
(c)
Ans. (b) Non-bailable
2. Every appeal to Cyber Appellate Tribunal shall be filed within a period of _____.
(a) 60 days (b) 90 days (c) 45 days (d) 30 days
Ans. (c) 45 days
3. Sending of unsolicited bulk and commercial messages over the internet is
________.
(a) Stalking (b) Phishing(c) Spamming (d) Spoofing
Ans. (a) Stalking
4. Permitted use of disruptive activities or the threat thereof in cyber space is called
_______.
(a) Commerce (b) Credit Card fraud(c) Net Banking (d) Cyber Terrorism
Ans. d) Cyber Terrorism
5. Information Technology Act was passed in the year _________.
(a) 1999 (b) 2000 (c) 2008 (d) 2012
Ans. b) 2000
6. Computer virus is a ________.
(a) Programme (b) File (c) Disk (d) Audi
Ans. a) Programme
7. Repeated act of harassment after threatening behaviour is called as :
(a) Cyber stalking (b) Data diddling (c) Cyber theft (d)
Cryptography
Ans. a) Cyber stalking
8. IT Act 2000, amended in :
(a) 2005 (b) 2008 (c) 2011 (d) 2015
Ans. b) 2008
9. Harassing someone through electronic message is offence of :
(a) Hacking (b) Squatting (c) Stalking (d) Phishing
99
Ans. b) Squatting
10. The receiving of unsolicited bulk emails is known as –––––
(a) Virus (b) Spoofing (c) Spam (d) Worms
Ans. c) Spam
11. Child pornography is prohibited by ______ of IT Act, 2000.
(a) Sec. 64 (b) Sec. 65 (c) Sec. 66 (d) Sec. 67-B
Ans. d) Sec. 67-B
12. Cyber Crime involves the theft of :
(a) Property (b) Identity (c) Money (d) All of these
Ans. d) All of these
13. Cyber Crime is a crime in which computer is used as :
(a) Tool (b) Target (c) Both (a) and (b) (d) None of the above
Ans. c) Both (a) and (b)
14. The cyber offence in which frauds are committed by inviting people to invest
money and sharing financial information is :
(a) Hacking (b) Squatting (c) Piracy (d) Phishing
Ans. d) Phishing
15. The science of sending secret cypher and decoding it, is called _____.
(a) Photography (b) Cyprography (c) Data diddling (d) Cryptography
Ans. d) Cryptography
Short Answers Questions (2-Mark)
1. Define Netiquette.
Ans. Netiquette is a combination of words ‘network’ and ‘etiquette’. It
defines the proper manners and behaviour one should possess while
working on the internet.
2. What is Cybercrime?
Ans. The computer related online crimes that include criminal activities
such as illegal copying of software, spreading computer viruses, hacking,
pirating a software, etc. are referred to as ‘Cybercrime’.
3. What is cyber trolling?
Ans. Cyber trolling refers to creating discord or upsetting people by
posting inflammatory or off-topic messages online, targeting certain
people.
4. What is meant by malware?
Ans. The ‘Malware’ is a type of destructive code that replicates by getting into
other’s computer
causing harm to the data and devices.
5. What do you mean by hackers?
Ans. The people who are involved in the cybercrime of hacking are called
‘Hackers’.
6. What are the steps which can ensure the confidentiality of data?
Ans. Back up your data, use a firewall and use multi-factor authentication
7. Write any 2 sources through which a virus can attack your computer system.
Ans. Pirated softwares/applications and browsing unwanted websites
containing viruses.
8. Name any 3-cybercrimes which often take place in the internet world.
Ans. Cyberstalking, Hacking, Phishing.
9. What do you mean by IPR?
Ans. Intellectual Property Rights means the ‘Ownership of ideas’ which is
created by using the skills and mental abilities of a person. The
development of software mainly requires the ability to create first-hand
knowledge which is unique.
10. As a citizen of India, what advice would you give to others regarding e-
waste management?
100
Ans. As a citizen of India, we can advise others to follow the three principles
of e-waste management viz. Reduce, Reuse and Recycle.
Long Answers Questions (3-Marks)
1. What is a virus? Give any example.
Ans. It is defined as malicious code programmed in such a manner that it
can spread from one device to another. It harms other users.
Example Mindware etc.
2. What is Cyber Ethics?
Ans. Cyber ethics is a set of morally correct rules. It is also a security
protocol that decides a code of behaviour. It must be followed and taken
care of while using the online environment. A responsible citizen must
follow these rules while using the internet.
Cyber ethics helps to create a safe environment in cyberspace. People who
don’t follow cyber ethics are considered threats by the government of any
nation.
Some important rules include:
Do not ask for, send, or store any offensive content.
Do not access any network or system without permission.
Do not store any data of users even if it is public.
3. Why is it important to follow cyber ethics? Write about some cyber ethics.
Ans. It is important to follow cyber ethics because online communication is
non-verbal. It is preferred to keep the internet a safe space.
Do not bully, harass, abuse, or stalk anyone over the internet.
Do not spread computer viruses even if it is for fun.
Do not spam any internet user.
Do not violate copyright laws.

101
KENDRIYA VIDYALAYA SANGATHAN JAIPUR REGION
Class: XI Session: 2022-23 Computer Science (083)
Practice Paper-1(Theory)
MaximumMarks:70 Time Allowed: 3 Hrs

General Instructions:
1. This question paper contains fives sections, Section A to E.
2. All questions are compulsory.
3. Section A have18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice
is given in Q35 against part C only.
8. All programming questions are to be answered using Python Language only.
SECTION A
1. MS-Office is a- 1
(a) Operating Software (b) Utility program
(c) Programming language (d) Application Software
2. What is the ASCII equivalent decimal no. for ‘Y’ ? 1
a) 87 (b)88 (c) 89 (d)90
3. Hexa-Decimal of (346)10= (?)16(Show calculation) 1
(a) 14B (b) 1A5 (c)15A (d) 5A1
4. Find the invalid identifier(s) from the following: 1
a) MyName b) 2ndName
c) true d) My_Name
5. Suppose tuple T is T = (10, 12, 43, 39), Find incorrect? 1
a) print(T[1]) b) T[2] = -29
c) print(max(T)) d) print(len(T))
6. What will be the result of the following code? 1
>>>d1 = {“abc” : 5, “def” : 6, “ghi” : 7}
>>>print (d1[abc])
(a) abc (b) 5 (c) {“abc”:5} (d) Error
7. Suppose list L is declared as 1
L = [5 * i for i in range (0,4)], list L is
a) [0, 1, 2, 3,] b) [0, 1, 2, 3, 4]
c) [0, 5, 10, 15] d) [0, 5, 10, 15, 20]
8. Identify declaration of M = ‘Mon’,‘23’,‘Bye’, ’6.5’ 1
a) dictionary b) string c) tuple d) list
9. STR=”RGBCOLOR” 1
colors=list(STR)
How do we delete ‘B’ in given List colors?
(a) del colors[2] (b) colors.remove("B")
(c) colors.pop(2) (d) All of these
10. What is the value of x when this loop has been terminated: 1
x=45
while x>0:

102
print(x)
x=x-10
(a) 25 (b) 45 (c) 5 (d) -5
11. What will be the output of the following Python Code? 1
tp=(5,)
tp1=tp * 2
print(len(tp1))
(a) 0 (b) 2
(c) 1 (d) error
12. day_name= ['Mon', 'Tues', 'Wednes', 'Thursday', 'Friday', 'Saturday','Sunday'] 1
print(day_name[7])
What will be the result?
(a) Sunday (b)Saturday
(c)Error (d) Mon
13. It is a ____________ Logical Gate 1

(a) XOR (b) NAND


(c) AND (d) OR
14. Which is equivalent of (A+B)’ 1
(a) A’.B’
(b) A’+B’
(c) A.B’
(d) A’.B
15. Which is not a threat? 1
(a) Worm (b) Trojan
(c)Virus (d) E-Mail
16. What type damages can be caused by viruses to your computer? 1
(a) Damage or Delete files
(b) Slow down your computer
(c) Invade all Programmes in your Computer
(d) All of these
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. Choose correct option: 1
A: Viruses are the malicious program.
R: Worm means Write Once Read Many.
(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

103
18. Choose correct option: 1
Statement 1: t1=tuple(’python’)
Statement 2: t1[4]=’z’
A: Above code will generate error Statement2:
R: Tuple is immutable by nature.
(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
SECTION B
19. What will be the output of the following Python code? 2
x, y=4, 2
while(x>=y):
print(x, y)
x=x-1
y=y+1
a) 4, 2 b) Invalid syntax c) 2, 4 d) Nothing is printed
3, 3 3, 3
20. What is the result of this statement: 2
10>5 and 7>12 or not 18>3
a) 10 b) True c) False d) None
OR

What will be the output of the following Python code?


>>> 6 * 3 + 4 ** 2 // 5 - 8
a) 13 b) 14 c) Error d) None
21. Convert the following program into for loop without affecting the output. 2
count=0
while count<10:
print(“Hello”)
print(“Good Bye!”)
count=count+1
22. What do you understand by PC intrusion? 2
23. What is a spam? Why has it become a big Internet issue? 2
24. How many times will the following for loops execute and what’s the output of 2
this program?

for i in range(-1,-7,-2):
for j in range(3):
print(1, j)
OR
What’s the output of the following program.
fruits = { 'Apple': 100,
'Orange': 200,
'Banana': 400,
'pomegranate':600 }
if 'Apple' in fruits:
del fruits['Apple']
print('Dictionary after deleting key =',fruits)
25. Write a program to print the Fibonacci Series till n terms, where n is entered 2
by the user.
104
SECTION C
26. Answer the following: 3
i) Convert: (111111110101110.1101101111)2= (?)16 (1+2)
ii) Differentiate between Compiler and Interpreter.
27. Rewrite the following code in Python after removing all syntax error(s). 3
30 = To
for K in range(0, To)
If K%4 == 0:
Print(K*4)
Else:
Print(K + 3)
28. Write a program to check whether the entered number is Armstrong or not. 3
29. What possible output(s) are expected to be displayed on screen at the time of 3
execution of the program from following code? (1 + 2)
from random import randint
LST=[5,10,15,20,25,30,35,40,45,50,60,70]
first = random.randint(3,8) -1
second = random.randint(4,9) -2
third = random.randint(6,11) -3
print(LST[first],"#", LST[second],"#", LST[third],"#")
a) 20#25#25# b) 30#40#70#
c) 15#60#70# d) 35#40#60#
Specify the maximum values that can be assigned to each of the variables
second and third in the code given.
30. Umesh wanted to gift his brother a football or a wrist watch. So he searched 3
for many sports items and wrist watches online. But after that every time he (1+1+1
goes online, his web browser shows him advertisements about sports items )
and wrist watches.
(a) Why is this happening?
(b) How could have Umesh avoided them?
(c) How can Umesh get rid of this now?
SECTION D
31. Write a program to search for an element in a given list of numbers. 4
32. Expand the following: - 4
i) Write the full forms of following: IPR, GPL, Proprietary Software, (2+2)
URL
ii) Identify the Open Source software(s) from the following: -
MySql, Quick Heal Antivirus, Python, Microsoft Office
SECTION E
33. Explain the following : 5
(i) What is syntax error? Give one example. (1+2
(ii) What is the difference between ‘=’ and ‘==’? Explain with the help of +2)
an example.
(iii) What do you understand by precedence of operators? What is the
precedence of arithmetic operators?

105
34. Write the solution for the following problem: 5
(a) Write the output of this program : (2+3)
s1='Hello World!'
index=0
while index< (len(s1)-3):
print(s1[index], end=' ')
index =index+ 1
OR
Write the output of this program. Justify your answer also.
my_dict={ }
my_dict[1]=1
my_dict[‘1’]=2
my_dict[1.0]=4
print(my_dict)
(b)Write a Python program to create a dictionary to store names of states and
their capitals.
OR
Write a Python program to create a third dictionary from two dictionaries in
the way so that the values are shown in third dictionary.
35. Explain the following : 5
(a) How do websites track you online? (3+2)
(b) What are cookies? How are they used by websites to track you?
******************************

106
KENDRIYA VIDYALAYA SANGATHAN JAIPUR REGION
Class: XI Session: 2022-23 Computer Science (083)
Answer Key for Practice Paper-1
MaximumMarks:70 Time Allowed: 3 Hrs
SECTION A
1. (d) Application Software 1
2. (c) 89 1
3. (c)15A 1
4. (b) 2ndName 1
5. (b) T[2] = -29 1
6. (d) Error 1
7. (c) [0, 5, 10, 15] 1
8. c) tuple 1
9. (d) All of these 1
10. (d) -5 1
11. (b) 2 1
12. (c)Error 1
13. (c) AND 1
14. (a) A’.B’ 1
15. (d) E-Mail 1
16. (d) All of these 1
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
(e) Both A and R are true and R is not the correct explanation for A
(f) A is True but R is False
(g) A is false but R is True
17. (b) Both A and R are true and R is not the correct explanation for A 1
18. (d) A is false but R is True 1
SECTION B
19. a) 4, 2 2
3, 3
20. c) False 2
OR

a) 13
21. for count in range(0,10,1): 2
print(“Hello”)
print(“Good Bye!”)
22. PC Intrusion - Computer Definition. To compromise a computer system by 2
breaking the security of such a system or causing it to enter into an insecure
state. The act of intruding—or gaining unauthorized access to a system—
typically leaves traces that can be discovered by intrusion detection systems.

107
23. Spam email is a form of commercial advertising which is economically viable 2
because email is a very cost-effective medium for the sender. If just a fraction
of the recipients of a spam message purchase the advertised product, the
spammers are making money and the spam problem is perpetuated.

24. Outer loop ( i based) run 3 times and Inner loop ( j based) will run 3 times for 2
each value of i.
Output:
10 11 12 10 11 12 10 11 12
OR
Dictionary after deleting key = {'Orange': 200, 'Banana': 400, 'pomegranate':
600}
25. n=int(input("How many numbers do you want to print in Fibonacci Series: ")) 2
first=0
second=1
i=3
print(first, second, end=" ")
while i<=n:
third=first+second
print(third, end=" ")
first=second
second=third
i=i+1
SECTION C
26. iii) (111111110101110.1101101111)2= (7FAE.DBC)16 3
iv) Difference between Compiler and Interpreter:
1. Compiler converts whole source code of program into target
program (machine code) in one round and display all the errors
with their line numbers while Interpreter converts source code
into machine code program line by line and stop/ halt at the
error-prone line until that error has been debugged from that
line of code.
2. Compiler takes lesser time in conversion while Interpreter takes
more time in conversion.
27. Rewrite the following code in Python after removing all syntax error(s). 3
To=30 # Variable assignment statement
for K in range(0, To): #colon should be there before loop body
if K%4 == 0: # if is a keyword
print(K*4) #print( ) is a predefined method in python
else: # else is a keyword
print(K + 3)
28. temp=n=int(input("enter a three digit number:")) 3
sum=0
while(n>0):
r=n%10
sum=sum + (r*r*r)
n=n//10
if temp==sum:
print("armstrong")
else:
print("not armstrong")
29. a) 20#25#25# 3
Option (a) is expected output. (1+2)
Maximum values that can be assigned to the variables second and third are 7
and 8 respectively.
108
30. (a) This is happening because third party cookies saved his search preferences 3
and now websites are posting advertisements based on his preferences. (1+1+1
(b) Umesh could have avoided this by privately browsing i.e. opening the web )
browser in incognito mode before searching for such things.
(c) Now Umesh can delete all the previous history and cookies stored on his
computer. This would stop websites posting advertisements.

SECTION D
31. L1=[2,5,11,13,18] 4
list1=len(L1)
n=int(input("Enter element to be searched for"))
for j in range(0, list1,1):
if L1[j]==n:
print(n,"found at index",j)
break
else:
print(" Element Not found" )
32. iii) IPR- Intellectual Property Rights 4
GPL-General Purpose License (2+2)
Proprietary Software-The software which is purchased by paying
some amount of money.
URL-Unified Resource Locator
iv) the Open Source software(s) are: MySql, Python
SECTION E
33. (i) syntax error-These are produced by Python when it is translating the 5
source code into byte code. They usually indicate that there is something (1+2+2
wrong with the syntax of the program. Example: Omitting the colon at the end )
of a for statement yields the somewhat redundant message SyntaxError:
invalid syntax.
Example: print(“Hello” #syntax error due to right parenthesis is missing
(ii) Difference between ‘=’ and ‘==’operator:
‘=’ assignment operator while ‘==’ is equality operator.
Example: a=5 # value 5 assigned to variable a.
2==9 # checks the equality, gives False as result
(iii) The order in which the operators are executed in an expression is called
the operator precedence. The precedence of Arithmetic operator is as follows:
**
*, /, //, %
+, -
34. Write the solution for the following problem: 5
(b) Output: H e l l o W o r (2+3)
(c) OR
Output: {1: 4, '1': 2}
Justification/Reason: 1 and 1.0 are considered as same key of integer type
while ‘1’ is considered as string type key hence statement-4 overwrite the
value assigned in statement-2 by the compiler.

(b)
md={ }
n=int(input("How many capitals you want to store"))
for i in range(n):
st=input("Enter state:")
cap=input("Enter Capital:")
md[st]=cap

109
print("States and their capitals are:", md)
OR
d1={ 1:'one',2:'two', 3: 'three' }
d2={ 4:'four',5:'five',6:'six'}
d3=dict(d1)
d3.update(d2)
print(d1)
print(d2)
print(d3)
35. (a) Whenever you visit a website, your web browser may reveal your 5
location via your device‘s IP address. (3+2)
1. It can also provide your search and browsing history etc. which may be
used by third parties, like advertisers or criminals.
2. This way website track you. Tracking is generally used by advertising
networks to build up details profiles for pinpoint ad targeting.
3. This information is compiled through your web usage patterns, and
which websites generally use for tracking you.
This generally includes-
1. IP Address
2. Cookies and tracking scripts etc.
3. HTTP Referrer
4. Super Cookies
5. User Agent
(b) Cookies are small pieces of information websites can store in your
browser.
Cookies can be –
1. First Party Cookies- These are the cookies that store your own log in id,
password, and auto fill information etc.
2. Third Party Cookies: These are the cookies that websites store to know
about your search history and web browsing history so as to place
advertisements as per your interests.

******************************

110
KENDRIYA VIDYALAYA SANGATHAN JAIPUR REGION
Class: XI Session: 2022-23 Computer Science (083)
Practice Paper-2 (Theory)
Maximum Marks: 70 Time Allowed: 3
hours

General Instructions:

• This question paper contains five sections, Section A to E.


• All questions are compulsory.
• Section A have 18 questions carrying 01 mark each.
• Section B has 07 Very Short Answer type questions carrying 02 marks each.
• Section C has 05 Short Answer type questions carrying 03 marks each.
• Section D has 03 Long Answer type questions carrying 05 marks each.
• Section E has 02 questions carrying 04 marks each. One internal choice is
given in Q35 against part c only.
• All programming questions are to be answered using Python Language only.
SECTION A
1. Which of following is Which of the following is the smallest unit of data in a 1
computer?
(a) Bit (b) KB (c) Nibble (d) Byte
2. Which of the following is an example of primary memory? 1
(a)Hard Disk (b)RAM
(c)Floppy Disk (c)DVD
3. A gate gives the output as 1 only if the input signal is 0. 1
(a) NOR (b) OR
(c)NOT (d) XOR
4. Given A= “[ 22,4.88,”India”, “T”]” the datatype of A is 1
(a) List (b) String (c) Dictionary (d) Tuple
5. Which of the following is a keyword in Python language? 1
(a) if (b)for
(c) int (d) all above
6. Which of following is valid identifier- 1
(a) NUM (b) 1_Num
(c) F.No (d) False
7. Which of following datatype not supported by python- 1
(a) float (b) Complex
(c) List (D) Date
8. Which of the following is a valid statement in python? 1
(a) name = “bikaner’
(b) num = 1,000
(c) a+b =c
(d) x=”30” +5

111
9. Which of following can be used for making a comment in python- 1
(a) & (b) # (c) @ (d) None of these

10. You should never give out which of the following on the Internet? 1
(a) Your name (b) Your age (c) Your address. (d)All of the above.
Which of the following is the best description of an 'internet troll'? 1
11.
(a) Someone who goes trolling on the internet, moving from place to place
without settling anywhere in a chat room or on a board.
(b) A funny emoticon made to look like a troll.
(c)Another name for a spammer.
(d) Someone who participates in a message board or chat with the intention to
disrupt it in some way.

12. In which of the following, a person is constantly followed/chased by another 1


person or group of several peoples?

(a) Phishing (b) Bulling (c) Stalking (d) Identity theft


13. Find the output of the following code- 1
number= [1,5,7,0,4]
print(number[2:3])
(a) [5]
(b) [7]
(c) [7,0]
(d) None of above
14. What is output of following code segment- 1
T= min(1,6,0,-3,100)
(a) 1 (b) -3 (c) 0 (d) None of above

15. Predict the output of the following code: 1


a=5
a+=100
if(a<100):
print(“false”)
else:
print(“true”)

(a) true ( b ) false (c) no output (d) none of these


16. Which of these is not a primitive or fundamental data types? 1
(a) integer ` (b) Boolean
(c) List (d) String
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
(h) Both A and R are true and R is not the correct explanation for A
(i) A is True but R is False
(j) A is false but R is True

112
17. Choose correct option : 1
T1=[3,9,0,1,7]
T2=[5,1,0,7,5.5]
Statement A: Output of print (len(T1)==len(T2) is True.
Statement R: method len() returns the number of elements in the list.
(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
18. Choose correct option: 1
S1=’CoMPuter SciENce’
S1[0] =S1[0].lower()
Statement A: Above code will generate error.
Statement R: String is mutable by nature.
(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
SECTION B
19. (a) What will be the output of the following Python code? > 2
>>> print(math.ceil(55.1))
(b) Which python module required to run above code successfully?

20. What is token ? Name various types of token. 2

OR

What will be the output of the following Python code?


>>> a=72.55
>>> b=10
>>> c=int(a+b )
>>> c
a) 72.55 b) 72 c) 82 d) None of these

21. (a) Write the output of following code segment. 2


str= “ CS and IP"
a=str.split()
print(a)

(b) Write the output of the code given below:


dict = {"stname": "Ajay", "age": 17}
dict['age'] = 27
dict['address'] = "Bikaner"
print(dict)

22. Define the term: 2


(a) Digital Footprints
(b) Cookies
23. What measures should one take to avoid and maintain confidentiality of 2
personal information?

113
24. Predict the output of the Python code given below: 2

fruits = ["apple",”mango”, "banana", "cherry"]


for x in fruits:
if(len(x)>5):
print(x )
OR

Predict the output of the Python code given below:

i = 1
while i < 6:
print(i)
if i == 3:
break
i += 1

25. Write a program calculate and print total and average runs scored by a 2
cricketer in 3 matches.
SECTION C
26. State De Morgan’s laws / theorems and prove using truth table. 3

27. Rewrite following code after removing errors (if any): 3


N=100
A= “Number” +5
B= 2N +20
Print(B)
28. Write a program to print following series – 3
2,4,8,16, …………….
29. Write a program to input names of 5 employee and store them in a List. Now 3
enter name of an employee and find if this employee is present in the List or
not.

30. What are common gender and disability issues faced while teaching / using 3
computers in class rooms.

SECTION D
31. Write a python program to calculate factorial of a number. 4
32. Convert the following numbers. 4
(a) ( 100111101 )2 = ( ? )8
(b) ( 127 )10 = ( ? )2
SECTION E
33. (a) Differentiate between list and tuple with example ? 5
(b) Write a python program to input 3 students name and their marks using (3+2)
dictionary. Print the dictionary also.
34. Write the solution for the following problem: 5
(a) How is random.randint(10) different from random.randrange (10)? (3+2)
(b)Write a Python program to generate a random number between 0 to 8.

114
35. (a) What is E-waste management? Discuss proper disposal of used electronic 5
gadgets (3+2)
(b) Write short note on IPR (Intellectual Property Right).

******************************

115
KENDRIYA VIDYALAYA SANGATHAN JAIPUR REGION
Class: XI Session: 2022-23 Computer Science (083)
Answer Key Practice Paper 2 (Theory)
Maximum Marks: 70 Time Allowed: 3

SECTION A
1. (a) Bit
2. (b) RAM
3. (c) NOT
4. (b) String
5. (d) All Above
6. (a) NUM
7. (d) Date
8. (b) bum=1,000
9. (b) #
10. (d) All of the above.
11. (d) Someone who participates in a message board or chat with the intention to
disrupt it in some way.

12. (c) Stalking


13. (b) [7]
14. (b) -3
15. (a) true
16. (c) List
17. (a)
18. (a)
Section B
19 (a) 56
(b) import math
20 Smallest unit in a program is known as token. Examples – int, if , a, num, # etc
OR
c) 82
21 (a) ['CS', 'and', 'IP']
(b) {'stname': 'Ajay', 'age': 27, 'address': 'Bikaner'}
22 (a) Digital Footprints -Digital footprints are the records and traces that we
leave behind as we use the internet.
(b) Cookies are text files with small pieces of data — like a username and
password — that are used to identify your computer as you use a computer
network.
23 Use a firewall, install antivirus, create strong password , don’t share personal
information

116
24 Banana
cherry
OR
1
2
3
25 run1= int (input ("Enter run scored in 1st inning="))
run2= int (input ("Enter run scored in 2nd inning="))
run3= int (input ("Enter run scored in 3rd inning="))
total= run1 +run2 + run2
avg= total/3
print("Total runs=",total)
print("Average Runs= ", avg)
26 3 Marks both theorem and truth table.
(i) (A+B)’ = A’.B’ (ii) (A.B)’ = A’+B’
27 N=100 (No Error)
A= “Number” +”5 “
B= 2*N +20
print(B)
28 #Series -----2,4,8,16, …………….
a=1
n= int (input ("Enter the terms="))
for i in range(n):
a=a*2
print(a, end=",")
29 L=[]
found=False
for i in range(5):
name=input("Enter Name =")
L.append(name)
text=input("Enter name to be searched=")
for i in range(len(L)):
if (text ==L[i]):
found=True
if(found):
print("Name is in List")
else:
print("Name is not in List")
30 Preconceived notions, Lack of interest, Lack of motivation

Unavailability of teaching material / aids, Lack of special needs teachers, Lack


of supporting curriculum
31 n= int (input ("Enter the Number="))
f=1
for i in range(1,n+1):
f=f*i
print("Factorial=",f)
117
32 (a) 475
(b) 1111111
33 (a)List is collection of items enclosed with[]. Tuple is collection of items
enclosed with(). List is mutable . Tuple is immutable.
L=[1,4,5,6,2] is a list
T=(3,5,4,1,8) is a tuple.
(b) student={}
n=3
i=1
while(i<=n):
a=input("enter student name=")
b=input("enter marks")
student[a]=b
i=i+1
print(student)
34 (a) randint() when we want to generate a random number from an inclusive
range.
randrange() when we want to generate a random number within a range by
specifying the increment. It produces a random number from an exclusive
range.
(b) import random
a=random.randint(0,8)
print(a)
35 (a) Electronic waste or e-waste describes discarded electrical or electronic
devices. Used electronics which are destined for refurbishment, reuse, resale,
salvage recycling through material recovery, or disposal are also considered e-
waste. Informal processing of e-waste in developing countries can lead to
adverse human health effects and environmental pollution.
We should Recycle it.
(b) Intellectual property (IP) is a category of property that includes intangible
creations of the human intellect. There are many types of intellectual property,
The best-known types are copyrights, patents, trademarks, and trade secrets.

118
KENDRIYA VIDYALAYA SANGATHAN JAIPUR REGION
Class: XI Session: 2022-23 Computer Science (083)
Practice Paper-3 (Theory)
Maximum Marks: 70 Time Allowed: 3 hours

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02
marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks
each.
6. Section D has 03 Long Answer type questions carrying 05 marks
each.
7. Section E has 02 questions carrying 04 marks each. One internal
choice is given in
Q35 against part c only.
8. All programming questions are to be answered using Python
Language only.

SECTION: A
Q.No Question Marks

1. Components that provide internal storage to the CPU is: 1


(a) Registers (b) Program Counters
(c) Controller (d) Internal Chips
2. The boolean expression of following logic circuit is : 1

(a) (A+B).C'+B (b) A'B'+C+B'A


(c) A.B.C+(B'+C').A (d) A+B+C'(A+B)
3. Full form of OMR is: 1
(a) Optical Mark Reading (b) Optical Mark Recognition
(c) Optical Mark Reader (d) Optical Mark Resolution
4. Which of the following is not valid string in Python? 1
(a) “Hello” (b) ‘Hello’
(c) “Hello’ (d) None of the Above
5. What shape represents a decision in a flow chart? 1
(a)Oval (b) Diamond (c) Rectangle (d) Arrow
6. What will be the output of above Python code? 1
abc="6/4"
print("abc")

119
(a) 1 (b) 6/4 (c) 1.5 (d) abc
7. Which of the following will give "Simon" as output? 1
If str1="Hari,Simon,Vinod"
(a) print(str1[-7:-12]) (b) print(str1[-11:-7])
(c) print(str1[-11:-6]) (d) print(str1[-7:-11])
8. What is identity theft? 1
9. Accessing of data in a dictionary is done through : 1
(a)Index (b) value (c) key (d) cell number
10. Which of the following will be the output of the operation? 1
L1=[1,2]
L2=[3,4]
(L1 + L2)*2
(a) [2,4,6,8] (b) [1,2,3,4,1,2,3,4] (c) [1,3,4,4] (d) [3,4,1,2]
11. Which of the following can add a list of elements to a list? 1
(a) append() (b) extend() (c) add() (d) none of these
12. Which of the following is not a type of cyber criminals? 1
(a) Unauthorized account access (b) Email spoofing and spamming
(c) Mass attack using Trojans as botnets (d) Report vulnerability in any system

13. Which of the following can be termed as Cyber Bullying: 1


a) Posting Rumors online
b) Posting hate speech
c) Posting sexual remarks
d) All the above
14. How many asterisks does the following code 1
fragment print?
a=3
while a < 20:
print('*')
a += 1
(a)16 (b) 17 (c) 18 (d) 20
15. What is the output of the following? 1
>>>print('INDIA'.capitalize())
16. ‘Python is an interpreted high level language’. What does it mean to you? 1
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
(k) Both A and R are true and R is not the correct explanation for A
(l) A is True but R is False
(m) A is false but R is True
17. Assertion (A) : Comments are non-executable statements that enable the users to 1
understand the program logic.
Reason (R) : They are basically statements used to put remarks. The comments
are used to explain the code and to make it more informative for the users.
Pick an appropriate statement from the given options:
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true and R is not the correct explanation of A.
(c) A is true but R is false.
(d) A is false but R is true.
18. Assertion (A) : In Python, the tuple is an immutable collection of data. 1
Reason (R) : It means that any change or alteration in data, is mentioned in the
120
same place. The updated collection will be use the same address for its storage.
Pick an appropriate statement from the given options:
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true and R is not the correct explanation of A.
(c) A is true but R is false.
(d) A is false but R is true.
SECTION : B
19. What is output from the following code : 2
(i)range(6) (iii)range(5,20,4)
(ii)range(7,10) (iv)range (12,1,-2)
20. How the pop ( ) function is different from remove( ) function working with list in 2
python ?
OR
What will be the output of the following python code:
(i) a = [12,14,16,18,10]
print(a[-1:1:-2])
(ii) d = {'Name':'Ravi', 'Marks':90}
e = {'Age':16, 'Marks':95}
d.update(e)
print(d)
21. How the internet security is a major issue? Write any two solutions of internet 2
security threats.
22. What is mutable and immutable data objects in Python? Name any one of each 2
type.
23. Identify the valid and invalid identifiers 2
MyDiary, 1num, File123, _Clear, Mynameisking, while, Your.story, If
24. (i)Name the popular micro blogging social networking website 2
ii)To protect a computer from virus, you should install -------- in your computer.
A. backup wizard B. disk cleanup
C. antivirus D. disk defragmenter
25. What will be the output of the following Python code? 2
>>>x,y=5,10
>>>x,y=y,x
>>>x,y
a) 5,10 b) 10,10 c) 10,5 d) 5,5
OR
What will be the output of the following code
(i) List1=[13,18,16,16,13,18]
print(List1.index(16))
(ii) Strg=”computer”
print(Strg[ 0: 8 : 2]
SECTION: C
26. Convert the following numbers into their equivalent numbers. 3
(i) (29.75)10 = (………….)2 (ii) (A4B)16 = (……………..)10
(iii) (1234)8 = (………….)16
27. Write a Python program to calculate bonus as the following criteria using if- elif 3
statement :
If salary between bonus
0 to 25000 25% of salary
25001 to 35000 15% of salary
35001 to 50000 10% of salary
121
50001 to 75000 05 % of salary
75001 and above nil
OR
What is difference between break and continue statement in Python explain with
example.

28. Go through the program of dictionary in python given below and predict the 3
output of program.
Student={"RollNo":10 , "Name":"Kuku" , "Class":11 , "Age":15}
T=len(Student)
Elm=Student.get("Name")
mylist=Student.items()
print("Length=",T)
print("Specific Element=",Elm)
print("My List=",mylist)
29. Find the output of the following code: 3
>>> L=["These", "are", "a", ["few", "words"], "that", "we", "will", "use"]
>>> print (L[3:4])
>>> print (L[1:4:-1])
>>> print ("few" in L)
>>> print (L[0::2])
>>> print (L[4:])
>>> print (L)
OR
Write a program to check number of ‘H’ present in a string:
“HEALPS HEALS WITHOUT HURTING”
the output will be displayed as:
Total number of ‘H’ is: 4
30. Consider the Following conversation and answer the question 3
Person 1:- What’s your name?
Person 2:- Radha
Person 1:- What is the name of your first school?
Person 2 :- Army Public School
Person 1 :- What are your Father and Mother name?
Person 2 :- Krishna and Sarita
Person 1 :- Who is your favorite actor or actress?
Person 2 :- Amitabh
Person 1:- What is the name of your pet animal?
Person 2 :- Tommy
Person 1 :- Where were you born and when?
Person 2:- Ajmer on 15 March 2002
Person 1 :- May I use your Laptop for online banking for fees payment
Person 2 :- Sure
(i) Who may be Victim of Cyber Crime Person1, Person 2 or both? Justify
your answer
(ii) Who is doing Ethical Hacking person1 or person2? Justify your Answer
(iii) Person 2 was using Key Logger software in his computer. What is it?
SECTION: D
31. Write a Python program to input 10 numbers to store in the list and print the 2+2
third largest number. For example, if the entered numbers in the list are List are
36, 25, 14, - 951, 75, - 85, 654, 88, 9521, 657, then output will be
The third largest number is : 654

122
32. What will be the output of the following code 4
i. type(34)
ii. a, b=10,20
a, b= b, a+b
print(a, b)
iii. a=20 + 4j
print(a.real + a.imag)
iv. print(10,20,30, sep=’*’,end=’@’)
SECTION: E
33. What will be the output of the following: 5
(a) [11, 14, 18, 10, 15]
(b) ['P', 'Y', 'T', 'H', 'O', 'N']
(c) L1.insert(0,12)
(d) L1.sort()
(e) L1.remove(14)
(f) L1.append(5)
(g) L2.pop()
(h) L1+L2
(i) L1.extend([12,16,18])
(j) L1*2
34. A code snippet using a dictionary is shown below and What will be the output of 5
the following :
dt={“Apple”:50, “Orange”:40, “Banana”:30 , “Mango”:80}
print(len(dt)) #Statement 1
print(dt.keys()) #Statement 2
print(dt.items()) #Statement 3
print(dt.popitem()) #Statement 4
print(dt.get("Banana")) #Statement5
Evaluate output of all statements.

35. a) What do you mean by Cyber safety? 1+2+2


b) What are different types of threats to computer security?
c) What is the need for secure password? How can one make a strong password?

123
Class: XI Session: 2022-23Computer Science (083)
Answer Key Practice Paper 3 (Theory)
SECTION A

1. (a) Registers 1
2. (c) A.B.C+(B'+C').A 1
3. (c) Optical Mark Reader 1
4. (c) “Hello’ 1
5. (b) Diamond 1
6. (d) abc 1
7. c) print(str1[-11:-6]) 1
8. Identity Theft is a type of fraud that involves using someone else’s identity to steal 1
money or gain other benefits.
9. (c) key 1
10. (b) [1,2,3,4,1,2,3,4] 1
11. (b) extend() 1
12. (d) Report vulnerability in any system 1
13. (d)All the above 1
14. (b) 17 1
15. India 1
16. Python is an interpreted language, which means the source code of a Python 1
program is converted into bytecode that is then executed by the Python virtual
machine.
17.
(e) Both A and R are true and R is the correct explanation of A. 1
18. (c)A is true but R is false. 1
SECTION : B
19. What is output from the following code : ½*4=2
(i)range(6) : 0,1,2,3,4,5
(ii)range(7,10) : 7,8,9
(iii)range(5,20,4) : 5,9,13,17
(iv)range (12,1,-2): 12,10,8,6,4,2
20. Pop() will delete last item from a list. Also displaying the deleted item. 1+1=2
Remove() function will delete given item from list.
OR
(i) [10,16]
(ii) {'Name': 'Ravi', 'Marks': 95, 'Age': 16}
21. Definition of internet security: 1 Mark 2
two solutions of internet security threats : ½ Marks each
22. Mutable :- That can be modified . example List 1+1=2
Immutable :- That can not be modified . example Tuple, String
23. Valid : MyDiary, File123, _Clear, Mynameisking, If 1+1=2
Invalid=1num, while, Your.story
24. (i) 1. Twitter · 2. Tumblr · 3. Pinterest · 4. Instagram · 5. Facebook · 6. LinkedIn. 1+1=2
ii) C. antivirus

124
25. c) 10,5 1+1=2
OR
(i) 2
(ii) Cmue
SECTION : C
(i)26. (29.75)10 = 11101.11 1+1+1=
(ii) (A4B)16 = 2635 3
(iii) (1234)8 = 29C
27. sal=int(input("enter the salary of employee:")) #1/2 mark 3
if (sal <=25000): #1/2 mark
b=sal*.25
elif (sal>25000 and sal <= 35000): #1/2 mark
b=sal*.15
elif (sal>35000 and sal <= 50000): #1/2 mark
b=sal*.10
elif (sal>50000 and sal <= 75000): #1/2 mark
b=sal*.05
else:
b=0
print("Bonus will be: ",b) #1/2 mark

OR
1 mark for break+1/2 mark for example
- Break: it’s a jump statement which forces to skip the remaining statements/
iterations of the loop and exit the loop.
Example : while(True) :
n=int(input(“enter a number and zero to terminate”))
if(n==0):
break
print(n*n)
1 mark for continue+1/2 mark for example
- Continue: it is just opposite to the break statement. As soon as continue is invoked,
the control will return for the next iteration of the loop.
example :
for i in range(1,5):
a= int(input(“enter first number”))
b= int(input(“enter second number”))
c=a+b
if(c<0):
print(“ program continues”)
continue
print(“sum of two numbers:”,c)

28. Length= 4 1+1+1=


Specific Element= Kuku 3
My List= dict_items([('RollNo', 10), ('Name', 'Kuku'), ('Class', 11), ('Age', 15)])
29. [['few', 'words']] ½*6=3
[]
False
['These', 'a', 'that', 'will']
['that', 'we', 'will', 'use']
['These', 'are', 'a', ['few', 'words'], 'that', 'we', 'will', 'use']
OR
125
s="HEALPS HEALS WITHOUT HURTING"
n=0
for i in s:
if i=="H":
n=n+1
print(n)
30. (iv) Both may be the victim of Cyber Crime because these are the common security 1+1+1=
answers a normal user sets and your system can be hacked by person 2 3
We should not do financial transaction using other’s computer because your
personal information may be revealed to person 1
(v) Person 2 is doing Ethical Hacking by asking personal information
(vi) Key Logger is a software/Hardware that records you key strokes.
SECTION : D
31. #students may use their own logic also. 4
L=list()
for i in range (10):
k=int(input("Enter a number :"))
L.append(k)
L.sort()
print ("List is ", L)
print ("The third largest number is :", L[-3])
- 1M for inputting 10 numbers to store in list
- 2M for method for finding third largest
- 1M for printing third largest

32.
a) Int 1*4=4
b) 20,30
c) 24.0
d) 10*20*30@
SECTION : E
33. (k) [11,14,18,10,15] ½ x10
(l) [‘P’, ‘Y’, ‘T’, ‘H’, ‘O’, ‘N’] =5
(m) [12,11,14,18,10,15]
(n) [10, 11, 12, 14, 15, 18]
(o) [10, 11, 12, 15, 18]
(p) [10, 11, 12, 15, 18, 5]
(q) 'N'
(r) [10, 11, 12, 15, 18, 5, 'P', 'Y', 'T', 'H', 'O']
(s) [10, 11, 12, 15, 18, 5, 12, 16, 18]
(t) [10, 11, 12, 15, 18, 5, 12, 16, 18, 10, 11, 12, 15, 18, 5, 12, 16, 18]
34. dt={“Apple”:50, “Orange”:40, “Banana”:30 , “Mango”:80} 1*5=5
Statement 1= 4
Statement 2 = dict_keys(['Apple', 'Orange', 'Banana', 'Mango'])
Statement 3= dict_items([('Apple', 50), ('Orange', 40), ('Banana', 30), ('Mango', 80)])
Statement 4= ('Mango', 80)
Statement5=30
35. a)Cyber Safety refers to the safe and responsible use of Internet to ensure safety and 1+2+2=
security of personal information and not posing threat to anyone else’s information. 5

b) Some common threats are:


Viruses, Spyware, Adware, Spamming, PC Intrusion (Denial of service, Sweeping,
Password guessing), Phishing
c) A strong password may be created mixing an upper-case letter, a lower-case
126
letter, a digit and a special symbol and the password may be changed at a frequent
time. A good combination of these mixed letters makes a strong password and makes
difficult to crack it. A strong password makes our system safe and secure.

127
KENDRIYA VIDYALAYA SANGATHAN JAIPUR REGION
Class: XI Session: 2022-23 Computer Science (083)
Practice Paper-4 (Theory)
Maximum Marks: 70 Time Allowed: 3
hours

General Instructions:

• This question paper contains five sections, Section A to E.


• All questions are compulsory.
• Section A have 18 questions carrying 01 mark each.
• Section B has 07 Very Short Answer type questions carrying 02 marks each.
• Section C has 05 Short Answer type questions carrying 03 marks each.
• Section D has 03 Long Answer type questions carrying 05 marks each.
• Section E has 02 questions carrying 04 marks each. One internal choice
is given in Q35 against part c only.
• All programming questions are to be answered using Python Language only.

SECTION A
Q.1 MICR stands for?
(a)Maganetic Ink Character Reader (b) Maganetic Ink Code Reader
(c) Maganetic Ink Caser Reader (d) Maganetic Ink Computer Reader

Q.2 Which of the following is not an example of system software?


(a) Language Translator (b)Utility Software
(c) Communication Software (d)Word Processors

Q.3 A gate gives the output as 1 only if all the inputs signals are 1.
(a) AND (b) OR
(c)EXOR (d) NOR

Q.4 Which one of the following is the correct extension of the Python file?
(a) .py (b) .python
(c) .p (d) None of these

Q.5 Which of the following is not a keyword in Python language?


(a) for (b)if
(c) try (d) sum

Q.6 Which of the following operators is the correct option for calculating ab ?
(a) a ^ b (b) a**b
(c) a ^ ^ b (d) a ^ * b

Q.7 What is data type of L if L= [ 1,’Python’,2.5]


(a) List (b) String
(c)Dictionary (d) Tuple

Q.8 Which of the following is an invalid statement?

128
(a) a,b,c = 1000 (b) a,b,c = 1000 2000 3000
(c) a,b,c = 1000, 2000, 3000 (d) a_b_c = 1000

Q.9 Operators with the same precedence (except power operator) are evaluated inwhich
manner?
(a) Left to Right (b) Right to Left
(d) Can’t say (d) None of the mentioned

Q.10 IT Act of the Indian Parliament notified on ___________


(i) 17 January 2001 (ii) 25 October 2002
(iii)17 October 2000 (iv) 25 April 2000

Q.11 What can happen when you give your personal data (email, address, photos
you post…) in exchange for free apps and services?

(i) Nothing can happen. Your data is not allowed to be passed on to anyone
(ii) It isn’t really used, it’s just compulsory to ask for that information
(iii) When giving your email you’re automatically entered in a lottery where you
can win something
(iv) Everything you do online is of value and is used by companies looking to
target their advertising

Q.12 What is the most important activity in system hacking?


(i) Information gathering (ii) Cracking passwords
(iii) Escalating privileges (iv) Covering tracks

Q.13 Find the output of the following


word=”green vegetables”
print(word.find(‘veg’,2)
(a) 8 (b) 6
(c)10 (d) 12

Q.14 Does Python supports Exit-Controlled Loop?


(a) Yes (b) No
(c) May be (d) Don’t Know

Q.15 Predict the output of the following code:


x,y=2,4
if(x+y= =10):
print(“true”)
else:
print(“false”)
(a) true (b)false (c) no output (d)none

Q.16 What keyword you use to add an alternative condition to an if statement?


(a) else if (b) false (c) elif (d) None of the above

Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
129
(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

Q.17 Choose correct option:


D1= {’A’:’CS’, ‘B’:’IP’}
D2= { ’B’:’IP’, ‘A’:’CS’}
A: Output of print (D1==D2) is True.
R: Dictionary is a collection of key-value pairs. It is not a sequence.
(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

Q.18 Choose correct option:


S1=’python’
S1[0] =S1[0].upper( )
A: Above code will generate error.
R: String is mutable by nature.
(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

SECTION B

Q.19 What will be the output of the following Python code? >
>>>a,b=6,7
>>>a,b=b,a
>>>a,b
a) (6,7) b) Invalid syntax c) (7,6) d) Nothing is printed

Q.20 What is the data type of (1)?

a) Tuple b) Integer c) List d) Both tuple and integer

OR

What will be the output of the following Python code?


>> a=(1,2)
>>> b=(3,4)
>>> c=a+b
>>> c

(a) (4,6) (b) (1,2,3,4 )


(c) Error as tuples are immutable (d) None

Q.21 Given is a Python string declaration:


(a) myexam="@@CBSE Examination 2022@@"

Write the output of: print(myexam[6:12])


130
(b) Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())

Q.22 Define the term:


(a) Cyber bullying
(b) Cyber Stalking

Q.23 What measures should one take to avoid and maintain confidentiality of
personal information?

Q.24 Predict the output of the Python code given below:


def Vari(C1,C2):
if C1>C2:
return C1-C2
else:
return C2-C1

NUMBER= [15,12,19,26,18]
for CNT in range (3,0,-1):
A=NUMBER[CNT]
B=NUMBER[CNT-1]
print(Vari(A,B),'#', end=' ')

OR

Predict the output of the Python code given below:

KV = (11, 22, 33, 44, 55 ,66)


NVS =list(KV)new_list = []
for i in KV:
if i%2==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)

Q.25 Write a program to check a number whether it is even or odd. ?

SECTION C
Q.26 Write the truth table for given Boolean expression:
𝐸 = 𝑋. 𝑌(𝑌. 𝑍 + 𝑍)

Q.27 Find the error in the following code:


(a) y = x +5 (b) a=input(“Value: “) (c) print(x = y = 5)
print(x, y) b = a/2
print( a, b)

131
Q.28 Write a program to input temperature in Celsius and convert it into
Fahrenheit using the formula: F = C * 9 / 5 + 32

Q.29 Write a program to input names of n students and store them in a tuple.
Also, input a name from the user and find if this student is present in the
tuple or not.

Q.30 What are common gender and disability issues faced while teaching /
using computers in class rooms.
SECTION D

Q.31 Write a program to calculate digits and letters in a string.


Q.32 Convert the following number system.
( 10011111 )2 = ( ? )16 = ( ? )10 = ( ? )8

SECTION E
Q.33 Mr. Rajesh Kumar is a teacher in a school. He is doing his work manually.
As a python learner solve the problems of Rajesh Kumar by python programs:

(i) Create a dictionary student which ask Student roll number, Name and Marks of
students and display them in tabular format.
(ii) Display the names of those students who have secured marks more than 75.
(iii) Delete those students who have secured less than 50 marks

Q.34 Write the solution for the following problem:


(a) How is math. ceil (89.7) different from math. floor (89.7)?
(b)Write a Python program to generate random number between 0 and 9.

Q.35 Explain the following:

(a)What are cookies? How are they used by websites to track you?
(b)What is confidentiality of information? How do you ensure it
(c)What procedure can be carried out for proper E-Waste disposal.

******************************

132
Practice Paper 4 Answer Key (2022-23)
Computer Science (083) Class: XI
Q Section-A (attempt 8 out of 10) Mark
No. s
1. Magnetic Ink Character Reader (1)
2. Word Processors (1)
3. AND (1)
4. .py (1)
5. Sum (1)
6. a**b (1)
7. List (1)
8. a,b,c= 1000 2000 3000 (1)
9. Left to Right (1)
10. 17 October 2000 (1)
11. Everything you do online is of value and is used by companies looking to (1)
target their advertising
12. Cracking passwords (1)
13. 8 (1)
14. Yes (1)
15. False (1)
16. Elif (1)
17. Both A and R are true and R is the correct explanation for A (1)
18. A is True but R is False (1)
19. (7,6) (2)
20. Integer (2)
Or
(1,2,3,4 )
21. Exami (2)
Or
dict_items([('name', 'Aman'), ('age', 27), ('address', 'Delhi')])
22. Cyber Bullying: use of internet to harm or frighten another person, (2)
especially by sending them unpleasant messages.
Cyber Stalking: Follow the target online by joining the same groups and
forums. Send threatening, controlling, or lewd messages or emails to the
target
23. Restrict access to data. ...Encrypt your data. ...Implement a confidentiality (2)
policy. ...Implement a data retention policy. ...
Develop and implement a cybersecurity program. ...Take physical security
measures. ...Non-disclosure agreements.

24. 7#7#3# (2)

Or

133
(22,44,66)
25. num=int(input(“Enter a Number”)) (2)
if ( num% 2)==0:
print(“Even Number”)
else:
print(“Odd Number”)
26. X Y Z X YZ (YZ+Z XY(YZ+ (3)
Y ) Z)
0 0 0 0 0 0 0
0 0 1 0 0 1 0
0 1 0 0 0 0 0
0 1 1 0 1 1 0
1 0 0 0 0 0 0
1 0 1 0 0 1 0
1 1 0 1 0 0 0
1 1 1 1 1 1 1
27. (a) x is not defined (3)

(b) unsupported operand type(s) for /: 'str' and 'int'

(c) invalid syntax


28. celsius = float(input("Enter temperature in celsius: ")) (3)
fahrenheit = (celsius * 9/5) + 32
print('%.2f Celsius is: %0.2f Fahrenheit' %(celsius, fahrenheit))

29. n = int(input("Enter the number of students: ")) (3)


list1 = [ ]
for i in range(n):
name = input()
list1.append(name)
tuple1 = tuple(list1)
findName = input("Enter name to find: ")
for item in tuple1:
if item==findName:
print("Name found")
else:
print("Name not found")
30. there can be one or more disabilities: (3)
(i) Locomotor disabilities – Severe deformities, polio, leprosy, cerebral palsy.
(ii) Hearing and speech disabilities – Hearing impairment, speech aphasia.
(iii) Cognitive impairment – Specific learning deficits (Dyslexia, Dyscalculia).
Down’s syndrome, Autism.
(iv) Vision impairment. low vision, blindness.
31. String =”python1234” (4)
total_digits = 0
total_letters = 0
for s in string:
if s.isnumeric():
total_digits += 1
else:
total_letters += 1
print(“Total Letters found :-“,total_letters)
print(“total digits found:-“,total_digits)
32. 9F16=15910=2378 (4)

134
33. (i) (5)
n = int(input("Enter number of students: "))
result = {}
for i in range(n):
print("Enter Details of student No.", i+1)
rno = int(input("Roll No: "))
name = input("Name: ")
marks = int(input("Marks: "))
result[rno] = [name, marks]
print(result)
(ii)
for student in result:
if result[student][1] > 75:
print(result[student][0])
(iii)
for student in result:
if result[student][1] < 50:
del result[student][0])
34. (a) math. ceil(89.7)' will return 90 whereas 'math. floor(89.7)' will return (5)
89.

(b) import random


for i in range(10):

print(random.randrange(10))
35. (a) Cookies are text files with small pieces of data that are used to (5)
identify your computer as you use a computer network. Specific cookies
known as HTTP cookies are used to identify specific users and improve
your web browsing experience.

(b) Data confidentiality is about protecting data against unintentional, unlawful,


or unauthorized access, disclosure, or theft.We can ensure it by Shared
documents in a secure way,Use anti-virus software, Install a firewall,
Password-protect important files and systems. ...
(c)
Recycling: complete segregation of parts and materials that is then used to
build new electronic products.
Refurbishing: reuse of the working, good quality products to replace parts and
extend the life of other electronic equipment.
Land filling. This is the most common method of electronic waste
disposal. ...
Incineration. A controlled combustion process wherein e-waste is burned
in an incinerator unit.

135
KENDRIYA VIDYALAYA SANGATHAN JAIPUR REGION
Class: XI Session: 2022-23 Computer Science (083)
Practice Paper-5 (Theory)
Maximum Marks: 70 Time : 3 hours

General Instructions:

• This question paper contains five sections, Section A to E.


• All questions are compulsory.
• Section A have 18 questions carrying 01 mark each.
• Section B has 07 Very Short Answer type questions carrying 02 marks each.
• Section C has 05 Short Answer type questions carrying 03 marks each.
• Section D has 03 Long Answer type questions carrying 05 marks each.
• Section E has 02 questions carrying 04 marks each. One internal choice
isgiven in Q35 against part c only.
• All programming questions are to be answered using Python Language only.
SECTION A
1. OCR stands for? 1
(a) (a) Optical Character Reader (b) Optical Code Reader
(c) Optical Character Recognition (d) Optical Computer Reader
2. Which one of the following is not input device? 1
b) Keyboard (b) Mouse
c) Speaker (d) Scanner
3. Which gate returns true if both inputs are similar otherwise false 1
(a) AND (b) OR
(c) EXOR (d) NOR
4. What is the output of the expression , 5*1**5 1
(a) 125 (b) 25
(c) 5 (d) 1
5. Which character is used in Python to make a single line comment? 1
(a) / (b) //
(c) * (d) #
6. Which of the following is an invalid identifier? 1
(a) my_file (b) myfile13
c) My.File (d) Myfile
7. if L= [ ‘My Score’,95.2, 2022], which data type in Python is used? 1
a. List
b. String
c. Dictionary
d. Tuple
8. Which statement is true from following- 1
a. List is immutable & Tuple is mutable
b. List is mutable & Tuple is immutable
c. Both are mutable
d. Both are immutable

136
9. Which type of value is returned by the input() function. 1
a. integer
b. float
c. string
d. no value

10. OSI stands for ___________ 1


a) Open Source Index
b) Open Source Image
c) Open Source Instant
d) Open Source Initiative
11. Pooja’s classmate sent her a message on Facebook “You are a Loser”. Pooja is 1
victim of :-
a) Phishing
b) Trolling
c) Cyber-bullying
d) Criticis
12. Which is not a cyber crime? 1
(i) Tracking
(ii)Phishing
(iii) Ransomware
(iv) Hacking
13. Find the output of the following 1
str=”My School”
print(str.find(‘School’,2)
(d) 4
(e) 3
(f) 7
(d) 9
14. Does Python support any empty or null statement? 1

a. Yes
b. No
c. May be
d. Don’t Know
15. Predict the output of the following code: 1
Var=5
if Var>4 OR VAR<6 AND Var==10
print(“Good”)
else:
print(“Not Good”)

a. Good b . Not Good c. no output d. none


16. Which statement is used for checking multiple conditions in Python? 1

a. else if b. if…elif c. switch d. None of the above

137
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
(n) Both A and R are true and R is not the correct explanation for A
(o) A is True but R is False
(p) A is false but R is True
17. Choose correct option : 1
Dic1={ ’A’:’CS’, ‘B’:’IP’}
Dic2={ ’B’:’IP’, ‘A’:’CS’}
Statement 1: Output of print (Dic1==Dic2) is True.
Statement 2: Dictionary is a collection of key-value pairs. It is not a
sequence.

18. Choose correct option: 1


Str1=’python’
Str1[0] =Str1[0].upper()
Statement 1: Above code will generate error.
Statement 2: String is mutable by nature.

SECTION B
19. What will be the output of the following Python code? 2
>>>x,y=5,10
>>>x,y=y,x
>>>x,y
20. What will be the output of the following Python code? 2
>>> a=’OK-BYE’
>>> a*=2
>>> a
21. (a) Given is a Python string declaration: 2
exam="##KVS Examination 2022##"
Write the output of: print(exam[2:6])
(b) Write the output of the code given below:
Dict1 = {"name": "RAM", "age": 26}
Dict1['age'] = 27
Dict1['address'] = "JAIPUR"
print(Dict1.items())
22. Define the term : 2
(a) Hackers
(b) Crackers
23. Name the online activities which would help you detect that your friend is 2
being cyber bulled.
24. Predict the output of the Python code given below: 2

(a) X=range(1,10,2)
for i in X:
print(i)

(b) X,Y=17,4
print (X//Y)
print(X/Y)

138
25. Write a Python program to input a number print its Square if it is odd, 2
otherwise print its square root. (use import math function)
SECTION C
26. Draw logic circuit for given Boolean expression: 3
F(A,B,C) = A’B+AB+B’C
27. Find the error in the following code and rewrite corrected code: 3
25=Val
for I in the range(0,Val)
if I%2==0:
print( I+1)
Else:
print (I‐1
28. Write a python program to print a sum of series up to 10 integers using for 3
loop.
29. Write a program to input a list of numbers and find the smallest and largest 3
number from the list.
30. What are the benefits of e-waste recycling? 3
SECTION D
31. Write a python program to accept a string and replace all space by ‘$’ symbol. 4
32. Convert the following number system. 4
(a) (11011.10 )2 into ()10
(b) (11100.1010)2 in to ()16
(c) (10AF)16 into ()2
(d) (A42)16 into ()8
SECTION E
33. Write a program to create a dictionary to input total number of sections and 5
class teacher’s name of a class 11 and display all information on the output
screen.
34. Which string method is used to implement the following: 5
a. To count the number of characters in the string
b. To change the first character of the string in capital letter
c. To change lowercase to uppercase letter
d. To check whether the given character is letter or a number
e. To replace all the occurrences of the old string with the new string.
35. Explain the following: 5
Open-Source Software and Proprietary Software
OR
Active and Passive digital footprint

******************************

139
KENDRIYA VIDYALAYA SANGATHAN JAIPUR REGION
Class: XI Session: 2022-23 Computer Science (083)
Answer Key Practice Paper-5 (Theory)

SECTION A
1. (c) Optical Character Recognition 1
2. c) Speaker 1
3. (d) NOR 1
4. (c) 5 1
5. (d) # 1
6. (c) My.File 1
7. List 1
8. b. List is mutable & Tuple is immutable 1
9. String 1
10. d) Open Source Initiative 1
11. Cyber-bullying 1
12. (i) Tracking 1
13. b) 3 1
14. Yes 1
15. A. Good 1
16. b. if…elif 1
17. (a) Both A and R are true and R is the correct explanation for A 1
18. ( C) A is True but R is False 1
SECTION B
19. c) (10,5) 2
20. c) OK-BYEOK-BYE 2
21. a) KVS 2
B)
dict_items([('name', 'RAM'), ('age', 27), ('address', JAIPUR')])
22. Hackers and Crackers : Hackers are most often programmers. Hackers are 2
people who hack devices and systems with good intentions. They might hack a
system for a specified purpose or for obtaining more knowledge out of it.
Crackers: Crackers are people who hack a system by breaking into it and
violating it with some bad intentions. They may hack a system remotely for
stealing the contained data or for harming it permanently. Crackers can easily
be identified because their actions are malicious.
1 mark each for explain the terms
23. Cyberbullying can include: 2
Sending mean texts or IMs to someone
Pranking someone’s cell phone
Hacking into someone’s gaming or social networking profile
Being rude or mean to someone in an online game
Spreading secrets or rumours about people online
Pretending to be someone else to spread hurtful messages online
1 mark each for at least two activities

140
24. Predict the output of the Python code given below: 2
1,3,5,7,9
4
4.25
1 mark for each correct output
25. #program to input a number print its square if it is odd otherwise print its 2
square root.

import math
num=int(input("enter a number : "))
if (num%2!=0):
print("The given number",num, "is odd so its square is :",num*num)
else:
print ("The given number",num, "is even so its square root is :", math.sqrt (num))
2 mark for correct python code
SECTION C
26. Logic circuit for given Boolean expression: 3

3 mark for correct logic circuit


27. Find the error in the following code and rewrite corrected code: 3
Val = 25 #Error 1
for I in range(0,Val): #Error 2
if I%2==0:
print( I+1)
else: #Error 3
print (I‐1)
1 mark for each corrected error
28. #program to print a series and sum of series upto 10 integers using for loop. 3
sum=0
for i in range (1,11):
print (i)
sum=sum+i
print("sum of series is " ,sum)
3 mark for correct python code
29. mylist=[] 3
num=int(input("how many elements to be entered: "))
for i in range(num):
item=int(input("enter elements : "))
mylist.append(item)
print("Largest element in the list is ", max(mylist))
print("Smallest element in the list is ", min(mylist))

141
output:
how many elements to be entered: 5
enter elements : 1
enter elements : 2
enter elements : 5
enter elements : 4
enter elements : 3
Largest element in the list is 5
Smallest element in the list is 1

3 mark for correct python code

30. (i) Protects public health and water quality 3


(ii) Allow for recovery of valuable precious metals.
(iii) Save landfill space
(or any other relevant point 1 mark for each correct line)

SECTION D
31. # python program to accept a string and replace all space by ‘$’ symbol. 4

str=input("enter a string :")


str1=" "
for i in str:
if i.isspace():
str1=str1+'$'
else:
str1=str1+i
print("The replaced string is:", str1)

output:
enter a string :I love my india
The replaced string is: I$love$my$india
3 mark for correct python code and 1 mark for output
32. 27.50 4
1C.A
0001000010101111
5102

1 mark for each correct conversion


SECTION E
33. classxi = dict () 5
n = int(input("Enter total number of section in xi class"))
i=1
while i <= n :
a = input ("enter section :")
b = input ("enter class teacher name :")
classxi[a]= b
i = i+1
print ("Class", "\t", "Section","\t", "Teacher Name")
for i in classxi :
print ("XI", "\t", i, "\t", classxi[i])

output:
142
Enter total number of section in xi class2
enter section :Science
enter class teacher name :Sunil
enter section :Humanities
enter class teacher name :Jyoti
Class Section Teacher Name
XI Science Sunil
XI Huminities Jyoti

3 mark for correct python code and 2 mark for output and documentation.
34. a. len(str) 5
b. str.capitalize( )
c. str.upper( )
d. ch.isalnum( )
e. str.replace()

1 mark for each correct string function

35. Open Software and Proprietary Software 5


Open source software (OSS) is software that is distributed with its source code,
making it available for use, modification, and distribution with its original rights.

Proprietary software is any software that is copyrighted and bears limits against
use, distribution and modification that are imposed by its publisher, vendor or
developer. Proprietary software remains the property of its owner/creator and is
used by end-users/organizations under predefined conditions.

OR

Active and Passive Digital Footprint


Active digital footprints are created when a user, for the purpose of sharing
information about oneself by means of websites or social media, deliberately. An
"active digital footprint" includes data that you intentionally submit online. Sending
an email contributes to your active digital footprint, since you expect the data be
seen and/or saved by another person. The more email you send, the more your
digital footprint grows.

A passive digital footprint is created when data is collected without the owner
knowing. A more personal aspect of your passive digital footprint is your search
history, which is saved by some search engines while you are logged in.

21/2 mark for each correct definition

******************************

143

You might also like