0% found this document useful (0 votes)
19 views70 pages

Computer Systems Overview and Functions

The Teacher's Manual for Computer Science with Python–XI covers fundamental concepts of computer systems and organization, including the roles of the CPU, memory types, and operating systems. It explains the relationship between hardware and software, categorizes software types, and details input and output devices. Additionally, it provides insights into memory units, storage devices, and the basic architecture of a computer.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views70 pages

Computer Systems Overview and Functions

The Teacher's Manual for Computer Science with Python–XI covers fundamental concepts of computer systems and organization, including the roles of the CPU, memory types, and operating systems. It explains the relationship between hardware and software, categorizes software types, and details input and output devices. Additionally, it provides insights into memory units, storage devices, and the basic architecture of a computer.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Teacher’s Manual

Teacher’s Manual
Computer Science with Python–XI

Chapter 1: Computer Systems and Organization


1. A computer is an electronic device that takes input from the user in the form of data and instructions,
processes this data and produces the result (output) as information.
2. Arithmetic Logic Unit (ALU) performs the arithmetic (+, –, *, /) and logical (AND, OR, NOT, XOR)
operations on data. It receives input data from the memory, performs specific operations (addition,
subtraction, etc.) or logical operations and the result is returned to the memory.
3. Control Unit (CU) controls the flow of data from input devices to memory and from memory to output
devices. It controls and guides the interpretation, flow and manipulation of all data and information.
It does not process the data; instead, it sends control signals to ALU and memory for carrying out the
required operations.
4. Here are some examples of hardware components commonly found in computer:
(a) Central Processing Unit (CPU): The ‘brain’ of the computer that processes data and instructions
(b) Random Access Memory (RAM): A type of memory that temporarily stores data and instructions
for the CPU to access quickly
(c) Hard Disk Drive (HDD): A storage device that stores data and programs
(d) Motherboard: A circuit board that connects all computer components
(e) VDU (Visual Display Unit): A monitor or screen that displays the output of the computer
(f) Keyboard: An input device that allows the user to input text and commands
(g) Mouse: An input device that allows the user to control and navigate the cursor
5. An Operating System (OS) is a software that manages and controls a computer system’s hardware and
software resources. It provides an interface between the user and the computer system and helps in
executing user programs.
The different types of operating systems are:
(a) Single User Operating Systems: These are designed to be used by only one user at a time. For
example, Microsoft Windows, MacOS and Linux.
(b) Multi-User Operating Systems: These allow multiple users to access a computer simultaneously
and share resources efficiently. For example, Unix, Linux, etc.
(c) Distributed Operating Systems: These manage multiple interconnected computers working
together as a single system. For example, Google Chrome’s OS, Linux, etc.
(d) Mobile Operating Systems: These are designed for smartphones and tablets. For example,
Android (Google), iOS (Apple), etc.
6. Without hardware, the software cannot be used. Software needs hardware to perform functions. For
example, a software application like Microsoft Word needs the hardware components of a computer,
such as the CPU, RAM and hard drive, to run and operate. Without these hardware components, the
software cannot function.
Similarly, hardware is of no use without software. Hardware needs software to control and manage
its operations. For example, the hardware components of a printer, such as the print head and ink
cartridges, need software drivers to operate and communicate with the computer. Without the software
drivers, the printer cannot function.
7. The software can be broadly categorized into four types depending on their functions and user
requirement:
(a) System Software: System software manages and controls the hardware and other software
components of a computer system. Examples include operating systems like Windows, macOS and
Linux.
2 Teacher’s Manual Computer Science with Python–XI

(b) Application Software: Application software is designed to perform specific tasks or functions,
such as word processing, accounting or graphics. Examples include Microsoft Office, Adobe
Photoshop and QuickBooks.
(c) Utility Software: Utility software is used to maintain and optimize the performance of a computer
system. Examples include antivirus software, disk cleaners and file compression tools like WinZip.
(d) Programming Tools: Programming software is used to write, debug and develop software
programs. Examples include compilers, debuggers and Integrated Development Environments
(IDE) like Visual Studio and Eclipse.
8. An operating system (OS) is a program that acts as an interface between the user and the hardware of
the computer. It helps to manage the resources of the computer and optimize its performance. An OS is
the first program to be executed on a computer after the BIOS (Basic Input Output System). It performs
all basic tasks such as identifying basic input/output devices, accepting input from the input devices,
sending results to the output devices, keeping track of files and directories on the disk and controlling
other peripheral devices such as disk drives and printers.
Two popular operating systems are:
(i) Microsoft Windows
(ii) Apple macOS

9. UNITS OF MEMORY
S. No. Unit Description
1. Binary Digit 1 Bit
2. Byte 1 Byte = 8 Bits
3. Kilobyte (KB) 1 KB = 1024 Bytes
4. Megabyte (MB) 1 MB = 1024 KB
5. Gigabyte (GB) 1 GB = 1024 MB
6. Terabyte (TB) 1 TB = 1024 GB
7. Petabyte (PB) 1 PB = 1024 TB
8. Exabyte (EB) 1 EB =1024 PB
9. Zettabyte (ZB) 1 ZB = 1024 EB
10. Yottabyte (YB) 1 YB = 1024 ZB
11. Brontobyte (BB) 1BB = 1024 YB
12. Geopbyte 1 Geop Byte = 1024 BB
10. (a) and (b) Compiler & assembler are programming tools used for converting source code into machine code.
(c) Ubuntu is an operating system which falls under the category of system software.
(d) Text Editor is an application software which falls under the category of application software and is
used for editing plain text files.
[Link] devices are hardware components used in computer systems to store data and instructions
either temporarily or permanently.
The memory can be both primary and secondary depending upon its location in the computer system.
The primary memory also termed main memory, is directly accessible to the CPU since all the work is
done in the RAM (primary memory). Secondary memory, also known as auxiliary memory or auxiliary
storage, includes magnetic storage devices such as hard disk drives, magnetic drums, etc.
(a) Random Access Memory (RAM): It is a read/write memory as it is possible to both read from
and write to a location within RAM. It is used for primary storage in computers to hold active
information of data and instructions. The RAM is a volatile memory as it does not store data and
instructions permanently and loses its contents when the power is switched off or interrupted.
RAM provides faster access than secondary memory with less memory access time.
Teacher’s Manual Computer Science with Python–XI 3

(b) Read-Only Memory (ROM): It is the memory where the data and instructions are placed at
the time of its manufacturing and can’t be changed thereafter. It is a permanent and non-volatile
memory as it does not lose its contents when the power is switched off or interrupted. ROM is slower
than RAM and is used to hold certain essential instructions to check basic hardware components
such as booting, procedures to load the operating system and frequently needed functions.
12. The output unit is formed by the output devices attached to the computer. Output devices produce the
output generated by the CPU in human-readable form. These devices can also be used to store the result
for further use.
Here are some examples of output devices:
(a) Monitor: A visual display unit that shows the output in the form of text, images, and videos
(b) Printer: An output device that prints text or graphics on paper
(c) Speaker: An audio output device that produces sound
(d) Plotter: A specialized output device that produces high-quality graphics and designs on paper
13. Impact printers are a type of printer that work by physically striking an inked ribbon against the paper
to create an image or text. They are often used in environments that require multipart forms or where
carbon copies are needed.
Here are some types of impact printers:
(a) Dot-matrix printers
(b) Daisy-wheel printers
(c) Line printers
14. A laser printer is a type of non-impact printer that uses laser technology to produce high-quality text
and graphics on paper. It works by using a laser beam to create an electrostatic image or pattern on a
photosensitive drum, which is then developed with toner particles and transferred onto paper. The toner
is then fused onto the paper with heat and pressure to create a permanent image.
15. A light pen is a pointing device that can be used to select anything on the computer screen by simply
pointing at it or drawing figures directly on the screen. It consists of a photocell mounted on a
pen-shaped tube called stylus. It is capable of sensing a position on the screen when its tip touches the
screen. Clicking is performed by pressing the pen on the screen. A light pen is mostly used by engineers,
architects or designers.
16. (a) ALU stands for Arithmetic Logic Unit.
(b) GUI stands for Graphical User Interface
17. Touch Screen is a type of display screen that allows interaction with a computer through a touch-sensitive
transparent panel covering the entire screen without any intermediate device. The touch screen uses a
technology that enables the user to touch the screen with their fingers to select objects. Touch screens
are mostly found in systems such as ATMs and mobile devices where the user needs to choose from a
given list. Such systems are also being used at shopping malls, amusement parks and airports.
18. Plotters are the output devices that are used for producing good-quality images and drawings. Unlike
printers, they support the printing of large-sized papers. They are mainly used in computer-aided
designing (CAD).
Here are some different types of plotters:
(a) Pen plotters
(b) Electrostatic plotters
(c) Inkjet plotters
(d) Thermal plotters
(e) Cutting plotters
4 Teacher’s Manual Computer Science with Python–XI

19. To check the size of RAM and HDD on a Windows computer, follow these steps:
(a) Right-click on the Windows Start button and select ‘System’.
(b) Under the ‘Device specifications’ section, see the amount of installed RAM.
(c) To check the size of the HDD, open File Explorer and navigate to ‘This PC’.
(d) Right-click on the HDD to check and select ‘Properties’.
(e) Under the ‘General’ tab, see the total capacity of the HDD in bytes.

Size Bytes Kilobytes (KB) Megabytes (MB) Gigabytes (GB)


RAM 8,589,934,592 8,388,608 8,192 8
HDD 1,099,511,627,776 1,073,741,824 1,048,576 1024
20. Some of the common secondary storage devices available at school or home are as follows:
(a) Hard Disk
(b) Blu-ray Disc (BD)
(c) Compact Disc (CD)
(d) DVD
(e) USB/Pen Drive
(f) Memory Cards
21. Microsoft Windows 11 and 10 operating systems are installed on computers at home or in school.
22. Here are the conversions of 2 MB, 3.7 GB, and 1.2 TB into bytes:
(a) 2 MB = 2,097,152 bytes
(b) 3.7 GB = 3,972844749 bytes
(c) 1.2 TB = 1,319,413,953,331.2 bytes
23.
(a) Operating system
(b) Interpreter
24. Type of memory needed to execute the following:
(a) To store data permanently – Hard Disk
(b) To execute the program – Random Access Memory (RAM)
(c) To store the instructions which cannot be overwritten – Read Only Memory (ROM)
25. Here are the differences between an interpreter and a compiler on the given parameters:
(a) Memory requirement during translation: An interpreter usually requires less memory during
translation as it processes the code line by line. It reads a single line of code from the source
program, converts it into machine code, executes it and then moves to the next line. On the other
hand, a compiler requires more memory during translation as it reads and converts the entire
source program into machine code before execution.
(b) Memory requirement after translation: An interpreter generally requires less memory after
translation because it does not create a separate executable file. It directly executes the source
program line by line. On the other hand, a compiler generates a separate executable file which
requires more memory for storage and execution.
(c) Number of instructions translated: An interpreter translates and executes one statement at a
time, so it translates fewer instructions at a time. A compiler translates the entire program in one
go; hence it translates more instructions than an interpreter.
26. The major difference between optical and magnetic discs is in the way they store data.
Optical discs use a laser to read and write data, while magnetic disks use magnetic fields to store and
retrieve data. The laser on an optical disc reads tiny bumps and valleys on the surface of the disc that
represent binary code. The most common types of optical discs are CD, DVD and Blu-ray discs.
Magnetic disks, on the other hand, use magnetic fields to store data on a spinning disk. The read/write
head on a magnetic disk writes data to the disk by magnetizing tiny areas of the disk surface in specific
patterns. The most common types of magnetic disks are hard disk drives (HDDs).
Teacher’s Manual Computer Science with Python–XI 5

27. Compact Disc (CD) is a thin optical disc which is commonly used to store audio and video data. The
capacity of a standard 120 mm CD is 700 MB. Originally, CD-ROM drives had a transfer rate of only
150 KB/s which was very low. The latest CD-ROM drives can transfer up to 72x, i.e., 10,800 KB/sec.
Digital Versatile Disc or Digital Video Disc is an optical disc storage device. It can be recorded on one or
both sides. Its capacity may range from 4.7 GB to 17 GB.
28. The statement ‘Functioning of a computer is similar to the way the human brain functions’ suggests that
there are similarities between the way a computer processes information and the way the human brain
works.
Computers and human brains both receive and process information through a series of interconnected
pathways. In the case of computers, this is done through electrical signals that travel through circuits
and wires while in the case of the human brain, it is done through neural pathways and connections
between neurons.
Both computers and human brains can store and retrieve information. In the case of computers, this
is done through hard drives and other storage devices while in the case of the human brain, it is done
through the process of memory.
29. The basic architecture of a computer consists of the following components:
(a) Central Processing Unit (CPU): The CPU is the ‘brain’ of the computer and is responsible for
executing instructions. It consists of an arithmetic and logic unit (ALU), a control unit (CU), and
registers.
(b) Memory: The memory is used to store data and instructions that the CPU needs to access quickly.
There are two types of memory – primary memory (RAM) and secondary memory (hard disk, SSD).
(c) Input Devices: Input devices such as a keyboard, mouse or touchpad, allow users to interact with
the computer by providing input.
(d) Output Devices: Output devices such as a monitor or printer, display or print the results of the
computer’s processing.
(e) Storage devices: Storage devices, such as hard disks, SSDs or USB drives are used to store data
and programs.
30. An input unit is a device that allows the user to input data or instructions into a computer. This data can
be in various forms such as text, images, audio or video. Examples of input devices include a keyboard,
mouse, touchpad, scanner, microphone and camera.
The significance of an input unit is that it enables the user to interact with the computer and provide
it with the necessary instructions and data. Without an input unit, the computer would not be able to
receive any input from the user making it impossible to perform any useful task.
31. Central Processing Unit (CPU) is the control centre or brain of a computer. It guides, directs, controls and
governs all the processing that takes place inside the computer. The CPU consists of three components—
ALU, CU and Registers.
(a) Arithmetic Logic Unit (ALU): All calculations and comparisons are made in this unit. The ALU
performs the arithmetic (+, –, *, /) and logical (AND, OR, NOT, XOR) operations.
(b) Control Unit (CU): It controls the flow of data from input devices to memory and from memory
to output devices. It controls and guides the interpretation, flow and manipulation of all data and
information. It does not process the data; instead, it sends control signals to ALU and memory for
carrying out the required operations.
(c) Registers: Registers are high-speed temporary storage areas found in the CPU. Registers work
as per the instructions given by the control unit (CU), storing instructions and data, immediately
required for operation.
32. CU controls all the functions like input, output, storage and process. It instructs ALU which operation
is to be carried out. So, the control unit is referred to as the central controller of a computer.
6 Teacher’s Manual Computer Science with Python–XI

33. An Arithmetic and Logic Unit (ALU) in a computer works in coordination with other units, primarily the
control unit and the memory unit.
The ALU is responsible for performing arithmetic and logical operations such as addition, subtraction,
multiplication, division and comparison. However, it does not function independently as it needs
instructions and data from memory and the control unit directs its operations.
The control unit retrieves instructions from memory and sends them to the ALU to perform the
appropriate operation. After the operation is completed, the result is stored back in memory or sent to
the output unit for display. The control unit also directs the flow of data and instructions within the
computer and coordinates the operations of other components, including the ALU.
34. An output unit is a device that provides output from a computer system to the user in a human-readable
format. It works by receiving data or instructions from the computer and then displaying or printing it
in a format that the user can understand.
Output devices come in various forms, depending on the type of output they produce. Some examples of
output devices include:
(a) Monitor: A monitor displays visual output from a computer in the form of text, images or video.
(b) Printer: A printer produces hard copies of documents or images on paper.
(c) Speaker: A speaker produces audio output from a computer, such as music or sound effects.
35. Memory is a critical component of a computer system that plays a vital role in its functioning. It refers
to the storage space that a computer uses to store data and instructions for the CPU to access quickly.
The primary role of memory in the functioning of a computer is to provide fast and efficient access to
data and instructions that the CPU needs to perform its tasks. There are two main types of memory in
a computer:
(a) Random Access Memory (RAM)
(b) Read-Only Memory (ROM)
36. Here is a basic block diagram of a computer system:
CPU (Central Processing Unit)

Control Unit (CU)

Input Arithmetic Output


Unit Logic Unit (ALU) Unit

Registers

Main/Primary Secondary
Memory Memory

(a) Input Devices: These are devices that are used to input data or instructions into the computer
system. Examples of input devices include the keyboard, mouse, touchpad and scanner.
(b) Memory Unit: The memory unit is responsible for storing data and instructions that are currently
being used by the computer system. It is divided into two types—Random Access Memory (RAM)
and Read-Only Memory (ROM).
(c) Control Unit: The control unit is responsible for controlling the flow of data and instructions
within the computer system. It retrieves instructions from memory and directs the operations of
the Arithmetic and Logic Unit (ALU) and the memory unit.
(d) Arithmetic and Logic Unit (ALU): The ALU performs arithmetic and logical operations such as
addition, subtraction, multiplication, division and comparison. It operates on data retrieved from
memory or registers.
Teacher’s Manual Computer Science with Python–XI 7

(e) Registers: Registers are high-speed memory locations that are used to store data temporarily
while the ALU operates on it.
(f) Output Devices: These are devices that are used to output data or information from the computer
system in a human-readable format. Examples of output devices include monitors, printers,
speakers and headphones.
37. Volatile memory is a type of computer memory that requires power to retain data. When power is
removed, the data stored in volatile memory is lost. The most common example of volatile memory is
Random Access Memory (RAM). RAM is used to temporarily store data and instructions that are actively
being used by the computer system. It provides fast access to data and instructions that the CPU needs
to perform its tasks. The main advantage of volatile memory is that it is very fast, but the disadvantage
is that it is temporary, and data cannot be stored in it permanently.
Non-volatile memory is a type of computer memory that can retain data even when power is removed.
This makes it ideal for storing data and instructions that need to be kept for a long time, such as
system programs or user data. Examples of non-volatile memory include Read-Only Memory (ROM),
flash memory and hard disk drives. Non-volatile memory is slower than volatile memory, but it can store
data permanently.
38. Primary storage devices are devices that are used to store data temporarily in a computer system.
The data stored in primary storage devices are directly accessible by the CPU and are used to hold the
instructions and data that are currently being used by the computer system.
Here are the types of primary storage devices:
(a) Random Access Memory (RAM)
(b) Read-Only Memory (ROM system)
(c) Cache Memory
39. A mouse is a pointing device with a roller at its base, used for moving pointer on a computer monitor.
It converts the movements of the user’s hand into a unique set of binary digits representing the position
of the mouse at a particular instant. When a user moves a mouse across a flat surface, the pointer moves
in the direction of the mouse’s movement.
The various types of mouse are:
(a) Mechanical Mouse
(b) Optical Mouse
(c) Laser Mouse
(d) Trackball Mouse
(e) Touchpad
(f) Wireless Mouse
40. A bar code is a collection or a sequence of lines of different heights and widths that are printed on various
types of products. The machine that reads these bar codes is called a bar code reader. It consists of a
light source, a lens, and a light sensor which translates optical impulses into electrical signals. Also, it
contains decoder circuitry which analyzes the bar code’s image data and sends the bar code’s content to
the scanner’s output port.
41. Inkjet Printer: An inkjet printer is the most common type of low-cost printer. It uses the technique of
spreading quickly dry ink on paper. The ink is stored in the form of cartridges of different colors (red,
green, black and yellow). These printers generate high-quality prints and are ideal for small offices and
homes.
LaserJet Printer: A laser printer is a type of non-impact printer that uses laser technology to produce
high quality text and graphics on paper. It works by using a laser beam to create an electrostatic image
or pattern on a photosensitive drum, which is then developed with toner particles and transferred onto
paper. The toner is then fused onto the paper with heat and pressure to create a permanent image.
8 Teacher’s Manual Computer Science with Python–XI

42. Plotters are the output devices that are used for producing good-quality images and drawings. Unlike
printers, they support the printing of large-sized papers. They are mainly used in Computer Aided
Design (CAD).
Benefits of using plotters are as follows:
(a) High Quality
(b) Large Format
(c) Versatility
(d) Durability
Limitations of using plotters are as follows:
(a) Expensive
(b) Slow
(c) Limited Colors
(d) Noise
43. Three types of input devices are:
(a) Keyboard: The most commonly used input device is the keyboard which takes the data in the form
of letters, digits and commands into the computer. A computer keyboard possesses additional keys
in contrast to a traditional typewriter, such as function keys, alphanumeric keys, direction keys
and other keys (special and lock keys).
(b) Biometric Sensor: It is an input device that is used to uniquely identify a person based on his
physical or behavioural traits. Biometric sensors can scan human characteristics such as eyes,
fingerprints, etc. It is commonly used to mark the attendance of employees/students in organizations/
institutions.
(c) Magnetic Ink Character Reader (MICR): MICR is a technology used in banking to detect the
numbers printed with magnetically charged ink at the bottom of bank cheques and convert them
into digital data. These digital numbers represent the bank account number, bank branch and
cheque number.
44. Visual Display Unit (VDU): It is the most common device for displaying the output of computer-
processed information. It displays information in the same way as it is seen on a television screen. The
monitor is also called Visual Display Terminal (VDT) or Visual Display Unit (VDU).
The different types of monitors are CRT (Cathode Ray Tube), LCD (Liquid Crystal Display), LED (Light
Emitting Diode) and OLED (Organic Light-Emitting Diode).
45. Impact Printer: There is a mechanical contact between the printer head and the paper.
Non-impact Printer: There is no mechanical contact between the printer head and paper.
46. (a) Light Pen: A light pen is an input device that allows the user to interact with a computer screen
by pointing to and selecting specific areas on the screen.
(b) CD-ROM: A CD-ROM (Compact Disc Read-Only Memory) is a storage device that uses laser
technology to read data stored on a compact disc. CD-ROMs can store up to 700 MB of data and are
commonly used to store software, music and other multimedia content.
(c) DVD: A DVD (Digital Versatile Disc) is a storage device similar to a CD-ROM but can store much
more data. DVDs can store up to 17 GB of data and are commonly used to store movies, television
shows and other multimedia content.
47. There are three main types of digital computers:
(a) Mainframe Computers: There are large, high-performance computers that are typically used by
large organizations for critical applications like transaction processing, financial processing and
data analysis. They have the high processing power, and large memory capacity, and are designed
to handle multiple users and tasks simultaneously.
Teacher’s Manual Computer Science with Python–XI 9

(b) Minicomputers: There are mid-sized computers that are smaller and less powerful than
mainframes but larger and more powerful than personal computers. They are often used for
scientific research, engineering and business applications that require significant processing
power and storage capacity. Minicomputers can support multiple users and are typically connected
to a network.
(c) Microcomputers: Microcomputers, also known as personal computers or PCs, are the most
common type of digital computer used today. They are small, affordable and designed for individual
use. They are typically used for general computing tasks like word processing, browsing the internet
and sending emails. Microcomputers come in different forms including desktops, laptops, tablets
and smartphones.
48. Secondary storage devices are used to store a large amount of data permanently which is not possible
by using the primary or main memory. The amount of data a disk can hold is defined as Disk Capacity,
which is measured in terms of bytes, kilobytes (KB), megabytes (MB) and so on.
The most common secondary storage devices are:
(a) Hard Disk: A hard disk is a non-volatile, high-capacity storage device ranging from 1 Gigabyte to
several Terabytes. It consists of solid rounded disks, packed on one another, made up of a magnetic
material and sealed inside a case. In a hard disk, data is stored on rotating magnetic disks called
platters. Each platter is divided into tracks and sectors.
(b) Blu-ray Disc (BD): A Blu-ray Disc is a high-capacity optical disk developed for recording, rewriting
and playing back high-definition video. It uses blue rays that permit large amounts of data to be
stored at a greater density. A single-layer disc can hold 25 GB while a dual-layer can hold 50 GB
of data. It was designed to supersede the DVD. Blu-ray discs support higher resolutions and more
advanced video and audio formats as compared to DVDs.
(c) Compact Disc (CD): It is a thin optical disc which is commonly used to store audio and video
data. The capacity of a standard 120 mm CD is 700 MB. Originally, CD-ROM drives had a transfer
rate of only 150 KB/s which was very low. The latest CD-ROM drives can transfer up to 72x, i.e.,
10,800 KB/sec.
(d) DVD: Digital Versatile Disc or Digital Video Disc is an optical disc storage device. Its capacity may
range from 4.7 GB to 17 GB.
(e) USB/Pen Drive: It is a small, portable memory device which can be plugged into a computer with USB
Port. A pen drive’s capacity is less than that of a hard disk but much higher than a floppy or CD. It is
more reliable also. Pen drives have a storage capacity of 2 GB, 4 GB, 8 GB, 16 GB, 32 GB and 64 GB.
(f) Memory Cards: These are data storage devices, also called Flash memory cards. They are mainly
used with digital cameras, computers, mobile phones, music players, video game consoles, etc. They
offer high recording ability with power-free storage. Memory cards come with a storage capacity of
8 GB, 16 GB, 32 GB, 64 GB and 128 GB.
49. Memory cards are small, portable storage devices used to store digital data, such as photos, videos
and music files. They are commonly used in cameras, smartphones, tablets and other portable devices.
Memory cards use flash memory technology to store data and come in various sizes, capacities and
formats.
The different types of memory cards are as follows.
(a) Secure Digital (SD) Cards: They are the most common type of memory card and come in different
sizes and capacities. They are commonly used in digital cameras, smartphones, tablets and other
portable devices. SD cards have a lock switch to prevent accidental deletion of data and they come
in different speed classes that determine their read and write speeds.
(b) MicroSD Cards: These are smaller than SD cards and are commonly used in smartphones,
tablets and other portable devices that have limited space. They are available in different sizes and
capacities and come in different speed classes.
(c) CompactFlash(CF) Cards: CF cards are larger than SD cards and were commonly used in
professional cameras before SD cards became more prevalent. They have a higher capacity and
faster transfer rates than SD cards but they are less common and more expensive.
10 Teacher’s Manual Computer Science with Python–XI

50. (a) Assembler: It is used to translate the program written in assembly language into machine code.
The input of the assembler is a source program that contains assembly language instructions. The
output generated by the assembler is the object code or machine code which is understandable by
the computer.
(b) Compiler: The language processor that translates the complete source program as a whole in
one go into machine code is called a compiler. The program translated into machine code is called
the object program. The source code is translated into object code successfully if it is free from
errors. If there are any errors in the source code, the compiler specifies the errors at the end of the
compilation with line numbers. The errors must be removed before the compiler can successfully
recompile the source code. Some of the examples are C and C++ compilers.
(c) Interpreter: The language processor that translates a single statement of source program into
machine code and executes it immediately before moving on to the next line is called an Interpreter.
If there is an error in the statement, the interpreter terminates its translating process at that
statement and displays an error message. Only after the removal of the error does the interpreter
move on to the next line for execution. Some of the languages that use interpreters are Python,
PHP, MATLAB, etc.
51. Secondary memory, also known as external memory, is a type of computer storage that is used to store
data and programs for long-term use. It is called ‘secondary’ because it is not directly accessible by the
CPU, unlike primary memory such as RAM. The need for secondary memory arises from several factors,
including:
(a) Storage capacity
(b) Non-volatility
(c) Portability
(d) Data backup
52. RAM (Random Access Memory) is a type of computer memory that is used to temporarily store data and
program instructions that the CPU (Central Processing Unit) needs to access quickly. RAM is a volatile
memory, meaning that its contents are lost when the computer is turned off.
The need for RAM arises from the fact that primary storage devices such as CPU caches and registers
have limited storage capacity, and accessing data from secondary storage devices such as hard disk
drives or solid-state drives is much slower than accessing data from RAM. Therefore, RAM provides a
fast and temporary storage solution for the data that the CPU needs to access frequently.
The main difference between RAM and ROM is that RAM is a temporary storage device used to store
data and program instructions that the CPU needs to access quickly, while ROM is a permanent storage
device used to store essential data and instructions that are required for the computer to boot up and
perform basic functions.
53. The software required to make a computer functional includes an operating system (OS).
An operating system is a type of system software that manages computer hardware and software resources
and provides common services for computer programs. The two primary services of an operating system
are:
(a) Resource Management: An operating system manages the computer hardware resources such
as CPU, memory, storage, and input/output devices, and ensures that they are used efficiently and
effectively by different computer programs.
(b) User Interface: An operating system provides a user interface that allows users to interact with
the computer and its applications. This can be in the form of a graphical user interface (GUI) or a
command-line interface (CLI), depending on the operating system.
Teacher’s Manual Computer Science with Python–XI 11

Chapter 2: Data Representation and Boolean Logic


1. Convert the decimal number into a binary number.
(a) 52 – 110100
(b) 44 – 101100
(c) 25.80 – 11001.1100110011
(d) 62.325 – 111110.0101001100
2. Convert the decimal number into an octal number.
(a) 911 – 1617
(b) 540 – 0344
(c) 61 – 75
(d) 132 – 204
3. Convert the decimal number into a hexadecimal number.
(a) 132 – 84
(b) 3619 – E23
(c) 206 – CE
(d) 752 – 2F0
4. Convert binary number into a decimal number.
(a) 10111 – 23
(b) 111101 – 61
(c) 101010.011 – 42.375
(d) 101101 – 45
5. Convert octal numbers into decimal numbers.
(a) 75 – 61
(b) 321 – 192
(c) 142 – 98
(d) 205 – 133
6. Convert hexadecimal numbers into decimal numbers.
(a) A2 – 162
(b) 13B – 315
(c) 271 – 625
(d) 132 – 306
7. UTF-8 encoding is a variable-sized encoding scheme to represent UNICODE code points in memory.
Variable-sized encoding means the code points are represented using 1, 2, 3 or 4 bytes depending on
their size.
UTF-8 and UTF-32 are the different ways to represent them in byte format. Both UTF-8 is variable
length encoding, where the number of bytes used depends upon UNICODE code points. On the other
hand, UTF-32 is a fixed-width encoding, where each code point takes 4 bytes. UNICODE contains code
points for almost all representable graphic symbols in the world and it supports all major languages, e.g.,
English, Japanese, Mandarin or Devanagari.
8. The values which are stored in binary variables are known as Boolean constants. Therefore, the values
true/false, yes/no or 1/0 are Boolean constants.
9. The operators used in Boolean algebra are known as Boolean/logical operators.
Basic Boolean operators are:
AND Operator
AND operator is a binary operator that operates on two variables and the operation performed by the
AND operator is known as logical multiplication. The symbol used for logical multiplication is the dot (.)
operator.
12 Teacher’s Manual Computer Science with Python–XI

Consider the following values for two variables in a given table. The result of AND operator will be
shown as:
A B OUTPUT A. B
0 0 0
0 1 0
1 0 0
1 1 1
The AND operation will result in a true value (1) when both inputs are 1 (true/high) and for all other
values it results in 0 (false/low).
OR Operator
The OR operator is a binary operator that operates on two variables and the operation performed by
the OR operator is known as logical addition. The symbol used for logical addition is plus (+) operator.
Consider the following values for two variables A and B as shown below. When there is logical addition
using the OR operator, the result will be shown as:
A B OUTPUT A. B
0 0 0
0 1 1
1 0 1
1 1 1
The OR operation results in a true value (1) when either of the inputs is 1 (true) or both inputs are
1 (true/high). For all other values of inputs, it results in 0 (false/low).
NOT Operator
The NOT operator is a unary operator that operates on one variable and the operation performed by
the NOT operator is known as negation or complementation. Consider the Table with values 0 and 1 for
variable A.
A OUTPUT A. B
0 1
1 0
It means that the logical statements A and A’ are opposite to each other. If the value of variable A is 0,
its complement would be 1, and if the value of variable A is 1, its complement would be 0.
10. The hexadecimal number system is used in computers for several reasons:
(a) Hexadecimal numbers can represent a larger range of values using fewer digits than binary. This
makes them a more compact representation of large numbers.
(b) Hexadecimal is a convenient representation of binary because each hexadecimal digit represents
four binary digits (bits). This means that binary numbers can be easily converted to hexadecimal by
grouping the bits into sets of four and converting each set to its hexadecimal equivalent. Similarly,
hexadecimal numbers can be easily converted to binary by replacing each hexadecimal digit with
its binary equivalent.
(c) Memory addresses in computers are often represented in hexadecimal because they are typically
expressed as a sequence of bytes, where each byte is represented by two hexadecimal digits.
11. (a) The truth table for a.(a+b)
a b a+b a.(a + b)
0 0 0 0
0 1 1 0
1 0 1 1
1 1 1 1
To verify a.(a + b) = a,
In the truth table, we can see that the column for a.(a+b) is identical to the column for a. Therefore, we
can conclude that the equation is true for all possible values of a and b.
Teacher’s Manual Computer Science with Python–XI 13

(b) The truth table for X. Y + X.Z


X Y Z Y+Z X.(Y+Z) X. Y X.Z X. Y+X.Z
0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 1 1 1 0 0 0 0
1 0 0 0 0 0 0 0
1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1
To verify X.(Y+Z) = X.Y + X.Z,
In the truth table, we can see that the columns for X.(Y+Z) and X.Y+X.Z have identical values for
all possible combinations of X, Y and Z. Therefore, we can conclude that the equation is true for all
possible values of X, Y and Z.
12. ((X'.Y)' + (X.Y')')'
13. De Morgan’s law can be stated as follows:
First Law: When two or more input variables are OR’ed and negated, they are equivalent to the AND
of the complements of the individual variables.
Second Law: When two or more input variables are AND’ed and negated, they are equivalent to the OR
of the complements of the individual variables.
Now, let us prove the first law using a truth table:
A B A’ B’ A+B (A+B)’ A’.B’
0 0 1 1 0 1 1
0 1 1 0 1 0 0
1 0 0 1 1 0 0
1 1 0 0 1 0 0
As we can see from the truth table, the columns for (A+B)’ and A’.B’ have identical values for each row.
Therefore, we can conclude that the negation of conjunction (AND) is equivalent to the disjunction (OR)
of the negations of the individual propositions and De Morgan’s law holds.
We can prove the second law using a truth table:
A B A’ B’ A+B (A+B)’ (A.B)’
0 0 1 1 0 1 1
0 1 1 0 0 1 1
1 0 0 1 0 1 1
1 1 0 0 1 0 0
The columns for (A.B)’ and A’+B’ have identical values for each row, which proves that the negation
of a disjunction is equivalent to the conjunction of the negations of the individual propositions and
De Morgan’s law holds.
14. Preparing digital content in Indian languages using UNICODE font has several advantages, some of
which are:
(a) Standardization: UNICODE is a standard encoding scheme that ensures uniformity and
consistency in the display and processing of Indian languages across different devices, platforms
and applications. It provides a unified platform for storing, transmitting and rendering Indian
language content, eliminating the need for proprietary or platform-specific encoding systems.
(b) Interoperability: By using UNICODE, Indian language content can be easily exchanged and
shared across different systems, software and networks, without losing its integrity or readability.
This enhances the interoperability and compatibility of Indian language content, making it more
accessible and widely usable.
(c) Multi-lingual support: UNICODE supports a wide range of Indian languages, including Hindi,
Tamil, Telugu, Bengali and many others. This enables content creators to use a single font
and encoding system for multiple languages, simplifying the process of creating and managing
multilingual content.
14 Teacher’s Manual Computer Science with Python–XI

15. The ASCII (American Standard Code for Information Interchange) code for the character ‘C’ is 67, ‘O’ is
79, ‘M’ is 77, ‘P’ is 80, ‘U’ is 85, ‘T’ is 84, ‘E’ is 69 and ‘R’ is 82.
To convert these ASCII codes into binary values, we need to convert each decimal number into an 8-bit
binary number.
Here’s the binary representation of each character:
• ‘C’ (67): 01000011
• ‘O’ (79): 01001111
• ‘M’ (77): 01001101
• ‘P’ (80): 01010000
• ‘U’ (85): 01010101
• ‘T’ (84): 01010100
• ‘E’ (69): 01000101
• ‘R’ (82): 01010010
So, the binary representation of the word ‘COMPUTER’ in ASCII code is:
01000011 01001111 01001101 01010000 01010101 01010100 01000101 01010010
[Link] full form of ASCII is American Standard Code for Information Interchange. It is a character
encoding standard that represents text in computers and other devices.
The full form of ISCII is Indian Script Code for Information Interchange. It is a character encoding
standard developed by the Government of India to represent various Indic scripts such as Devanagari,
Bengali, Gurumukhi, Tamil, etc., in digital form. ISCII was later superseded by UNICODE as the
standard encoding scheme for Indian languages.
17. (a)
A
A.B (A.B)+(C+D)

C C+D
D (A.B)+(C+D)+(B.D)


(b)
A
(A+B)

B (A+B).(BC+D)
BC
C (BC+D)

18. Write the binary equivalent of the following octal numbers: -


(a) 2306 – 10011000110
(b) 5610 – 101110001000
(c) 742 – 111100010
(d) 65.203 – 110101.010000011
19. (a) 4026 – (100000000100110)2
(b) BCA1 – (1011110010100001)2
(c) 98E – (100110001110)2
(d) 132.45 – (100110010.01000101)2
20. (a) (54)10 = (110110)2
(b) (120)10 = (1111000)2
(c) (76)10 = (114)8
(d) (889)10 = (1571)8
(e) (789)10 = (315)16
(f) (108)10 = (6C)16
Teacher’s Manual Computer Science with Python–XI 15

21. (a) 100101111 – 457 (c) 1010011 – 123


(b) 111011010 – 732 (d) 10011101 – 235
22. (a) 1111101101100011 – FB63
(b) 100000101011100 – 415C
(c) 1000111010100011 – 8EA3
(d) 111011111 – 1DF
23. (a) 145 – 101
(b) 6760 – 3568
(c) 455 – 301
(d) 10.75 – 8.953125
24. The hexadecimal number system uses 16 literals which means that it has a base of 16.
Each hexadecimal digit represents a value that is a power of 16, starting from 16°(1) for the rightmost
digit and increasing by a factor of 16 for each digit to the left. The 16 possible hexadecimal digits are:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
25. Typing in an Indian language using UNICODE involves the following steps:
(a) Check UNICODE Characters Chart: To find the UNICODE value for a specific character in the
Indian language you want to type, you can refer to the UNICODE characters chart. You can access
the chart for Indian languages at the URL: [Link] This
chart provides the UNICODE values for various Indian language scripts.
(b) Insert UNICODE Characters: To insert a specific UNICODE character, you can follow these steps:
(i) Type the UNICODE character code using the numeric keypad on your keyboard. For example,
for the letter d in Hindi, the UNICODE value is 0915.
(ii) After typing the character code, press the ALT key.
(iii) While holding the ALT key, press the X key. This combination will convert the character code
to the actual UNICODE character.
(iv) The UNICODE character will appear on the screen, representing the desired Indian language
character.
26. (a) (1010100)10 = (11110110100110110100)2
(b) (3674)8 = (11110111100)2
(c) (266)10 = (412)8
(d) (9F2)16 = (100111110010)2
27. The name of the law is the Distributive Law.
The truth table for the given boolean expression is:
a b c b+c a. (b + c) ab ac ab + ac
0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 1 1 1 0 0 0 0
1 0 0 0 0 0 0 0
1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1

It is proved that a(b+c) = ab + ac


28.
X x+y
Y x’+y
Z (x’+y).2+W1

W
16 Teacher’s Manual Computer Science with Python–XI

Chapter 3: Getting Started with Python


1. Some limitations of Python are as follows:
(a) Speed: Python is an interpreted language, which means that it is generally slower compared to
compiled languages like C or C++.
(b) Mobile Development: Python is not a very good language for mobile development. It is seen as a
weak language for mobile computing.
(c) Memory Consumption: Python is not a good choice for memory-intensive tasks. Due to the
flexibility of the data types, Python’s memory consumption is also high.
(d) Runtime Errors: Python programmers have cited several issues with the design of the language.
Because the language is dynamically typed, it requires more testing and has errors that only show
up at runtime.
2. A flowchart and an algorithm are both tools used in computer programming, but they are different in
nature and serve different purposes. Here are the differences between flowchart and algorithm:
(a) A flowchart is a graphical representation of a process, using symbols, shapes and arrows to illustrate
the flow of information or steps involved in solving a problem. An algorithm, on the other hand, is
a step-by-step procedure for solving a problem or performing a task, which can be implemented in
code.
(b) A flowchart is a visual representation of a process, while an algorithm is a set of instructions that
describes how to perform a task or solve a problem.
(c) A flowchart provides a high-level view of a process, showing the steps involved in solving a problem
or performing a task. An algorithm provides a detailed step-by-step description of how to perform
each step.
(d) A flowchart is represented using symbols, while an algorithm is represented using a natural
language, pseudocode or programming language.
3. The pseudocode to read two numbers that divides one by the other and displays the quotient:
(a) Start
(b) Declare variables num1, num2, quotient
(c) Read num1
(d) Read num2
(e) If num2 is equal to 0, display “Error: Division by zero”
(f) Else, set quotient = num1 / num2
(g) Display “Quotient is: ”, quotient
(h) End
4. Algorithm to determine who takes the cake in the given scenario:
(a) Start
(b) Declare variables player1_wins and player2_wins, both initialized to 0.
(c) Loop 5 times:
(i) Read the result of the coin flip (1 for player 1 win, 2 for player 2 win).
(ii) If the result is 1, increment player1_wins. If it is 2, increment player2_wins.
(iii) If either player has won 3 flips, exit the loop.
(d) If player1_wins is equal to 3, display “Player 1 wins the cake!”
(e) If player2_wins is equal to 3, display “Player 2 wins the cake!”
(f) If neither player has won 3 flips, display “It’s a tie!”
(g) End
Teacher’s Manual Computer Science with Python–XI 17

5.A pseudocode to print all multiples of 5 between 10 and 25 (including both 10 and 25):
(a) Start
(b) Set variable i = 10
(c) Loop while i <= 25:
(i) If i is a multiple of 5, print i
(ii) Increment i by 1
(d) End
6. A pseudocode that will perform the tasks mentioned:
(a) Start
Declare variables cs, math, phys, aggregate, percentage
Read marks for Computer Science from the user and store them in the cs
Read marks for Mathematics from the user and store them in the math
Read marks for Physics from the user and store them in phys
(b) Set aggregate = cs + math + phys
Display “Aggregate marks: ”, aggregate
(c) Set percentage = (aggregate / 300) * 100
Display “Percentage of marks: ”, percentage
End
7. The algorithm to find the greatest among two different numbers entered by the user:
(a) Start
(b) Declare variables num1 and num2 to store the two input numbers
(c) Read in num1 from the user
(d) Read in num2 from the user
(e) If num1 is greater than num2, display “num1 is the greatest”
(f) Otherwise, if num2 is greater than num1, display “num2 is the greatest”
(g) Otherwise, if num1 and num2 are equal, display “Both numbers are equal”
(h) End
8. The algorithm that performs the tasks mentioned:
(a) Start
(b) Declare variable num to store the user input
(c) Read the number from the user and store it in num
(d) If num is between 5 and 15, display “GREEN”
(e) Else, if num is between 15 and 25, display “BLUE”
(f) Else, if num is between 25 and 35, display “ORANGE”
(g) Else, display “ALL COLORS ARE BEAUTIFUL”
(h) End
9. Algorithm to accept four numbers as input and find the largest and smallest of them:
(a) Start
(b) Declare variables num1, num2, num3, num4, largest and smallest
(c) Read in num1 from the user
(d) Read in num2 from the user
(e) Read in num3 from the user
(f) Read in num4 from the user
(g) Set largest equal to num1
(h) Set smallest equal to num1
(i) If num2 is greater than largest, set largest equal to num2
(j) If num3 is greater than largest, set largest equal to num3
(k) If num4 is greater than largest, set largest equal to num4
(l) If num2 is less than the smallest, set the smallest equal to num2
(m) If num3 is less than the smallest, set the smallest equal to num3
18 Teacher’s Manual Computer Science with Python–XI

(n) If num4 is less than the smallest, set the smallest equal to num4
(o) Display the largest and smallest numbers
(p) End
10. The concept of decomposition is based on breaking down complex systems or problems into smaller, more
manageable components. By doing so, we can understand each component in isolation and tackle each
one individually, leading to a simpler and more manageable solution overall.
11. Algorithm to find the factorial of an inputted number:
(a) Start
(b) Declare variables num and factorial
(c) Read in num from the user
(d) Set factorial equal to 1
(e) If num is 0 or 1, set factorial equal to 1
(f) If num is greater than 1, do the following:
(i) Set i equal to 1
(ii) Repeat the following steps until i is greater than num:
• Multiply factorial by i
• Increment i by 1
(g) Display the factorial
(h) End
12. Match the pairs:
Start/Stop of the Process

Data

Process Step

Decision-making

Flow of control

13. Pseudocode to print the bill depending upon the price and quantity of an item:
(a) Start
(b) Declare variables price, quantity, total cost and GST
(c) Read the price of the item from the user and store it in the price variable
(d) Read the quantity of the item from the user and store it in the quantity variable
(e) Multiply the price by the quantity to calculate the total cost and store it in the total cost variable
(f) Display the total cost
(g) Calculate the GST by multiplying the total cost by 0.05 (5%) and store it in the GST variable
(h) Add the GST to the total cost to calculate the bill GST, and store it in a variable with the same
name
(i) Display the bill GST
(j) End
14. Python was first released on February 20, 1991, by its creator, Guido van Rossum. The initial release
was Python 0.9.0, which was a successor to the ABC language.
Teacher’s Manual Computer Science with Python–XI 19

15. Python was developed by Guido van Rossum, a Dutch programmer, in the late 1980s and early 1990s.
The design of Python was influenced by two programming languages—ABC and Modula-3. ABC was a
language designed for teaching programming concepts and it had an easy-to-learn syntax and interactive
shell. Modula-3, on the other hand, was a system programming language that had a strong module
system and support for low-level programming.
16. IDLE is a simple Integrated Development Learning Environment that comes with Python. The most
important feature of IDLE is that it is a program that allows the user to edit, run, browse and debug a
Python program from a single interface.
17. In Python, both displaying and printing are methods of outputting data to the console or terminal, but
there is a difference between them.
Displaying means showing data or output on the console, but without actually printing it. In Python,
this is often done by calling a function that returns a value, such as assigning a value to a variable.
For example, consider the following code:
x=5
x * 2
In this code, the expression x * 2 is evaluated and its result, 10, is computed. However, this value is not
printed or displayed on the console.
Printing on the other hand, means outputting data to the console so that it is visible to the user. In
Python, this is done using the print() function.
For example,
x=5
print(x * 2)
In this code, the value of x * 2, which is 10, is printed to the console using the print() function.
18. Cross-platform software is software that can run on multiple operating systems or platforms without
requiring modification. In the context of Python, it means that Python programs can be written once
and run on multiple platforms, such as Windows, Linux and macOS, without making any changes to the
code.
19. Python offers the following advantages:
(a) Platform-independent: It is platform-independent and can run across different operating
systems/platforms like Windows, Linux/Unix, macOS and other operating systems.
(b) Readability: Python programs use clear, simple, concise and English-like instructions that are
easy to read and understand even by non-programmers or people with no substantial programming
background.
(c) Object-Oriented Programming Language: It is an interactive, interpreted and object-oriented
programming language
(d) Higher Productivity: Since Python is a simple language with small codes and extensive libraries,
it offers higher productivity to programmers than languages like C++ and Java.
(e) Syntax Highlighting: It allows distinguishing between input, output and error messages by
different color codes.
20. There are two ways to work in Python:
(a) Interactive Mode: In this mode, we can execute Python code interactively, line by line and see
the results immediately. We can run Python in interactive mode by opening a Python interpreter,
which allows us to enter Python commands and see their output immediately. Interactive mode is
useful for testing and experimenting with small code snippets.
(b) Script Mode: In this mode, we can write a Python program in a script file, save it and then execute
it using the Python interpreter. We can create a Python script using a text editor or an integrated
development environment (IDE) such as IDLE. Script mode is useful for writing larger programs
or scripts that need to be executed multiple times.
20 Teacher’s Manual Computer Science with Python–XI

21. Advantages of working in Interactive mode in Python:


(a) We can get immediate feedback for each line of code you enter, which allows for quick experimentation
and testing.
(b) It is easy to debug code in interactive mode, as you can quickly test different inputs and see the
results.
Disadvantages of working in Interactive mode in Python:
(a) Interactive mode is best suited for small to medium-sized projects and it can be tedious for larger
projects.
(b) Code written in interactive mode is not easily reusable in other projects or scripts.
22. (a) To display the sum of 3, 8.0, 6*12:
(i) Open Python in interactive mode.
(ii) Type "3 + 8.0 + 6*12" and press enter.
(iii) The sum, which is 83.0, will be displayed on the screen.
(b) To print the sum of 16, 5.0, 44.0:
(i) Open Python in interactive mode.
(ii) Type print (16 + 5.0 + 44.0) and press enter.
(iii) The sum, which is 65.0, will be printed on the screen.
23. (a) Open Python in interactive mode.
(b) Type the following commands and press enter after each line:
(i) print("Python is easy to learn and write.")
(ii) print("It allows us to work in two modes: Interactive mode and Script
mode.")
(iii) print("Interactive mode is also known as Python Shell and Script mode is
known as Python Editor. It is a platform-independent language.")
(iv) print("We find it interesting to work with Python.")
(c) The output will be displayed on the screen.
(d) Type “python [Link]” and press enter, where the filename
Instructions in Script mode:
(a) Open Python in script mode.
(b) Type the following code and save the file with a .py extension:
(i) print("Python is easy to learn and write.")
(ii) print("It allows us to work in two modes: Interactive mode and Script
mode.")
(iii) print("Interactive mode is also known as Python Shell and Script mode is
known as Python Editor. It is a platform-independent language.")
(iv) print("We find it interesting to work with Python.")
(c) Type “python [Link]” and press enter, where the filename is the name of the file we saved in
step 2.
(d) The output will be displayed on the screen.
24. full_name = "Rahul Sharma"
birthday = "December 03, 1993"
print("Full Name is:", full_name)
print("Birthday is on:", birthday)
Output is:
Full Name is: Rahul Sharma
Birthday is on: December 03, 1993
Note: It’s an example, you print your full name and birthday.
Teacher’s Manual Computer Science with Python–XI 21

25. (a) print(n=17) – this code will produce a TypeError.


(b) print(8+9) – the output will be 17.
(c) print(4.2, "hello", 6-2, "world", 15/2.0) – the output will be 4.2    hello    4    world    7.5
(d) print("123abc",sep='-') – the output will be 123abc
(e) print("XXX",end='!') – the output will be XXX!
26. (a) 46
(b) 100
27. Output:
Python is easy to learn and write.
21.99113
I am a class XI student
I m
class XI student
I’m 16 years old
28.

Start

Initialize counters
Even_count = 0
Odd_count = 0

Input the list of


integers

Is the Yes
number
even?

No

Increment Increment
Odd_count by 1 Even_count by 1

Display
Even_count
and Odd_count

End
22 Teacher’s Manual Computer Science with Python–XI

Chapter 4: Python Programming Fundamentals


1.
>>>print("type your name")
2. school = input("Enter Your School Name : ")
Class = input("Enter Your Class: ")
section = input("Enter Your Section : ")
print (school, Class, section, sep="")
Output:
Enter Your School Name: Doon Public School
Enter Your Class: 11
Enter Your Section: B
Doon Public School – 11 – B
3. (a) (2 + 3) ** 3 – 6 / 2
= 5 ** 3 – 6 / 2
= 125 – 3
= 122
(b) (2 + 3) * 5//4 + (4 + 6)/ 2
= 5 * 5//4 + 10/2
= 25//4 + 5
= 6 + 5
= 11
(c) 12 + (3 * 4 – 6)/3
= 12 + (12 – 6)/3
= 12 + 2
= 14
(d) 12 + (3 **4 – 6)// 2
= 12 + (81 – 6)//2
= 12 + 75//2
= 12 + 37
= 49
(e) 12 * 3 % 5 + 2 * 6//4
= 36 % 5 + 2 * 6//4
= 1 + 3
= 4
(f) 12 % 5 *3 + (2*6)//4
= 2 * 3 + 3
= 9
4. Here are the Python expressions and their evaluations using IDLE:
(a) (2 + 3) ** 3 – 6 / 2
>>> (2 + 3) ** 3 - 6 / 2
122.0
(b) (2 + 3) * 5//4 + (4 + 6)/ 2
>>> (2 + 3) * 5//4 + (4 + 6)/ 2
11.0
Teacher’s Manual Computer Science with Python–XI 23

(c) 12 + (3 * 4 – 6)/3
>>> 12 + (3 * 4 - 6)/3
14.0
(d) 12 + (3 ** 4 – 6)// 2
>>> 12 + (3 ** 4 - 6)// 2
49
(e) 12 * 3 % 5 + 2 * 6//4
>>> 12 * 3 % 5 + 2 * 6//4
4
(f) 12 % 5 * 3 + (2*6)//4
>>> 12 % 5 * 3 + (2 * 6)//4
9
5. The invalid variable names and their reasons:
(a) if: This is an invalid variable name because it is a reserved keyword in Python and cannot be used
as a variable name.
(b) total marks: This is an invalid variable name as space is not allowed while naming an identifier.
(c) S.I.: This is an invalid variable name because it contains a special character (.) that is not allowed
in Python variable names.
(d) #tag: This is an invalid variable name because it starts with the # symbol, which is used for
comments in Python and cannot be used as part of a variable name.
(e) tag$: This is an invalid variable name because it contains a special character ($) that is not allowed
in Python variable names.
(f) 9a: This is an invalid variable name because it starts with a number, which is not allowed in
Python variable names.
(g) for: This is an invalid variable name because for is a reserved keyword in Python and cannot be
used as a variable name.
The valid variable names are Group, volume and tot_strength.
6. Output:
(a) 8 5
(b) 0 2
(c) 20 300
(d) 66.66 126.66
(e) 4 –10 7
(f) 8 8 0
(a) (a + b)/2
7.
(b) (3**2+9**3)/2
(c) 3**2 + ((9**3) / 5)
(d) a ** (1/2) + (a+2)/b
(e) 8 - 6 + (6* sum)/ 7 – var ** ½
(f) u * t + (1/2) *a*t**2
8. (a) Add the remainder of 8/3 to the product of 8 and 3.
result = 8 * 3 + 8 % 3
print(result)
Output: 26
24 Teacher’s Manual Computer Science with Python–XI

(b) Find the square root of the sum of 8 and 43.


import math
sum= 8+43
result = [Link](sum)
print("Square root of sum of 8 and 43 is",result)
Output: Square root of sum of 8 and 43 is 7.14142842854285
(c) Find the sum of the square roots of 8 and 43.
import math
result = [Link](8) + [Link](43)
print(result)
Output: 10.480949082616429
(d) Find an integral part of the quotient when 100 is divided by 32.
result = 100 // 32
print(result)
Output: 3
9.
Operators are special symbols or tokens which represent computation or perform various mathematical
or logical operations. They are applied to operand(s), which can be values or variables. The same operator
can behave differently on different data types. Operators when applied to operands form an expression.
Unary and Binary operators: An operator can be termed as unary or binary depending upon the number
of operands it takes. A unary operator takes only one operand whereas a binary operator takes two
operands.
For example, in the expression –6 * 2 + 8 – 3, the first minus sign is a unary minus and the second minus
sign is a binary minus. The multiplication and addition operators in the above expression are binary
operators.
10.
An expression is a combination of value(s), i.e., constant, variable and operators. It generates a single
value, which by itself is an expression. Operands contain the values an operator uses and operators are
the special symbols which represent simple calculations like addition, subtraction, multiplication, etc.
A statement is a complete line of code that performs an action or defines a value. Statements can be
simple such as an assignment statement that sets the value of a variable, or complex, such as a loop or
conditional statement that controls program flow.
11. A Python program can contain the following components:
(a) Statements: A Python program is composed of one or more statements that perform a specific
action or create a value.
(b) Variables: Variables are used to store data and are assigned values using the assignment
operator(=).
(c) Data types: Python supports a variety of data types, including integers, floating-point numbers,
complex numbers, strings, Booleans, lists, tuples, sets and dictionaries.
(d) Operators: In Python programs, operators such as +,-,*,%,etc., are used to perform some kind of
computation on given values(operands) and return the result.
(e) Comments: Comments are used to add explanatory text to a program and are ignored by the
Python interpreter. Comments are preceded by the # symbol.
(f) Whitespace: Python uses indentation to define blocks of code, such as functions, loops and
conditional statements.
12.A variable is like a container that stores values that you can access or change. Variable, as the name
suggests, has been derived from the word “vary” which means that a variable may vary during the
execution of a program, i.e., the value of a variable keeps changing during the program execution.
Variables are important for a program for several reasons:
(a) Data storage
(b) Data manipulation
(c) Control flow
(d) Readability
(e) Reusability
Teacher’s Manual Computer Science with Python–XI 25

13. Dynamic typing is a feature of Python that allows variables to change their data type during the
execution of a program. This means that a variable can be assigned a value of one data type and then
later be assigned a value of a different data type. The data type of a variable is determined at runtime,
rather than being explicitly declared by the programmer.
For example, if a variable x is assigned the value 5, then x is considered to be an integer. If x is later
assigned the value "hello", then x is considered to be a string.
14. def calculate_area(base, height):
area = 1/2 * base * height
return area
area = calculate_area(5, 3)
print(area)
15. def calculate_area(base, height, shape_type):
if shape_type == 'triangle':
area = 0.5 * base * height
print("area of triangle is", area)
elif shape_type == 'rectangle':
area = base * height
print("area of rectangle is",area)
else:
print('Invalid shape type')
calculate_area(5, 3, 'triangle')
calculate_area(4, 3, 'rectangle')
calculate_area(2, 8, 'circle')
16. def print_pattern(n):
for i in range(1, n+1):
print('*' * i)
print_pattern(3)
print_pattern(4)
17. def dollar_to_rupee(amount, conversion_rate):
rupees = amount * conversion_rate
return rupees
amount_in_dollars = float(input('Enter the amount in dollars: '))
conversion_rate = float(input('Enter the dollar-to-rupee conversion rate: '))
amount_in_rupees = dollar_to_rupee(amount_in_dollars, conversion_rate)
print('Amount in rupees:', amount_in_rupees)
18. The code a = b = 70 assigns the value 70 to both a and b.
This is an example of a multiple assignment statement, where the same value is assigned to multiple
variables at the same time. The assignment happens from right to left: first, the value 70 is assigned to
b, and then b’s value of 70 is assigned to a.
19. The given code shows TypeError: cannot unpack non-iterable int object.
20. (a) The code has a syntax error: print should be in lowercase, and parentheses are required around its
argument.
(b) There are two errors in this code. First, NameError : name 'b' is not define, second, AND is not a
valid operator in Python Syntax Error.
26 Teacher’s Manual Computer Science with Python–XI

(c) Invalid syntax error. The fourth line should use commas to separate the values of a, b and c, not
semicolons.
(d) The code is trying to assign a value to the constant 4, which is not allowed in Python.
(e) The code has a syntax error: Print should be in lowercase, i.e., print, and there should be a
comma between the string and the variable.
21. Output
(a) 15
13 22
(b) 2 3 6
2 3 6
(c) 7 49
22. Comments are an essential part of programming that help programmers understand and maintain their
code more efficiently. They are lines of text in a program that are ignored by the interpreter and exist
purely for the benefit of the programmer. In this way, comments are useful because they provide context
and explanations about the code, making it easier to read, understand and modify.
Here are a few examples of how comments can enhance the readability and understandability of a
program:
(a) Comments can be used to provide a summary of what the code is trying to achieve. For example:
# This program calculates the area of a circle.

(b) Comments can be used to explain complex algorithms or calculations. For example:
# This loop is used to find the highest value in the list.

23. (a) No error
(b) There are two errors in this code fragment. The first error is that "Print" should be changed to
"print" (Python is case-sensitive). The second error is that the concatenation operator ‘+’ is used
to concatenate two different types (a string and an integer). To fix this, we can convert the integer
to a string before concatenating.
(c) TypeError: unsupported operand type(s) for /: 'str' and 'int' such as variable A is used in a
mathematical expression with the operator ‘/’, which is not allowed for strings.
24. (a) (20, 81) 41
(b) 50 30
(c) 12 6.0 24
(d) a and b,:25 13 16
25. (a) ValueError: invalid literal for int() with base 10: 'XI'
(b) There is a syntax error such as comma is missing in the second statement.
Also, we need to convert the input to an integer before performing arithmetic operations.
26. radius = float(input("Enter the radius of the circle: "))
area = 3.14159 * radius ** 2
print("The area of the circle with radius", radius, "is", area)
27. mark1 = float(input("Enter marks for subject 1: "))
mark2 = float(input("Enter marks for subject 2: "))
mark3 = float(input("Enter marks for subject 3: "))
mark4 = float(input("Enter marks for subject 4: "))
mark5 = float(input("Enter marks for subject 5: "))
average = (mark1 + mark2 + mark3 + mark4 + mark5) / 5
print("The average marks are:", average)
Teacher’s Manual Computer Science with Python–XI 27

28. base = float(input("Enter the base of the triangle: "))


height = float(input("Enter the height of the triangle: "))
area = 0.5 * base * height
print("The area of the triangle with base",base, "and", height ,"is",area)
29. num = int (input ("Enter a number: "))
multiple1 = num * 1
multiple2 = num * 2
multiple3 = num * 3
multiple4 = num * 4
multiple5 = num * 5
print("The first five multiples of",num, "are", multiple1, multiple2, multiple3,
multiple4, multiple5)
30. name = input("Enter the student's name: ")
class_name = input("Enter the class: ")
age = input("Enter the student's age: ")
print("Student's Details: Name –",name, "Class –", class_name, "Age –",age)
print("Student's Details:")
print("Name – ",name)
print("Class –",class_name)
print("Age – ",age)
31. Python program to read three numbers in three variables and swap the first two variables with the sums
of the first and second, and second and third numbers, respectively:
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
num3 = int(input("Enter the third number: "))
num1, num2 = num1 + num2, num2 + num3
print("After swapping, the value of num1 is",num1, "and the value of num2 is
",num2)
28 Teacher’s Manual Computer Science with Python–XI

Chapter 5: Conditional and Looping Constructs


1. A compound statement is a statement which comprises a group of statements. The compound statements
usually execute when a condition is satisfied or a code block is called directly or through a function call.
Compound statements are spread into multiple logical lines or several single statements but aligned
together into a single unit. Its syntax is:
<compound statement header>:
<multiple simple statements/ compound statements indented at same level>
Here, the header line starts with the keyword and ends at the colon (:). The body consists of more than
one simple Python statement or compound statement.
2. Jump statements are statements that change or modify the normal execution in which a program runs.
These statements are used to alter the execution flow of a program by transferring control to another
part of the program. In Python, pass, continue and break are three jump statements that can be used to
alter the control flow of the program.
3.A loop may contain another loop as a part of its body. This loop inside a loop is called a nested loop.
Once the condition of the outer loop is true, the control is transferred to the inner loop. The inner loop is
terminated first and then the outer loop terminates.
The syntax for a nested while loop:
while expression:
while expression:
statement(s)
statement(s)
statement 2
In a nested while loop, a while loop is defined inside another while loop.
Here’s an example of a nested loop in Python:
# Outer loop
i = 1
while i <= 3:
print("Outer loop iteration:", i)
# Inner loop
j = 1
while j <= 3:
print("Inner loop iteration:", j)
j += 1
i += 1
4. In a while loop, the loop control variable is used to determine whether the loop should continue or
terminate. Updating the loop control variable is significant because it determines when the loop should
stop executing and when it should continue.
If the loop control variable is not updated, the loop may continue running indefinitely, leading to an
infinite loop. This can cause the program to crash or become unresponsive as the loop will keep executing
the same set of instructions repeatedly without ever exiting the loop.
To avoid infinite loops, it is important to update the loop control variable inside the loop body, so that
the loop condition eventually becomes false and the loop terminates. In the example given below, we can
update the value of x inside the loop body as follows:
x = 0
while x < 5:
print(x)
x += 1
Here, we have added a statement x += 1 inside the loop body, which increments the value of x by 1 on
each iteration. This ensures that the loop condition eventually becomes false when x becomes greater
than or equal to 5, and the loop terminates after printing the values 0, 1, 2, 3 and 4.
Teacher’s Manual Computer Science with Python–XI 29

5. Logical expression:
(a) Mark >= 100 and Mark < 70
(b) Num >= 0 and Num <= 5 and Num != 2 OR 0 < Num < 5 and Num != 2
(c) Answer == 'N' or Answer == 'n'
(d) Age >= 18 and gender == 'male'
(e) City == 'Kolkata' or City == 'Mumbai'
6. There are several errors in the given code.
(a) In the line with the if statement, the equality operator should be == instead of =. The = operator is
used for assignment, whereas == is used for comparison.
(b) The string values “w” and “r” should be enclosed in quotes to indicate that they are strings.
(c) The print statements should be in lowercase and should be enclosed in parentheses.
Here’s the corrected code:
code = input("Enter season code: ")
if code == "w":
print("Winter season")
elif code == "r":
print("Rainy season")
else:
print("Summer season")
7. Output:
(a) guru99 1
guru99 2
guru99 3
(b) 100
200
300
(c) 20
16
(d) 1 1
2 1
2 2
3 1
3 2
3 3
4 1
4 2
4 3
4 4
5 1
5 2
5 3
5 4
5 5
(e) 10
11
12
13
14
30 Teacher’s Manual Computer Science with Python–XI

(f) 11
13
15
17
19
8. The output of the program, with x = 50, would be:
ok
average
9. Output:
o +
o o
10. (a) num1 += num2 + num3
Output: 9
(b) num1 = num1 ** (num2 + num3)
print(num1)
Output: 1024
(c) num1 **= num2 + c
print(num1)
Output: NameError: name 'c' is not defined
(d) num1 = '5' + '5'
print(num1)
Output: '55'
(e) print(4.00/(2.0+2.0))
Output: 1.0
(f) num1 = 2+9*((3*12)-8)/10
print(num1)
Output: 27.2
(g) num1 = float(10)
Output: 10.0
(h) num1 = int(float('3.14'))
print(num1)
Output: 3
(i) print(10 != 9 and 20 >= 20)
Output: True
(j) print(5 % 10 + 10 < 50 and 29 <= 29)
Output: True
11. else and elif are two different constructs used in the if statement for different purposes.
The else statement is used in conjunction with the if statement to execute a block of code if the if
statement is False. The else statement doesn’t check for any additional condition. It is always executed
if the if condition is False.
For example:
num = 5
if num > 10:
print("Num is greater than 10")
else:
print("Num is less than or equal to 10")
elif is a shorthand for “else if ”. It is used when you want to check for multiple conditions one after
another. If the first condition is False, the next condition is checked and so on until a True condition is
found. The code block associated with the first True condition is executed and the rest of the conditions
are skipped.
Teacher’s Manual Computer Science with Python–XI 31

For example:
num = 10
if num > 10:
print("Num is greater than 10")
elif num == 10:
print("Num is equal to 10")
else:
print("Num is less than 10")
12. Output:
(a) 20
22
24
26
28
(b) I
N
D
I
A
(c) 12
13. num = int(input("Enter a number: "))
if num > 0:
print("The number is positive.")
elif num == 0:
print("The number is zero.")
else:
print("The number is negative.")
14. for num in range(10, 21):
if num % 2 == 0:
print(num)
15. num = int(input("Enter a number: "))
fact = 1
if num < 0:
print("Factorial cannot be found for negative numbers")
elif num == 0:
print("Factorial of 0 is 1")
else:
for i in range(1, num+1):
fact *= i
print("Factorial of", num, "is", fact)
16. def display_primes():
for num in range(2, 30):
is_prime = True
for i in range(2, num):
if num % i == 0:
is_prime = False
break
if is_prime:
print(num)
32 Teacher’s Manual Computer Science with Python–XI

17. import math


def exponential_series(x, n):
sum = 1
fact = 1
for i in range(1, n+1):
fact *= i
term = (-1)**(i+1) * (x**i) / fact
sum += term
return sum
x = float(input("Enter the value of x: "))
n = int(input("Enter the number of terms to be summed: "))
result = exponential_series(x, n)
print("The sum of the exponential series is:", result)
18. import math
def exponential_series(x, n):
sum = 1
fact = 4
sign = -1
for i in range(1, n+1):
fact *= (2*i) * (2*i - 1)
term = sign * (x**i) / fact
sum += term
sign = -sign
return sum
x = float(input("Enter the value of x: "))
n = int(input("Enter the number of terms to be summed: "))
result = exponential_series(x, n)
print("The sum of the exponential series is:", result)
19. n = int(input("Enter the value of n: "))
sum = 0
for i in range(1, n+1):
for j in range(1, i+1):
sum += j
print("Sum of the series:", sum)
20. (a) for i in range(1, 6):
for j in range(i):
print("*", end=" ")
print()
(b) for i in range(65, 70):
for j in range(i-64):
print(chr(i), end=" ")
print()
(c) for i in range(1, 6):
for j in range(i, 0, -1):
print(j, end=" ")
print()
Teacher’s Manual Computer Science with Python–XI 33

CHAPTER 6: Strings in Python


1. The * operator behaves differently on strings than it does on numbers. In Python, the * operator can be
used to repeat a string a given number of times. When used with a string and a number, the * operator
creates a new string that is a repetition of the original string, as many times as specified by the number.
For example:
s = "hello"
result = s * 3
print(result)
Output:
hellohellohello
2. split()—The split() method breaks up a string at the specified separator and returns a list of substrings.
Its syntax is:
[Link]([separator, [maxsplit]])
The split() method takes a maximum of 2 parameters:
• separator (optional)—The separator is a delimiter. The string splits at the specified separator. If
the separator is not specified, any whitespace (space, newline, etc.) string is a separator.
• maxsplit (optional)—The maxsplit defines the maximum number of splits. The default value of
maxsplit is –1, which means no limit on the number of splits.
For example,
1 . s = "apple,banana,orange"
fruits = [Link](",")
print(fruits)
Output:
['apple', 'banana', 'orange']
2. s = "apple,banana,orange,grape"
result = [Link](",", maxsplit=2)
print(result)
Output:
['apple', 'banana', 'orange,grape']

3. The word ‘HELLO’ will be printed 12 times.
4. The output of the code is: el
5. The output of the code is:
(a) Python found the substring!
(b) Strings in python
Strings In Python
Strdata typegs data type Python
6. Output:
Substring, 'work', found at index: 0
Substring, 'har',found at index: 5
Doesn't contain given substring
34 Teacher’s Manual Computer Science with Python–XI

7. (a) sequence = 'sequence'


third_e = [Link]('e', [Link]('e', [Link]('e')+1)+1)
print(third_e)
(b) string = 'FuNcTioN'
new_string = ''
for letter in string:
if [Link]():
new_string += [Link]()
else:
new_string += [Link]()
print(new_string)
(c) Str = 'School'
print('Z' in Str)
8. (a) str1 = "Global Warming"
print(str1[-4:])
(b) str1 = "Global Warming"
str1 = [Link]('a', '*')
print(str1)
9. Output:
mINDAwORKA
10. s = 'My School'
index = [Link]('h')
if index != -1:
left_partition = s[:index+1]
right_partition = s[index+1:]
print(left_partition, right_partition)
else:
print('The letter "h" does not exist in the string.')
11. def convert_to_titlecase(s):
return [Link]()
s = "this is a sample string"
print(convert_to_titlecase(s))
12. def replace_spaces_with_hyphens(sentence):
modified_sentence = [Link](' ', '-')
return modified_sentence
s = input("Enter a sentence:")"
res=replace_spaces_with_hyphens(s)
print("Modified Sentence",res)
13. string = 'INSTITUTE'
parts = [Link]('T')
print(parts)
Teacher’s Manual Computer Science with Python–XI 35

14. Output:
mmin y Py
My Python Program
My Python Programming
My Python
My
15. def count_vowels(s):
vowels = {'a': 0, 'e': 0, 'i': 0, 'o': 0, 'u': 0}
s = [Link]()
for c in s:
   if c in vowels:
     vowels[c] += 1
print('Count of vowels:')
for vowel, count in [Link]():
   
print("Vowel:",vowel,count)
s = 'Hello World'
count_vowels(s)
16. line = input('Enter a line of text: ')
words = [Link]()
count = 0
for word in words:
if word == 'is':
count += 1
print("The word 'is' appears", count, "time(s) in the line.")
Output:
Enter a line of text: my name is Dev and this is my book
The word 'is' appears 2 time(s) in the line.
17. s = input('Enter a string: ')
s = [Link]('i', '')
print('Modified string:', s)
Output:
Enter a string: i m possible
Modified string: m possble
36 Teacher’s Manual Computer Science with Python–XI

Chapter 7: Lists in Python


[Link] are several ways to create a list in Python:
(a) Creating a List using square brackets: The list can be created by enclosing the items inside square
brackets, separating them with commas. For example,
my_list = [1, 2, 3, 4, 5]
(b) Creating a list from an existing sequence: The list() method in Python is used to create a list from
an existing sequence data type objects. For example,
>>> list1=list('Computer')
>>> list1
['C','o','m','p','u','t','e','r' ]
(c) Creating a list through user input using list() method: We can create a new list by extracting the
elements from the user through command prompt and using built-in method list() as shown below:
>>> list1 = list(input("Enter the List Data: -"))
>>> Enter the List Data: - Computer
>>> print(list)
['C','o','m','p','u','t','e','r' ]
(d) Creating a list from an existing list: We can create a new list from an already existing list.
For example,
>>> list1= [10, 20, 30, 40, 50]
>>>list6 = list1[1:4]
print(list6)
[20, 30, 40]
2. Strings and lists are both data structures in Python and they have some similarities in the way they can
be accessed and manipulated:
(a) Indexing (b) Slicing
(c) Iteration (d) Concatenation
(e) Length
3. Lists are mutable, i.e., values in the list can be modified, which means that Python will not create a new
list when you make changes to an element of a list. Elements in a list need not be of the same type. In
other words, we say that lists are heterogeneous (of multiple types) in nature.
Example: we can add an element to the end of a list using the append() method. We can remove an
element from a list using the remove() method, and we can modify an element in a list by accessing it
using its index and assigning a new value to it.
4. (a) len() – This function is used to find the length of a list or a string. It returns the number of elements
in the list or the number of characters in the string.
my_list = [1, 2, 3, 4, 5]
print(len(my_list)) #
Output: 5
(b) append() – This function is used to add an element to the end of a list. It takes one argument,
which is the element to be added to the list.
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)
Output: [1, 2, 3, 4]
Teacher’s Manual Computer Science with Python–XI 37

(c) extend() – This function is used to add elements from another list to the end of an existing list. It
takes one argument, which is the list of elements to be added.
my_list = [1, 2, 3]
my_list.extend([4, 5, 6])
print(my_list)

Output: [1, 2, 3, 4, 5, 6]
(d) pop() – This function is used to remove and return the last element from a list. It takes an optional
argument, which is the index of the element to be removed. If no index is specified, it removes the
last element.
my_list = [1, 2, 3, 4, 5]
last_element = my_list.pop()
print(last_element)
print(my_list)
Output:
5

[1, 2, 3, 4]
(e) remove() – This function is used to remove the first occurrence of an element from a list. It takes
one argument, which is the element to be removed.
my_list = [1, 2, 3, 4, 5]
my_list.remove(3)
print(my_list)

Output: [1, 2, 4, 5]
(f) del – This keyword is used to delete an element or a slice from a list. It takes one or two arguments,
which are the index or the slice to be deleted.
my_list = [1, 2, 3, 4, 5]
del my_list[2]
print(my_list)
my_list = [1, 2, 3, 4, 5]
del my_list[1:3]
print(my_list)

Output: [1, 2, 4, 5]
[1, 4, 5]
(g) sort() – This function is used to sort a list in ascending order. It takes several optional arguments
that can be used to customize the sorting behavior.
my_list = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
my_list.sort()
print(my_list)

Output: [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9]
(h) sorted() – This function is used to sort a list and return a new sorted list. It takes the list to be
sorted as an argument.
my_list = [4, 2, 5, 1, 3]
sorted_list = sorted(my_list)
print(sorted_list)
print(my_list)

Output: [1, 2, 3, 4, 5]
[4, 2, 5, 1, 3]
38 Teacher’s Manual Computer Science with Python–XI

(i) copy(): This method is used to create a new copy of a list.


my_list = [1, 2, 3]
new_list = my_list.copy()
print(new_list)
Output: [1, 2, 3]
(j) count(): This method returns the number of occurrences of an element in a list.
L = [7,9,4,3,4,8,4]
[Link](4)
Output: 3
(k) max(): The max() function is a built-in Python function that is used to find the maximum value in
a list.
L = [7,9,4,3,6]
max(L)
Output:
9
(l) min(): The min() function is a built-in Python function that is used to find the minimum value in a
list.
L = [7,9,4,3,6]
min(L)
Output:
3
(m) sum(): The sum() function is a built-in Python function that is used to add up all the values in a
list.
L = [7,9,4,3,6]
sum (L)
Output:
29
5. The insert() and append() methods are both used to add elements to a list in Python, but there is a key
difference between the two:
insert(): The insert() method inserts item into the list at the specified index. When an item is inserted
into a list, the list is expanded in size to accommodate the new item.
For example:
my_list = [1, 2, 3]
my_list.insert(1, 4)
print(my_list)
Output: [1, 4, 2, 3]
append(): The append() method is used to add an element to the end of a list. It takes a single argument,
which is the element to be added to the end of the list.
For example:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)
Output: [1, 2, 3, 4]
Teacher’s Manual Computer Science with Python–XI 39

6. L=[10,["few","facts","fun"], 3,'Good']
(a) L[3:]: It will return [‘Good’]
(b) L[::2]: It will return [10, 3]
(c) L[1:2]: It will return [['few', 'facts', 'fun']]
(d) L[1][1]: It will return "facts"
7. [1, 2, 3, '4', '5']
3
[1]
[4, 5, 6]
8. (a) [10, 12, 26, 32, 65, 80]
(b) [12, 32, 65, 26, 80, 10]
(i) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
(ii) 5
9. The output of the given code segment will be:
1
3
5
7
9
10. Output:
(a) [1, 2, 3]
(b) [6, 7, 8, 9, 10]
(c) [2, 4, 6, 8, 10]
11. Output:
['CC', 'a', 'm', '@', 'D', '22', 'D', '*']
12. Program: To display positive and negative numbers from the list of integers.
n = int(input("Enter the number of integers: "))
numbers = [ ]
positive_numbers = [ ]
negative_numbers = [ ]
for i in range(n):
num = int(input("Enter an integer: "))
[Link](num)
if num >= 0:
positive_numbers.append(num)
else:
negative_numbers.append(num)
print("Original list:", numbers)
print("Positive numbers:", positive_numbers)
print("Negative numbers:", negative_numbers)
40 Teacher’s Manual Computer Science with Python–XI

13. Python program that finds the largest and second largest elements in a list:
elements = [5, 12, 8, 15, 6, 9]
largest = None
second_largest = None
for element in elements:
if largest is None or element > largest:
second_largest = largest
largest = element
elif second_largest is None or element > second_largest:
second_largest = element
print("Largest element:", largest)
print("Second largest element:", second_largest)
14. Python program that reads in a list of integers, sorts it and calculates the median:
n = int(input("Enter the number of integers: "))
numbers = []
for i in range(n):
num = int(input("Enter an integer: "))
[Link](num)
[Link]()
if n % 2 == 0:
median1 = numbers[n//2]
median2 = numbers[n//2 - 1]
median = (median1 + median2) / 2
else:
median = numbers[n//2]
print("Median:", median)
15. The basic principle of sorting in insertion sort is to divide the input list into two sub-lists—the sorted
sub-list and the unsorted sub-list. Initially, the sorted sub-list contains all the elements of the input list.
We then iterate through the unsorted sub-list. For each element, we compare it with the elements in the
sorted sub-list, starting from the rightmost element.
We shift all elements in the sorted sub-list that are greater than the current element one position to the
right, to make space for inserting the current element in the correct position.
This process is repeated until all elements from the unsorted sub-list have been moved to the sorted sub-
list, resulting in a fully sorted list.
16. Insertion sort is more efficient than bubble sort in practice, even both have a worst-case time complexity
of O(n2).
This is because insertion sort performs better on partially sorted lists and can insert each element into
its correct position with fewer comparisons and swaps.
In contrast, bubble sort repeatedly iterates through the entire list, performing unnecessary comparisons
even if the list is nearly sorted. As a result, insertion sort tends to run faster than bubble sort in real-
world scenarios, especially when the input is partially sorted.
17. elements = input("Enter the list of elements separated by commas: ").split(",")
unique_elements = list(set(elements))
print("Modified list without duplicates:", unique_elements)
Teacher’s Manual Computer Science with Python–XI 41

18. elements = [1, 2, 3, 4, 5]


new_element = input("Enter the new element to insert: ")
position = int(input("Enter the position to insert the new element: "))
[Link](position, new_element)
print("Modified list with new element:", elements)
19. elements_input = input("Enter the elements of the list, separated by spaces: ")
elements_str = elements_input.split()
elements = []
for e in elements_str:
  [Link](int(e))
position = int(input("Enter the position of the element to be deleted: "))
del elements[position]
print("List after deleting element",elements)
value = int(input("Enter the value of the element to be deleted: "))
[Link](value)
print("Modified list:", elements)
20. total = 0
for x in S:
   if x % 2 == 1:
total += x
print("Sum of odd values in S:", total)
21. numbers = [1, 2, 3, 4, 5]
if len(numbers) == 0:
   print("Mean of the numbers: None")
else:
   total = sum(numbers)
   mean = total / len(numbers)
   print("Mean of the numbers:", mean)
22. lst = [5, 2, 4, -5, 12, 2, 7, 4]
print("Original list:", lst)
unique_list = []
for element in lst:
     if element not in unique_list:
     unique_list.append(element)
print("List without duplicates:", unique_list)
23. numbers = [3, 5, 1, 9, 2, 7]
minimum = numbers[0]
for number in numbers[1:]:
if number < minimum:
minimum = number
print("The minimum element is:", minimum)
42 Teacher’s Manual Computer Science with Python–XI

24. Python code to calculate and display the total marks and percentage of a student from the given list
storing marks of a student:
marks = [85, 90, 95, 80, 75]
total_marks = sum(marks)
max_marks = len(marks) * 100
percentage = (total_marks / max_marks) * 100
print("Total marks:", total_marks)
print("Percentage:", percentage)
25. my_list = [1, 'a', 'b', 3, 'c', 5]
for i in range(len(my_list)):
     if i % 2 == 1:
     my_list[i] = my_list[i] * 2
print(my_list)
26. my_list = [1, 2, 3, 4, 2, 3, 2, 1, 2, 5]
element = 2
count = 0
for item in my_list:
     if item == element:
     count += 1
print(count)
27. my_list = [10, 20, 30, 40, 50]
last_element = my_list[-1]
for i in range(len(my_list) - 1, 0, -1):
      my_list[i] = my_list[i - 1]
my_list[0] = last_element
print("Shifted list:", my_list)
28. def swap_with_next_divisible_by_5(arr):
for i in range(len(arr) - 1):
    if arr[i + 1] % 5 == 0:
arr[i], arr[i + 1] = arr[i + 1], arr[i]
    return arr
Num = [3, 25, 13, 6, 35, 8, 14, 45]
result = swap_with_next_divisible_by_5(Num)
print(result)
29. stRecord = ['Raman','A-36',[56,98,99,72,69], 78.8]
percentage = stRecord[3]
print("Percentage:", percentage)
fifth_subject_marks = stRecord[2][4]
print("Marks in fifth subject:", fifth_subject_marks)
max_marks = max(stRecord[2])
print("Maximum marks:", max_marks)
roll_no = stRecord[1]
print("Roll No.:", roll_no)
stRecord[0] = "Raghav"
print("Modified stRecord:", stRecord)
Teacher’s Manual Computer Science with Python–XI 43

30. Let’s apply the fourth pass of insertion sort and the fourth pass of bubble sort to the given list
[12, 14, –54, 64, 90, 24]:
After the fourth pass of insertion sort, the list will be:
–54, 12, 14, 24, 64, 90
After the fourth pass of bubble sort, the list will be:
12, –54, 14, 24, 64, 90
31. Here are the steps to arrange the given elements [12, 5, 14, 8, 3, 54, 25, 10, 27, 3] using insertion sort:
(a) Start with the second element (5) and compare it with the previous element (12).
(b) Since 5 is smaller than 12, swap them: [5, 12, 14, 8, 3, 54, 25, 10, 27, 3].
(c) Move to the third element (14) and compare it with the previous elements until you find an element
smaller than it. Here, 14 is greater than 12 and so it is in its correct position.
[5, 12, 14, 8, 3, 54, 25, 10, 27, 3]
(d) Move to the fourth element (8) and compare it with the previous elements until you find an element
smaller than it. Here, 8 is smaller than 14 and 12. So, swap 8 with 12: [5, 8, 12, 14, 3, 54, 25, 10, 27, 3]
(e) Continue this process until all elements are in their correct positions.
The final sorted list will be: [3, 3, 5, 8, 10, 12, 14, 25, 27, 54]
44 Teacher’s Manual Computer Science with Python–XI

Chapter 8: Tuples and Dictionary


1. Advantages of using tuples over the list:
(a) Tuples use less memory whereas lists use more memory.
(b) We can use tuples in a dictionary as a key but it is not possible with lists.
Tuples are generally faster than lists when it comes to accessing and iterating through elements.
2. Tuples and lists are two common data structures in Python, but they have some key differences in terms
of their properties and use cases. Here are the similarities and differences between tuples and lists:
Similarities:
(a) Both tuples and lists are used to store a collection of elements in Python.
(b) Both tuples and lists can store elements of different data types.
(c) Both tuples and lists support indexing and slicing to access individual elements.
(d) Both tuples and lists can be iterated over using a loop.
Differences:
(a) Lists are mutable, while tuples are immutable. This means that you can change the elements of
a list after it has been created, but you cannot change the elements of a tuple once it has been
created.
(b) Lists are created using square brackets ([]), while tuples are created using parentheses ().
(c) Lists have several built-in methods for modifying and manipulating the elements, such as append(),
insert(), and remove(). Tuples have fewer built-in methods and are mainly used for accessing and
grouping data.
(d) Lists are typically used for collections of similar items that may need to be changed or modified
over time, while tuples are often used for collections of related values that are not intended to be
changed, such as coordinates or database records.
3. A key-value pair is a fundamental concept in dictionaries in Python. It refers to a single item or entry in
a dictionary, where a key is associated with a corresponding value. The key is used to identify and access
the associated value in the dictionary.
In a dictionary, the keys are unique and immutable objects such as strings, numbers or tuples. The
values associated with the keys can be of any data type, including strings, numbers, lists, tuples, sets or
even other dictionaries.
For example, consider the following dictionary that stores the prices of some fruits:
fruit_prices = {'apple': 150, 'banana': 50, 'orange': 120}
4. Tuples and dictionaries are two different data structures in Python. While both are used to store and
manipulate data, they have some key differences:
(a) Tuples are ordered collections of elements, while dictionaries are unordered collections of key-value
pairs.
(b) Tuples are immutable, meaning that once a tuple is created, its contents cannot be modified. In
contrast, dictionaries are mutable and can be modified by adding, deleting or changing key-value
pairs.
(c) In a tuple, elements are accessed by their index position, starting from 0. In a dictionary, values are
accessed by their corresponding keys.
(d) Tuples can contain duplicate values, while keys in a dictionary must be unique.
(e) Tuples are generally more memory-efficient than dictionaries, as they do not require additional
memory to store keys.
Teacher’s Manual Computer Science with Python–XI 45

5. Strings and tuples are two different data structures in Python. While both are used to store and
manipulate data, they have some key differences:
(a) Strings are sequences of characters, while tuples are ordered collections of elements.
(b) Strings are immutable, meaning that once a string is created, its contents cannot be modified. In
contrast, tuples are generally immutable, but there are some exceptions. For example, if a tuple
contains a mutable object like a list, the contents of that object can be modified.
(c) Strings are accessed using index positions, starting from 0, while tuples are accessed in the same
way.
(d) Strings have a wide range of built-in methods that can be used to manipulate the contents of the
string, while tuples have fewer methods and are generally used for storing and accessing data
rather than manipulating it.
(e) Strings are generally less memory-efficient than tuples, as they require additional memory to store
each individual character.
6. False. A tuple can contain values of different types.
In Python, a tuple is an ordered collection of values, and each value can be of any data type, such as
integer, float, string, Boolean, etc. Therefore, there is no restriction on having the same type of values in
a tuple.
Example: we can define a tuple with integer and string values as follows:
my_tuple = (1, 'apple', 3, 'orange')
7. A tuple defined inside another tuple is termed as a nested tuple. In a nested tuple, each subtuple is
treated as an element of the parent or main tuple. It is valid for tuple holding list as its elements too, as
shown: -
>>> Tup = ((0, 1, 2, 3), ['hello', 'world'])
this is a nested tuple holding a tuple and list as its elements.
8. To create an empty tuple in Python, we simply use a pair of empty parentheses. The code to create an
empty tuple:
my_tuple = ()
9. A Python program to create and display a tuple having values of different data types:
my_tuple = (1, 'apple', 3.14, True)
print("My tuple:", my_tuple)
Output:
My tuple: (1, 'apple', 3.14, True)
10. The main difference between “book” and (‘book’,) is that the former is a string data type, while the
latter is a tuple data type.
In Python, a string is a sequence of characters enclosed in quotes (‘or’). On the other hand, a tuple is an
ordered collection of elements, enclosed in parentheses ().
Example to illustrate the difference:
my_string = "book"
my_tuple = ('book',)
print(type(my_string))
print(type(my_tuple))
Output:
<class 'str'>
<class 'tuple'>
46 Teacher’s Manual Computer Science with Python–XI

11. A Python program that combines the first three elements and last three elements from a tuple:
T1 = ('a', 1, 2, 3, 4, 'b', 'c', 'book', 10)
T2 = T1[:3] + T1[-3:]
print(T2)
Output:
('a', 1, 2, 'c', 'book', 10)
12. Here are the corrected versions of the code:
The dictionary should have 7:70 instead of 7,70:
d1 = {1:10, 2.5:20, 3:30, 4:40, 5:50, 6:60, 7:70}
(a) The dictionary should be accessed using square brackets instead of parentheses:
d1[9] = 90
(b) The del keyword should be followed by square brackets when deleting a key-value pair from a
dictionary:
del d1[2]
(c) The correct syntax to remove an item with key 4 from the dictionary d1 using the pop() method is:
[Link](4)
(d) The items() method should be used instead of item to get a list of key-value pairs:
[Link]()
(e) The keys() method should be used instead of key to get a list of keys:
[Link]()
(f) The values() method should be used instead of value to get a list of values:
[Link]()
(g) The get() method should be used instead of gets to get the value associated with a key, and we
should provide a default value of 80 to return if the key is not found:
[Link](4,80)
(h) The correct syntax to get the number of key-value pairs in the dictionary d1 using the len() function
is:
len(d1)
(i) The clear() method should be used instead of clears to remove all key-value pairs from the dictionary:
[Link]()
13. (a) >>> [Link]()
dict_items([(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')])
>>> [Link]()
dict_keys([1, 2, 3, 4])
>>> [Link]()
dict_values(['one', 'two', 'three', 'four'])
>>> [Link](d2)
{1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six'}
>>> len(d1)
6
(b) >>> del d1[3]
>>> print(d1)
{1: 'one', 2: 'two', 4: 'four', 5: 'five', 6: 'six'}
>>> [Link](4)
'four'
>>> print(d1)
Teacher’s Manual Computer Science with Python–XI 47

{1: 'one', 2: 'two', 5: 'five', 6: 'six'}


>>> d1[8]='eight'
>>> print(d1)
{1: 'one', 2: 'two', 5: 'five', 6: 'six', 8: 'eight'}
>>> [Link]()
>>> print(d1)
{}
14. Errors:
(a) TypeError: can’t multiply sequence by non-int of type 'tuple'
(b) TypeError: can only concatenate tuple (not "str") to tuple
(c) TypeError: can’t multiply sequence by non-int of type 'str'
(d) ValueError: too many values to unpack (expected 3)
(e) Compile time Error: missing parentheses of print() function
(f) TypeError: 'tuple' object does not support item assignment
(g) TypeError: can only concatenate str (not "tuple") to str
(h) ValueError: not enough values to unpack (expected 3, got 2)
15. Output:
(a) 9
(b) True
(c) (200, 'Global', 3, 3.5)
(d) ('Exam', [1, 2], (30, 40), (3, 5, 3))
(e) ValueError: [Link](x): x not in tuple
(f) ValueError: [Link](x): x not in tuple
(g) False
(h) 1
(i) True
(j) 'GlobalGlobal'
16. Output:
(a) (10, 20, 40)
(b) ('Tea', 'Tea', 'Tea', 'Tea', 'Tea')
(c) ('I', 't', 'e', 'm')
17.
Output:
(a) (10, 20, 30, 40)
(100, 200, 300)
(b) True
(c) True
18. num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
num3 = int(input("Enter the third number: "))
my_tuple = (num1, num2, num3,)
for element in my_tuple:
print(element)
max_value = max(my_tuple)
min_value = min(my_tuple)
print("Maximum value is:", max_value)
print("Minimum value is:", min_value)
48 Teacher’s Manual Computer Science with Python–XI

19. tuple1 = tuple(input("Enter values for first tuple separated by space: ").split())
tuple2 = tuple(input("Enter values for second tuple separated by space: ").split())
print("Original tuples:")
print("Tuple 1:", tuple1)
print("Tuple 2:", tuple2)
tuple1, tuple2 = tuple2, tuple1
print("\nInterchanged tuples:")
print("Tuple 1:", tuple1)
print("Tuple 2:", tuple2)
if tuple1 == tuple2:
print("\nThe two tuples are equal.")
else:
print("\nThe two tuples are not equal.")
20. n = int(input("Enter the number of classes: "))
classes = {}
for i in range(n):
   class_name = input("Enter the name of class " + str(i + 1) + ": ")
   teacher_name = input("Enter the name of the class teacher for " + class_name + ": ")
   classes[class_name] = teacher_name
print("\nClass Teacher Details:")
for class_name, teacher_name in [Link]():
   print("Class: " + class_name + " Teacher: " + teacher_name)
class_name = input("\nEnter the name of a class to display its teacher: ")
if class_name in classes:
   print("Teacher of " + class_name + " class is " + classes[class_name])
else:
   print("No information found for " + class_name + " class.")
21. n = int(input("Enter the number of students: "))
students = {}
for i in range(n):
name = input("Enter the name of student " + str(i + 1) + ": ")
percentage = float(input("Enter the percentage of " + name + " in the exam: "))
students[name] = percentage
print("\nStudent Details:")
for name, percentage in [Link]():
print(name, percentage)
name_to_delete = input("\nEnter the name of student to be deleted: ")
if name_to_delete in students:
del students[name_to_delete]
print("Student " + name_to_delete + " has been deleted.")
else:
print("No information found for student " + name_to_delete)
print("\nUpdated Student Details:")
for name, percentage in [Link]():
print(name, percentage)
Teacher’s Manual Computer Science with Python–XI 49

22. n = int(input("Enter the number of customers: "))


customers = {}
for i in range(n):
name = input("\nEnter the name of customer"+str(i+1)+":")
items = input("Enter the items bought by"+name+":")
cost = float(input("Enter the total cost of items bought by"+name+":"))
phone = input("Enter the phone number of"+name+":")
customers[name] = {'items': items, 'cost': cost, 'phone': phone}
print("\nCustomer Details:")
print("Name\t\tItems Bought\t\tTotal Cost\t\tPhone Number")
print("-" * 100)
for name, details in [Link]():
print(name + "\t\t" + details['items'] + "\t\t" + str(details['cost']) +
"\t\t" + details['phone'])
50 Teacher’s Manual Computer Science with Python–XI

Chapter 9: Introduction to Python Modules


1. In Python, a library is a collection of pre-existing code that can be used to perform common tasks without
having to write the code.
A Python library typically contains a set of pre-defined functions, classes and variables that can be
imported into a Python program, making it easier for us to write code by reusing existing code. Libraries
can help us accomplish various tasks like web scraping, data visualization, scientific computing, machine
learning, etc.
Example: The ‘NumPy’ library is a popular Python library used for scientific computing. It provides
a powerful array object and functions for working with arrays that make it easy to perform complex
mathematical operations.
import numpy as np
# Create a NumPy array with 10 random numbers between 0 and 1
arr = [Link](10)
# Calculate the mean of the array
mean = [Link](arr)
# Print the array and its mean
print("Array:", arr)
print("Mean:", mean)
Output:
Array: [0.55637707 0.04990217 0.27383518 0.45725541 0.86791498 0.22004002
0.27809501 0.88966257 0.92681545 0.23797902]
Mean: 0.4757876874550936
2. To create a module to input the total number of days and find the total number of months and remaining
days, we can write the following code and save it as a Python file like month_calculator.py:
def calculate_months_and_days(total_days): """
total_months = total_days // 30
remaining_days = total_days % 30
return (total_months, remaining_days)
To use this module in our program, we can import it and call the calculate_months_and_days function.
An example program that does this:
import month_calculator
total_days = int(input("Enter the total number of days: "))
total_months, remaining_days = month_calculator.calculate_months_and_days(total_
days)
print(total_days, days is equal to",total_months, "month(s) and", remaining_days,
"day(s).")
Output:
Enter the total number of days: 31
31 days is equal to 1 month(s) and 1 day(s).
3. In Python, a module is a file containing Python definitions and statements. These files usually have a
‘.py’ file extension and are used to organize code into reusable, modular pieces.
A Python module typically consists of functions, classes and variables that can be imported and used in
other Python programs. By importing a module, you can reuse code that has already been written and
tested, rather than having to write everything from scratch.
Teacher’s Manual Computer Science with Python–XI 51

To import a module in Python, we can use the import statement followed by the name of the module.
For example, to import the math module, we would use the following statement:
import math
print([Link])
4. To reuse the functions defined in a Python module in our program, we need to import the module into
our program. We can do this using the import statement, followed by the name of the module.
For example, we have a module called my_module.py that defines a function called my_function(). To
use this function in our program, we would first need to import the module:
import my_module
result = my_module.my_function(argument)
We can import specific functions from the module using the from statement, like this:
from my_module import my_function
result = my_function(argument)
5. In Python, there are several ways to import objects (functions, classes and variables) from a module.
Here are the most common ways:
(a) import statement can be used to import a module. It is the simplest and most common way to use
modules in our code. It provides access to all attributes (like variables, constants, etc.) and methods
or functions present in the module.
import <module_name>
import in case of accessing specific modules, it can be modified as:
import module1, module2, ...moduleN
To access particular methods from any module, the statement shall be:
<module_name>.<function_name>
(b) Python’s from statement can be used to import specific attributes or individual objects from a
module into the current (calling) module or namespace.
from <module_name> import <function_name>
OR
from import function_name1,function_name2...function_nameN
(c) import* statement can be used to import all names from a module into the current calling
(namespace) module.
from <module_name> import *
6. The two statements:
(a) import math
(b) from math import *
are different from each other in how they import the contents of the math module.
The first statement (a) imports the entire math module into our code, making all of its functions and
variables available to our program. To use an object from the module, we need to prefix its name with
the module name, like this:
[Link](25)
The second statement (b) imports all of the objects from the math module directly into our code, without
the need for the math. prefix. This means that we can use the objects from the module directly in our
code, like this:
sqrt (25)
This syntax is generally not recommended, as it can make our code harder to read and maintain and can
also lead to naming conflicts if the module defines objects with the same names as objects in our code.
52 Teacher’s Manual Computer Science with Python–XI

7. Python resolves the scope of a name or identifier using a set of rules known as the ‘LEGB’ rule, which
stands for Local, Enclosing, Global and Built-in. These rules determine the order in which Python
searches for a name or identifier when it is referenced in a program.
Here’s how the LEGB rule works:
• Local scope (L): Python first looks for the name or identifier in the local scope, which is the
current function or block where the name or identifier is defined. If the name or identifier is found
in the local scope, Python uses that value.
• Enclosing scope (E): If the name or identifier is not found in the local scope, Python searches
for it in the enclosing scope, which is the scope of the function or block that contains the current
function or block. This process continues recursively up the chain of enclosing scopes until the
name or identifier is found or the global scope is reached.
• Global scope (G): If the name or identifier is not found in any of the enclosing scopes, Python
searches for it in the global scope, which is the module-level scope. If the name or identifier is found
in the global scope, Python uses that value.
• Built-in scope (B): If the name or identifier is not found in any of the above scopes, Python looks
for it in the built-in scope, which contains the names of all the built-in functions and modules in
Python. If the name or identifier is found in the built-in scope, Python uses that value.
If the name or identifier is not found in any of the above scopes, Python raises a NameError exception.
8. A program having multiple functions is considered better designed than a program without any functions
for several reasons:
(a) Modularity: Functions provide a way to break a large, complex program into smaller, more
manageable pieces.
(b) Reusability: Functions can be reused in multiple parts of a program or in different programs
altogether.
(c) Readability: Functions help to improve the readability of our code by providing a descriptive
name for a set of instructions.
(d) Testing: Functions are easier to test than entire programs. By isolating a particular piece of
functionality in a function, we can write test cases to check the output of the function and ensure
that it works as expected.
9. An example implementation of the calculate_area() module in Python:
def calculate_area(base, height):"""
area = 1/2 * base * height
return area
Using this module in our program:
import calculate_area
area = calculate_area.calculate_area(5,10)
print("The area of the triangle is:", area)
Output:
The area of the triangle is: 25.0
10. The corrected code:
import math
def main():
r = input('Enter any radius: ')
a = [Link] * [Link](float(r), 2)
print("Area = " + str(a))
main()
Teacher’s Manual Computer Science with Python–XI 53

11. [Link](89.7) and [Link](89.7) are two different methods in the math module.
(a) [Link](89.7) returns the smallest integer greater than or equal to 89.7, which is 90.
(b) [Link](89.7) returns the largest integer less than or equal to 89.7, which is 89.
12. For generating random integers between 1 and 5 inclusive, we should use the randint() function from the
random module in Python.
The random() function generates random float values between 0 and 1 so, it is not suitable for generating
random integers within a specific range without additional processing.
The randint() function generates random integers within a specific range, including the endpoints of
the range. Therefore, to generate random integers between 1 and 5, we can use the following code:
import random
random_number = [Link](1, 5)
print(random_number)
13. Python program to calculate the average and median of a list of donations:
donations = [100, 60,70,900,100, 200, 500, 500, 503, 600, 1000, 1200]
average = sum(donations) / len(donations)
print("The average donation is:", average)
[Link]()
if len(donations) % 2 == 0:
median = (donations[len(donations)//2 - 1] + donations[len(donations)//2]) / 2
else:
median = donations[len(donations)//2]
print("The median donation is:", median)
14. import random
random_number = [Link](0, 9)
print("The random number is:", random_number)
15. def fibonacci(n):
a, b = 0, 1
while a < n:
   print(a, end=" ")
   a, b = b, a + b
   print()

fibonacci(50)
16. import statistics as s
data = [41, 32, 43, 40, 28, 45]
print ("Data : ", data)
print ("Average temperature in month of June :", [Link](data))
print ("Median value in month of June :", [Link](data))
new_data = []
for i in data:
new_data += [i - 20]
print ("\nAverage temperature in month of December :",[Link](new_data))
print ("Median value in month of December :", [Link](new_data))
54 Teacher’s Manual Computer Science with Python–XI

17. import math


# Define functions for arithmetic operations
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
return x / y
# Define functions for logarithmic and trigonometric operations def log10(x):
return math.log10(x)
def sin(x):
return [Link](x)
def cos(x):
return [Link](x)
# Define a function to display the menu and get user input
def get_operation():
print("Calculator Menu:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
print("5. Logarithm (base 10)")
print("6. Sine")
print("7. Cosine")
print("0. Exit")
choice = int(input("Enter your choice: "))
return choice
# Define the main program function
def main():
while True:
choice = get_operation()
if choice == 0:
print("Exiting program...")
break
elif choice >= 1 and choice <= 4:
# Get user input for arithmetic operations
x = float(input("Enter first number: "))
y = float(input("Enter second number: "))
if choice == 1:
print("Result: ", add(x, y))
elif choice == 2:
print("Rzesult: ", subtract(x, y))
elif choice == 3:
Teacher’s Manual Computer Science with Python–XI 55

print("Result: ", multiply(x, y))


elif choice == 4:
print("Result: ", divide(x, y))
elif choice >= 5 and choice <= 7:
# Get user input for logarithmic and trigonometric operations
x = float(input("Enter a number: "))
if choice == 5:
print("Result: ", log10(x))
elif choice == 6:
print("Result: ", sin(x))
elif choice == 7:
print("Result: ", cos(x))
else:
print("Invalid choice. Please try again.")
# Call the main program function
main()
18. import math
# Define functions for calculating area, perimeter or surface area
def square_area(side):
return side ** 2
def square_perimeter(side):
return 4 * side
def rectangle_area(length, width):
return length * width
def rectangle_perimeter(length, width):
return 2 * (length + width)
def triangle_area(base, height):
return 0.5 * base * height
def triangle_perimeter(side1, side2, side3):
return side1 + side2 + side3
def circle_area(radius):
return [Link] * radius ** 2
def circle_circumference(radius):
return 2 * [Link] * radius
def cylinder_area(radius, height):
return 2 * [Link] * radius * height + 2 * [Link] * radius ** 2
def cylinder_volume(radius, height):
return [Link] * radius ** 2 * height
# Define a function to display the menu and get user input
def get_shape():
print("Shape Calculator:")
print("1. Square")
print("2. Rectangle")
print("3. Triangle")
print("4. Circle")
56 Teacher’s Manual Computer Science with Python–XI

print("5. Cylinder")
print("0. Exit")
choice = int(input("Enter your choice: "))
return choice
# Define the main program function
def main():
while True:
choice = get_shape()
if choice == 0:
print("Exiting program...")
break
elif choice == 1:
side = float(input("Enter the length of the side: "))
print("Area: ", square_area(side))
print("Perimeter: ", square_perimeter(side))
elif choice == 2:
length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))
print("Area: ", rectangle_area(length, width))
print("Perimeter: ", rectangle_perimeter(length, width))
elif choice == 3:
base = float(input("Enter the base of the triangle: "))
height = float(input("Enter the height of the triangle: "))
print("Area: ", triangle_area(base, height))
side1 = float(input("Enter the length of side 1: "))
side2 = float(input("Enter the length of side 2: "))
side3 = float(input("Enter the length of side 3: "))
print("Perimeter: ", triangle_perimeter(side1, side2, side3))
elif choice == 4:
radius = float(input("Enter the radius of the circle: "))
print("Area: ", circle_area(radius))
print("Circumference: ", circle_circumference(radius))
elif choice == 5:
radius = float(input("Enter the radius of the cylinder: "))
height = float(input("Enter the height of the cylinder: "))
print("Surface Area: ", cylinder_area(radius, height))
print("Volume: ", cylinder_volume(radius, height))
else:
print("Invalid choice. Please try again.")
Teacher’s Manual Computer Science with Python–XI 57

Chapter 10: Society, Law and Ethics


1. Cybercrime is defined as a crime in which a computer is the object of the crime (hacking, phishing,
spamming) or is used as a tool to commit an offence . Cybercriminals may use computers to access
personal information, business trade secrets, or use the internet for exploitative or malicious purposes.
2. Cyber ethics refer to the moral principles, values and guidelines that govern online behaviour and
interactions in the digital realm. It is a set of rules that individuals and organizations must follow to
ensure responsible and ethical conduct in the use of technology, the internet and digital media.
Cyber ethics are crucial in promoting responsible behaviour and ensuring the safety and security of the
digital realm. They provide guidelines for individuals and organizations to follow and promote a healthy
and ethical online environment.
3. Identity theft refers to the acquisition of personal data of the victim and using it for illegal purposes.
It is a type of fraud that involves using someone else’s identity to steal money or gain other benefits.
A few steps to follow in order to prevent identity thefts:
(a) Ensure a strong and unique password
(b) Avoid posting confidential information online
(c) Do not post personal information on social media
(d) Shop from known and trusted websites only
(e) Use the latest version of the browsers
(f) Install advanced malware and spyware tools
(g) Use specialized security solutions against financial data
(h) Always update your system and the software
(i) Download only well-known apps and share limited details
4. Illegal downloads from the internet involve violation of copyright laws where users download material,
such as music, movies and other forms of media, without properly purchasing the product or doing so
without proper permission of copyright holder. Hence, illegal downloads result in digital piracy.
5. Child pornography involoves publishing and transmission of obscene material involving children
in electronic form. In recent years, its prevalence has increased due to easy internet access and the
widespread availability of such content online. Child pornography is the most heinous crime which
occurs and has led to various other crimes such as sex tourism, sexual abuse of the child, etc.
6. People can unknowingly commit cybercrime by engaging in activities that are illegal or unethical in
the digital realm without realizing the consequences of their actions. Some examples of how people can
unknowingly commit cybercrime include:
(a) Falling for phishing scams
(b) Using illegal software or media
(c) Participating in online harassment or cyberbullying
(d) Sharing malware or viruses
7. Phishing is a type of cyber-attack that uses social engineering to trick individuals into disclosing
their personal or sensitive information, such as login credentials, credit card details, or social security
numbers.
There are different ways to do phishing, some of which include:
(a) Email phishing: This is the most common type of phishing, where attackers send fraudulent
emails that appear to be from a legitimate source, such as a bank or social media platform. These
emails usually contain a link or attachment that, when clicked or downloaded, leads the victim to
a fake website or downloads malware onto their device.
58 Teacher’s Manual Computer Science with Python–XI

(b) Spear phishing: This is a targeted form of phishing where attackers tailor their emails or
messages to specific individuals or groups. They may use information obtained from social media
or other sources to make the message appear more convincing and increase the likelihood of the
victim falling for the scam.
(c) Smishing: This is a type of phishing that uses text messages to trick victims into disclosing their
information. Attackers may send fraudulent text messages that appear to be from a legitimate
source, such as a bank or delivery service, and prompt the victim to click on a link or provide their
personal information.
8. Precautions to avoid phishing:
(a) Never open or download a file from an unsolicited email, even from someone we know.
(b) Keep operating system updated
(c) Use a trusted antivirus program
(d) Enable two-factor authentication whenever available
(e) Confirm the authenticity of a website prior to entering login credentials by looking for a reputable
security trust mark
(f) Look for HTTPS in the address bar when you enter any sensitive personal information on a website
to make sure your data will be encrypted
9. The procedure followed by the police to track and investigate cybercrime cases may vary depending
on the nature and severity of the crime, as well as the jurisdiction where the crime was committed.
However, some general steps that are typically followed in cybercrime investigations include:
(a) Receiving a complaint
(b) Conducting a preliminary investigation
(c) Identifying and locating suspects
(d) Obtaining a search or arrest warrant
(e) Making an arrest and conducting interviews
(f) Presenting evidence in court
10. Cyber forensics is an electronic discovery technique used to determine and reveal technical criminal
evidence. It often involves electronic data storage extraction for legal purposes. Although still in its
infancy, cyber forensics is gaining traction as a viable way of interpreting evidence. Cyber forensics is
also known as computer forensics.
The various capabilities of cyber forensics are:
(a) Recover deleted files
(b) Find out what external devices have been attached and who have access to them
(c) Determine what programs have been run
(d) Recover web pages
(e) Recover emails and users who read them
(f) Recover chat logs
(g) Determine file servers used
(h) Discover a document’s hidden history
(i) Recover phone records and text messages from mobile devices
(j) Find malware and data collected
11. There are several precautions that can be taken to prevent students from unknowingly engaging in
cybercrime:
(a) Educate students about cyber ethics
(b) Teach responsible use of technology
(c) Use monitoring and filtering software
(d) Encourage reporting of suspicious activity
(e) Emphasize password security
(f) Set guidelines for online behaviour
(g) Teach digital citizenship
Teacher’s Manual Computer Science with Python–XI 59

[Link] Licences, exclusive rights in the software are retained with the owner/developer/ publisher.
They reserve all the freedoms and rights to use and distribute this proprietary software.
Free and Open-source Licence refers to a software that users can safely run, adapt and redistribute
without legal restraint and which emphasizes on freedom.
Open-source software is a software with source code that is publicly available under a licence that gives
users the right to study, change and distribute that software and emphasizes on security, cost-saving
and transparency.
13. Biometric authentication systems are generally considered to be more secure than traditional
authentication methods such as passwords, as biometric characteristics are unique to each individual
and cannot be easily replicated or stolen.
14. Ethics and law are closely related but are not the same thing. Ethics refers to the principles of right
and wrong that govern behavior, while law refers to a set of rules and regulations that are enforced by a
governing authority.
15. Fairness and ethics are related concepts but they have different meanings in the context of law.
Fairness generally refers to the idea that similar cases should be treated similarly. This principle is
often embodied in the concept of equal protection under the law. It means that the law should be applied
equally to all individuals, regardless of their race, gender, religion, or other personal characteristics.
Fairness also implies that people should have access to due process, which means that they have the
right to a fair trial, the right to present evidence, and the right to be heard.
Ethics refers to a set of moral principles that guide individual behaviour. Ethics are not necessarily
codified into law, but they can influence how laws are interpreted and applied. Ethical considerations
in law may include issues such as whether a particular law is just or unjust, whether a legal practice is
morally acceptable, or whether a lawyer’s actions are ethical.
16. Ethical norms and the law differ in their source, enforcement, scope, flexibility and consequences. Ethical
norms are based on moral beliefs and personal values, while laws are formal rules established and
enforced by governments. Ethical norms are not legally binding and rely on personal conscience, societal
expectations, and cultural influences. In contrast, laws are legally enforceable and carry penalties for
non-compliance. Ethical norms can be more flexible and subject to change over time, while laws are more
rigid and require formal processes for modification.
17. Threat, vulnerability and risk are three related concepts that are often used in the context of security
and risk management. While they are related, they have distinct meanings:
(a) Threat: A threat is a potential danger or harm that could be caused by an event, action, or object.
For example, a natural disaster like a hurricane or a malicious cyber attack are both threats.
(b) Vulnerability: Vulnerability refers to weaknesses or gaps in security that can be exploited by a
threat. For example, a building with weak locks or a computer system with outdated software are
both vulnerable to threats.
(c) Risk: Risk is the likelihood or probability of a threat exploiting a vulnerability and causing harm
or damage. Risk is often expressed in terms of the likelihood of an event occurring and the potential
impact of that event.
[Link] goal of information security within an organization is to protect the confidentiality, integrity,
and availability of its information assets. This means ensuring that the organization’s sensitive and
confidential information is kept secure from unauthorized access, alteration, or destruction.
Information security aims to achieve the following goals:
(a) Confidentiality: Ensuring that sensitive information is kept private and only accessed by
authorized individuals.
(b) Integrity: Ensuring that information is accurate, complete, and has not been tampered with.
(c) Availability: Ensuring that information is available to authorized individuals when needed.
(d) Authenticity: Ensuring that information is genuine and has not been falsified.
(e) Non-repudiation: Ensuring that the parties involved in a transaction cannot deny their
involvement or the authenticity of the transaction.
60 Teacher’s Manual Computer Science with Python–XI

[Link] are many ways to secure a system from cyber attacks, and the specific methods used will depend
on the type of system, the nature of the threats faced, and the available resources.
Here are some common methods:
(a) Use strong passwords and two-factor authentication to protect against unauthorized access to user
accounts.
(b) Regularly update software and systems to ensure they are protected against known vulnerabilities
and threats.
(c) Use firewalls and other network security devices to monitor and control network traffic.
(d) Implement intrusion detection and prevention systems to identify and block malicious activity.
(e) Use encryption to protect sensitive data both in transit and at rest.
(f) Conduct regular security audits to identify vulnerabilities and risks.
(g) Train employees on best practices for information security, such as not clicking on suspicious links
or opening unknown attachments.
(h) Have a disaster recovery plan in place in case of a cyber attack or data breach.
(i) Limit access to sensitive information to only those who need it, and implement role-based access
controls to ensure that employees only have access to the information they require to perform their
job duties.
(j) Conduct regular penetration testing to identify vulnerabilities and test the effectiveness of existing
security measures.
20. Biometrics is the use of unique physical characteristics or behaviours of individuals to identify and
authenticate their identity. Here are some advantages of using biometrics in schools:
(a) Increased security
(b) Improved attendance tracking
(c) Streamlined administrative processes
(d) Enhanced student safety
(e) Reduced administrative costs
[Link] terms ‘hacker’ and ‘cracker’ are often used interchangeably, but they actually have different
meanings.
A hacker is someone who is skilled in computer programming and has an in-depth understanding of
computer systems and networks. Hackers are often associated with the concept of ‘ethical hacking,’
which involves using their knowledge and skills to identify and fix security vulnerabilities in computer
systems, often at the request of the system owner.
A cracker, on the other hand, is someone who uses their computer skills and knowledge to gain
unauthorized access to computer systems and networks, often for malicious purposes. Crackers are often
associated with cybercrime, such as stealing personal information, spreading malware, or committing
identity theft.
[Link] downloads from the internet involve violation of copyright laws where users download material,
such as music, movies and other forms of media, without properly purchasing the product or doing so
without proper permission of copyright holder. Hence, illegal downloads result in digital piracy.
The repercussions of illegal downloads can be severe. Here are some potential consequences:
(a) Legal action
(b) Damage to reputation
(c) Increased security risks
[Link] has had a significant impact on society in many ways. It has transformed the way we
communicate, work, learn and live. One example of how technology has impacted society is through the
rise of social media.
Social media platforms, such as Facebook, Twitter and Instagram, have fundamentally changed the way
we interact with each other and consume information. They have made it easier for people to connect
with friends and family, stay informed about news and events, and share their thoughts and opinions
with a wide audience.
Teacher’s Manual Computer Science with Python–XI 61

24. Social media networks have many benefits, they also have several drawbacks. Some of the main
drawbacks of social media networks include:
(a) Cyberbullying: Social media platforms have been linked to increased rates of cyberbullying, which
can have a negative impact on mental health and well-being.
(b) Privacy concerns: Social media platforms collect vast amounts of personal data on their users,
which has raised concerns about how that data is being used and who has access to it.
(c) Addiction: Social media can be addictive, leading to compulsive behavior and negative impacts on
productivity and mental health.
(d) Spread of misinformation: Social media platforms have been criticized for allowing the spread of
fake news and misinformation, which can have serious consequences for democracy and public
health.
(e) Online harassment: Social media platforms can also be a breeding ground for online harassment
and hate speech, which can create a hostile and toxic online environment.
25. Here are five of the most popular social media sites:
(a) Facebook
(b) YouTube
(c) Instagram
(d) Twitter
(e) LinkedIn
26. Plagiarism is copying someone else’s work and then passing it off as one’s own. It is morally wrong
because it is an act of stealing. In other words, it is copying information and not giving the author credit
for it.
Copying programs written by other programmers and claiming them as their own could be an act of
plagiarism. It involves lying, cheating, theft and dishonesty.
27. Differences between the following:
(a) Phishing and Identity theft
Phishing – Phishing is an unlawful activity where fake websites or emails that look original or
authentic are presented to the user to fraudulently collect sensitive and personal details, particularly
usernames, passwords, banking and credit card details.
Identity Theft – This entails the use of another person’s personal information, without appropriate
consent, for the purpose of fraudulent practices. Often personal information may even be leaked
online or stolen during web surfing.
(b) Copyright infringement and Trademark Infringement
Copyright Infringement refers to the unauthorized use, production, distribution or display of
someone else’s copyrighted work without the owner’s permission. It protects original creative works
such as books, music, films, software, artwork, etc.
Trademark infringement is defined as the unauthorized use of a trademark or service mark on or
in connection with goods and/or services in a manner that is likely to cause confusion, deception, or
mistake about the source of the goods and/or services. Trademark owners can take legal action if
they believe their marks are being infringed.
(c) Proprietary and Free and Open-source software
In Proprietary, exclusive rights in the software are retained with the owner/developer/ publisher.
They reserve all the freedoms and rights to use and distribute this proprietary software.
Free and Open-Source Software (FOSS) allow users to not only access but also modify (or improve)
them as their source code is also available.
62 Teacher’s Manual Computer Science with Python–XI

28. (a) Identity theft: This is when someone uses another person’s personal information, such as their
name, date of birth, social security number, or other identifying information, without their consent.
This can lead to financial fraud, opening credit accounts, or committing other illegal activities in
the victim’s name.
(b) Credit card account theft: This is when someone obtains another person’s credit card information,
such as the card number, expiration date, and security code, without their consent. This can lead
to unauthorized purchases, fraudulent charges, and other financial losses for the victim.
29. The different types of intellectual property are:
(a) Patents
(b) Trademarks
(c) Copyrights
30. The cybercrime discussed in this scenario is ‘Phishing’. Phishing is a type of online fraud where
cybercriminals send fraudulent emails or messages that appear to be from a legitimate organization to
trick individuals into revealing sensitive information such as login credentials, social security numbers,
or credit card information.
In this scenario, Ravi received an email that appeared to be from the IRS department, with a link to
an official-looking website. On clicking the link, he was taken to the website where he uploaded some
important information. However, the website was a fake one, created by cybercriminals to steal Ravi’s
sensitive information.
31. The cybercrime being discussed in the above example is ‘Copyright Infringement’. Copyright infringement
is the unauthorized use or reproduction of someone else’s creative work, such as text, images, music, or
software, without their permission.
In this scenario, Rajni downloaded a PowerPoint presentation from the internet and then sent it to
Shreya after changing the name to ‘made by Rajni’, suggesting that she had created the presentation
herself. However, by doing so, Rajni has infringed upon the copyright of the original creator of the
presentation.
32. Trademark: A trademark includes any visual symbol, word, name, design, slogan, label, etc., that
distinguishes a brand or commercial enterprise from other brands or commercial enterprises. For
example, no company other than Reebok can use the Reebok brand to sell shoes or clothes. It also
prevents others from using a confusingly similar mark, including words or phrases, such as ‘Reebokk’.
However, it may be possible to apply for the Reebok trademark for unrelated goods like textbooks.
Intellectual property: Intellectual property refers to creations of the intellect (hence the name);
inventions, literary and artistic works, symbols, names, images and designs used in commerce are part
of it.
Intellectual Property Rights (IPRs) are specific legal rights that allow their owner to completely benefit
from the use of their creation for a certain period of time. These rights also entitle them to prevent
others from using or dealing with their product without prior permission and force them to stop and
compensate for any damages.
33. Data privacy refers to the protection of personal information, such as name, address, contact details,
financial information, and other sensitive data, from unauthorized access, use, or disclosure. It involves
ensuring that individuals have control over their personal information and can determine how it is
collected, used, and shared by others.
Websites that you visit may collect a range of information about you, such as:
(a) Personal information (b) Browsing history
(c) Cookies (d) Device information
(e) Location data (f) Social media activity
Teacher’s Manual Computer Science with Python–XI 63

34. Confidentiality of information refers to the protection of sensitive and private information from
unauthorized access, use, or disclosure. It is a critical component of information security, particularly
when it comes to safeguarding personal and sensitive information, such as medical records, financial
information, trade secrets, and other proprietary data.
Confidentiality is maintained by restricting access to sensitive information to only those who are
authorized to view it. This can be done by implementing access controls, such as passwords, biometric
authentication, and other security measures, to prevent unauthorized access.
35. Some common social networking sites are:
(a) Facebook
(b) Twitter
(c) LinkedIn
(d) Instagram
(e) Snapchat
(f) Pinterest
(g) Reddit
(h) Tumblr
(i) YouTube
36. Digital Footprints is the term used to describe the trail, traces or ‘footprints’ that people leave online
while using smartphones, tablets, computers, etc. Digital footprints are recorded with each and every
online activity that we perform—be it interactions on the social media, chatting and connecting with
friends on the social media sites, online shopping, or locations through Facebook check-ins, etc.
Digital footprints are classified into two types:
(a) Active digital footprints
(b) Passive digital footprints
64 Teacher’s Manual Computer Science with Python–XI

Chapter 11: Cyber Safety


1. Using an incognito window or private browsing mode can be useful in certain situations, but it may not
always be necessary or effective in protecting your privacy online.
When you use an incognito window or private browsing mode, your browser doesn’t save your browsing
history, cookies, or temporary files. This can be useful if you don’t want other people who use the same
device to see your browsing history or if you want to keep your search history private.
2. True or False.
(a) True
(b) True
(c) False
3. Here are some tips for safe internet browsing:
(a) Keep your software and operating system up to date: Regularly install updates and
security patches for your browser, operating system, and other software to protect against known
vulnerabilities.
(b) Use a reputable antivirus program: Install and regularly update a good antivirus program to
protect against malware and viruses.
(c) Be cautious of suspicious links: Avoid clicking on links from suspicious or unknown sources,
and hover over links to see where they lead before clicking on them.
(d) Use strong and unique passwords: Use complex passwords that are unique for each website or
service you use, and consider using a password manager to securely store your passwords.
(e) Enable two-factor authentication: Enable two-factor authentication on your online accounts
whenever possible to add an extra layer of security.
(f) Avoid using public Wi-Fi: Public Wi-Fi networks can be insecure and potentially allow others to
intercept your data. If you must use public Wi-Fi, use a virtual private network (VPN) to encrypt
your traffic.
(g) Be careful what you download: Only download software and files from reputable sources, and
scan them with antivirus software before opening them.
(h) Use an ad blocker: Install an ad blocker to prevent potentially malicious ads from being displayed
on websites you visit.
4. Some safe browsing tips are given below:
(a) Before you start—Update your software: Protect yourself before you start browsing the web by
making sure that your operating system, web browser, security software, browser plug-ins (like
Java or Adobe products) and other applications are up-to-date.
(b) Protect your web browser (and let your web browser protect you): You can adjust settings in your
web browser to work in a more or less secure way.
(c) Observe safe online behaviour: You should observe the following measures when browsing the web
to significantly reduce your risk of being a victim of cybercrime:
(i) Use strong unique passwords online.
(ii) Download files and applications only from those websites that you trust.
(iii) Pause and think before clicking on links in email, messages or on social networking sites.
Don’t click on links in messages if you don’t know the sender or if the message is unexpected.
(iv) If a link looks suspicious or you can’t tell where it leads to, before clicking, hover over that link
to see the actual web address it will take you to (usually shown at the bottom of the browser
window).
(v) Beware of offers that seem too good to be true.
Teacher’s Manual Computer Science with Python–XI 65

5. Google Chrome is generally considered a safe browser for browsing the internet. Google has a dedicated
security team that works to identify and fix security issues in the browser.
However, like any software, Google Chrome is not immune to security vulnerabilities. Cybercriminals
may attempt to exploit these vulnerabilities to infect your device with malware, steal your personal
information, or perform other malicious actions.
6. Cyber safety is the safe and responsible use of information and communication technology. It is not only
about keeping information safe and secure but also about being responsible with that information, being
respectful of other people online, and using ‘netiquette’ (internet etiquette).
7. Here are four tips for cyber safety:
(a) Use strong passwords: Use unique, complex passwords for each of your accounts, and consider
using a password manager to securely store them.
(b) Keep your software up to date: Regularly install updates and security patches for your operating
system, applications, and antivirus software.
(c) Be cautious of suspicious links and downloads: Avoid clicking on links or downloading files
from suspicious sources or websites, as they may contain malware or viruses.
(d) Enable two-factor authentication: Enable two-factor authentication on your accounts whenever
possible to add an extra layer of security. This requires a second form of identification, such as a
text message or fingerprint scan, to access your account, even if your password is compromised.
8. Private browsing, also known as incognito mode or privacy mode, is a feature available on most modern
web browsers that allows users to browse the internet without leaving a trace of their activity on the
computer or device they are using.
When private browsing mode is enabled, the browser does not save any data related to the browsing
session, such as cookies, search history or temporary files. This can be useful if we want to keep your
online activity private or if we are using a shared device and do not want others to see your browsing
history.
9. If cyber safety is overlooked, there are several potential dangers that could arise, including:
(a) Identity theft: Cybercriminals can use stolen personal information to impersonate you and carry
out fraudulent activities such as opening bank accounts or applying for credit cards in your name.
(b) Financial loss: Cybercriminals can use stolen financial information to make unauthorized
transactions, drain bank accounts or commit other financial crimes.
(c) Malware infections: Malware such as viruses, trojans, and ransomware can infect your device
and cause damage to your system, including stealing personal information, encrypting files and
rendering your device unusable.
(d) Cyberbullying and harassment: Overlooking cyber safety can expose you to online harassment
and cyberbullying from anonymous or known individuals, which can have serious emotional and
psychological consequences.
10. The IP address (Internet Protocol address) is a unique numerical identifier assigned to each device
connected to a network that uses the Internet Protocol for communication. The IP address plays a crucial
role in networking by identifying and locating devices on the internet.
Here are some of the important roles of IP addresses in networking:
(a) Device identification (b) Addressing and routing
(c) Location tracking (d) Security
11. Confidentiality is the term used to prevent disclosure of information to unauthorized individuals or
systems.
Data should be kept secret. The owner of the data has to decide who can access the data and who can’t.
One of the most common threats to confidentiality nowadays is Password Hacking in online money
transaction systems.
66 Teacher’s Manual Computer Science with Python–XI

12. A firewall is a network security system that monitors and controls incoming and outgoing network traffic
based on predetermined security rules. The role of a firewall is to protect a network and its devices from
unauthorized access, malicious traffic, and other cyber threats.
Here are some of the key roles of a firewall:
(a) Blocking unauthorized access (b) Traffic filtering
(c) VPN connectivity
13. Cookies are small text files on your computer storing small pieces of information related to your online
habits/text. They can identify you and track your browsing activity.
14. Websites can track us in various ways, some of which include:
(a) Cookies
(b) IP Address
(c) Browser Fingerprinting
(d) Social Media Tracking
15. (a) Rohit is experiencing targeted advertising based on his previous browsing behavior. When he
searched for wristwatches and footballs, he likely left behind cookies or other tracking data that
advertisers can use to serve him with relevant ads.
(b) To avoid targeted advertising, Robin could take the following steps:
(i) Use a private browsing mode or clear his browsing history and cookies after searching for
specific items.
(ii) Use an ad blocker or privacy extension on his web browser to prevent tracking scripts and
advertisements from being displayed.
(c) To stop getting targeted advertising, Robin could do the following:
(i) Clear his browsing history and cookies on his web browser.
(ii) Opt-out of personalized advertising settings on the websites he visits.
16. Gender discrimination refers to unfair treatment or prejudices based on a person’s gender, usually
towards women. It can take many forms, such as unequal pay, lack of job opportunities, stereotypes,
harassment, or exclusion from social, educational, or political activities.
In a classroom setting, gender discrimination can create a negative learning environment that can
affect both male and female students. Here are some ways gender discrimination can hamper classroom
teaching and learning process:
(a) Stereotyping (b) Classroom Interaction
(c) Curriculum Content (d) Harassment and Bullying
17. Viruses are programs that copy themselves throughout a computer or network. Viruses can only be
activated when a user opens the program. At their worst, viruses can corrupt or delete data, use the
user’s email to spread, or erase everything on the hard disk. If not checked, a virus can damage the
system or specific files which are important for the functioning of an operating system. It may also slow
down your computer as a result of replication of viruses in the background without being visible on the
screen.
18. Spyware: Malware that collects information about the usage of the infected computer and communicates
it back to the attacker is known as Spyware. Spyware mostly gets installed on your PC without your
consent. It finds its way into PCs by ‘piggybacking’ onto a file, or gets downloaded from the internet
when you visit a particular website.
Adware: Adware refers to a type of malware that displays unwanted advertisements on your computer
or device. Adware is commonly activated unknowingly when users are trying to install legitimate
applications that adware is bundled with.
Teacher’s Manual Computer Science with Python–XI 67

19. While both worms and Trojan horses are types of malicious software or malware, there are some key
differences between the two:
(a) Replication
(b) Method of spreading
(c) Purpose
(d) Level of damage
20. Malware and worm are two types of malicious software that can cause harm to a computer system or
network. While they share some similarities, they have different characteristics and functions.
Malware is an umbrella term that refers to any software designed to harm a computer system or network.
Malware can include viruses, trojans, spyware, adware, and other types of malicious software. Malware
can infect a computer system through email attachments, infected downloads, or vulnerable software.
Worms, on the other hand, are a type of self-replicating malware that spreads across networks and
computers, usually without the user’s knowledge or consent. Worms can cause significant damage
to a network by consuming bandwidth, overloading servers, and installing additional malware on
compromised computers. Worms can spread through network vulnerabilities, email attachments, or
infected downloads.
21. Secure connection is necessary while doing net banking because it involves the transfer of sensitive
and confidential information, such as personal identification numbers (PINs), account numbers and
transaction details. These details can be intercepted by hackers or unauthorized third parties if the
connection is not secure, potentially leading to financial fraud or identity theft.
22. WhatsApp provides end-to-end encryption for its users’ messages, which means that only the sender
and the recipient can read the messages, and no one else, including WhatsApp itself, can access the
message content. This encryption is designed to protect user privacy and ensure that messages are not
intercepted or tampered with by unauthorized third parties.
23. To identify whether a website is safe or not, you can look at the URL and other indicators in your web
browser. Here are some ways to identify whether a website is safe or not based on the URL:
(a) Check for ‘https’
(b) Look for the padlock.
(c) Check the domain name
(d) Use a website safety checker
(e) Look for trust seals
24. A secure connection is a connection that is encrypted by one or more security protocols to ensure the
security of data flowing between two or more nodes. When a connection is not encrypted, it can be easily
listened to by anyone and is even prone to threats by malicious software and rogue and unexpected
events. Anyone who wants to get information from a non-secured connection can do so since they can
easily go through the computer’s network taking with them important data such as login, passwords and
other private information.
Secure connections, as they are supposed to protect data being transferred from one computer to another,
must be able to do three main tasks:
(a) Prevent third parties from getting hold of confidential data.
(b) Validate identification of the person first who wishes to access and exchange data.
(c) Protect information from being viewed or altered by unknown parties.
25. HTTP vs HTTPS
When we request an HTTPS connection to a web page, the website will initially send its SSL certificate
to your browser. This certificate contains the public key needed to begin the secure session. Based on this
initial exchange, your browser and the website then initiate the ‘SSL (Secure Socket Layer) handshake’.
The SSL handshake involves the generation of shared secrets to establish a uniquely secure connection
between ourself and the website.
68 Teacher’s Manual Computer Science with Python–XI

When a trusted SSL Digital Certificate is used during a HTTPS connection, users will see a padlock
icon in the browser address bar. When an Extended Validation Certificate is installed on a website, the
address bar will turn green.
All communications sent over regular HTTP connections are in ‘plain text’ and can be read by any hacker
that manages to break into the connection between your browser and the website. This presents a clear
danger if the ‘communication’ is on an order form and includes your credit card details or social security
number. With an HTTPS connection, all communications are securely encrypted. This means that even
if somebody manages to break into the connection, they would not be able to decrypt any of the data
which passes between you and the website.
26. There are many websites that use HTTPS, but here are two examples:
(a) Google: [Link]
(b) Facebook: [Link]
27. To ensure confidentiality of information, here are some best practices to follow:
(a) Use strong passwords
(b) Enable two-factor authentication
(c) Be cautious about sharing personal
(d) Use encryption
(e) Keep software up-to-date
(f) Use a password manager
(g) Be mindful of phishing scams
28. Identity theft is a type of fraud that involves using someone else’s identity to steal money or gain other
benefits. Online identity theft refers to an act of stealing someone’s personal information such as name,
login details, credit card details, etc., and then posing as that person online. The intent is to use that
identity for personal gains, generally with the intent to cheat others.
To prevent identity theft:
(a) Never share your password or account numbers over email or instant messaging.
(b) Do not follow links from emails while conducting financial transactions; instead enter the URL
yourself.
(c) Be wary of callers, pop-ups, websites, or emails asking for personal information.
(d) Look for ‘https’ or a picture of a lock before purchasing from a website or giving out information on
that website. Create a secure password and change it often.
(e) Install firewall, anti-spyware and anti-virus software and update it often.
29. Cyber law in India is implemented through the Information Technology Act, 2000, which was enacted to
provide legal recognition to electronic transactions and to protect electronic data from cybercrime. The
Act has been amended several times.
30. The Information Technology Act, 2000 is the primary law in India dealing with cybercrime and electronic
commerce. The original Act contained 94 sections, divided into 13 chapters and 4 schedules. The laws
apply to the whole of India. Persons of other nationalities can also be indicted under the law if the crime
involves a computer or network located in India.
31. Child pornography is publishing and transmitting obscene material about children in electronic form. In
recent years, child pornography has increased due to easy access to the internet and easy availability of
online videos. Child pornography is the most heinous crime and has led to various other crimes such as
sex tourism, child abuse, etc.
32. Cybercrime can have a significant impact on our daily lives in several ways:
(a) Financial loss (b) Privacy invasion
(c) Online harassment (d) Disruption of services
(e) Spread of misinformation
Teacher’s Manual Computer Science with Python–XI 69

33. There are several methods that individuals and organizations can use to prevent and protect themselves
from cybercrime. Here are two examples:
(a) Two-factor authentication (2FA): 2FA is a security process that requires users to provide two
different authentication factors to access an account or service. Typically, this involves providing
something the user knows (such as a password) and something the user has (such as a code
generated by a mobile app). By requiring two factors, 2FA adds an extra layer of security and
makes it more difficult for cybercriminals to gain unauthorized access. Many online services now
offer 2FA as an option, and it is highly recommended to use it whenever possible.
(b) Regular software updates and patches: Cybercriminals often exploit vulnerabilities in software
to launch attacks. Software vendors release updates and patches to fix these vulnerabilities, so it
is essential to keep software up-to-date to prevent attacks. Individuals and organizations should
regularly check for software updates and apply them promptly. This includes not just operating
systems and antivirus software, but also web browsers, plug-ins, and other applications.
34. Protecting oneself from online fraud requires a combination of awareness, prevention and response.
Here are some steps that individuals can take to protect themselves from online fraud:
(a) Educate yourself: The first step to protecting yourself from online fraud is to educate yourself
about common types of scams and frauds.
(b) Use strong passwords: Use strong and unique passwords for all your online accounts. A strong
password is one that is difficult to guess or crack.
(c) Be cautious of suspicious emails and links: Cybercriminals often use email and social media
to spread malware or phishing scams. Be wary of unsolicited emails or messages, especially those
that contain suspicious links or attachments.
(d) Use antivirus software: Antivirus software can detect and remove malware and other malicious
programs from your computer. It is essential to keep your antivirus software up-to-date and to
run regular scans to ensure that your system is free from viruses and other threats. Be sure to
download antivirus software only from trusted sources.
(e) Use secure websites: When you are making online transactions or providing personal information,
make sure that the website is secure. Look for the padlock icon in the address bar and ensure that
the URL starts with “https” instead of “http”.
35. Here are four steps to combat cybercrime:
(a) Use strong and unique passwords: The first step in protecting yourself from cybercrime is to
use strong and unique passwords for all your online accounts. A strong password is one that is
difficult to guess or crack.
(b) Be cautious of suspicious emails and links: Cybercriminals often use email and social media to
spread malware or phishing scams. Be wary of unsolicited emails or messages, especially those that
contain suspicious links or attachments. If you receive an email from a company or organization,
double-check the sender’s email address and verify that the request is legitimate before clicking
any links or providing any personal information.
(c) Use antivirus software: Antivirus software can detect and remove malware and other malicious
programs from your computer. It is essential to keep your antivirus software up-to-date and to
run regular scans to ensure that your system is free from viruses and other threats. Be sure to
download antivirus software only from trusted sources.
(d) Keep your software up-to-date: cybercriminals often exploit vulnerabilities in software to
launch attacks. It is essential to keep your software up-to-date to prevent these attacks.
36. Social networking platforms can be responsible for cybercrime in several ways. Here are a few examples:
(a) Phishing attacks
(b) Malware distribution
(c) Cyberbullying and harassment
(d) Privacy violations

Common questions

Powered by AI

To maintain confidentiality, use access controls, such as passwords and biometric authentication, to restrict access to authorized individuals only . Additionally, implementing encryption and secure communication protocols further ensures protection against unauthorized access .

Private browsing prevents the storage of browsing history, cookies, and temporary files, useful for maintaining privacy on shared devices . However, it doesn't stop websites from tracking your activity or your ISP from logging your browsing history, thus not a full privacy solution .

Social networking sites contribute to digital footprints by recording every interaction, which includes posts, likes, shares, and location check-ins, leaving a trail of online activity classified into active and passive footprints .

A light pen is effective for selecting or drawing directly on a screen, beneficial in graphic design or CAD applications where precision input is required. It can also be used in interactive kiosks or educational tech for direct manipulation on screens .

ROM is non-volatile memory where data and instructions are pre-placed and cannot be changed, making it slower than RAM and suitable for initial hardware checks and essential functions . RAM is volatile, allowing data to be read and written, facilitating faster access for active processes, but loses content when power is off .

An IP address is crucial for identifying and locating devices on the internet, and its misuse can lead to unauthorized tracking, location identification, and potentially enabling attacks like hacking or unauthorized access, compromising an individual's privacy and security .

Primary memory, also known as main memory, is directly accessible by the CPU and is used to hold active information of data and instructions, making it volatile because it loses its content when power is interrupted . Secondary memory, or auxiliary memory, includes magnetic storage devices and is non-volatile, meaning it retains data after power loss .

Insertion sort tends to be more efficient than bubble sort because it inserts elements into their correct positions with fewer comparisons and swaps. While both have a worst-case time complexity of O(n²), insertion sort performs better on partially sorted lists and avoids unnecessary comparisons .

Impact printers create text and images by physically striking an inked ribbon onto paper, suitable for carbon copy requirement environments . In contrast, laser printers utilize a laser beam to develop an image on a drum using toner, then transfer and fuse it onto paper, offering higher precision and speed without physical impact .

The 'insert' method places an item at a specified index and expands the list, while 'append' adds an element to the end of the list . 'Insert' can alter the list's ordering by shifting elements, while 'append' maintains the original order .

You might also like