0% found this document useful (0 votes)
29 views60 pages

IP XI Question Bank

The syllabus for Class XI IP (2023-2024) covers topics including computer systems, Python programming, database concepts, and emerging trends in technology. Key areas include hardware components, software types, Python basics, and SQL commands. The document also includes objective questions and assertion-reason based questions to assess understanding of the material.
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)
29 views60 pages

IP XI Question Bank

The syllabus for Class XI IP (2023-2024) covers topics including computer systems, Python programming, database concepts, and emerging trends in technology. Key areas include hardware components, software types, Python basics, and SQL commands. The document also includes objective questions and assertion-reason based questions to assess understanding of the material.
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
You are on page 1/ 60

Syllabus of Class XI IP (2023-2024)

Topics to be-covered Th. Pr.


Unit1:Introduction to Computer System 10
• Introduction to computer and computing: evolution of computing devices,
components of a Computer System and their inter connections,Input/Output
devices.
• Computer Memory: Units of memory,types of memory–primary and
secondary,data deletion,its recovery and related security concerns.
• Software: purpose and types – system and application software, generic and
specific purpose software
Unit2:Introduction to Python 35 28
• Basics of Python programming,Python interpreter-interactive and script
mode, the structure of a program,
• Indentation,identifiers,keywords,constants,variables,types of
operators,precedence of operators,data
• Types,mutable and immutable data types,
statements,expressions,evaluationand comments, input and output
statements,
• Data type conversion,debugging.
• Control Statements:if-else,if-elif-else, while loop,forloop
• Lists: list operations-creating,initializing,traversing and manipulating lists,list
methods and built-infunctions.– len(),list(),append(),insert(),
count(),index(),remove(), pop(), reverse(), sort(), min(),max(),sum()
• Dictionary:conceptof key-value pair,
creating,initializing,traversing,updating and deleting elements,dictionary
methods and built-infunctions.– dict(), len(), keys(), values(), items(),
update(), del(), clear()
Unit3:Database concepts and the Structured Query Language 17 7
• Database Concepts: Introduction to database concepts and its need, Database
Management System.
• Relational data model: Concept of domain, tuple,relation, candidate key,
primary key, alternate key
• Data Query: SELECT, FROM, WHERE with relational operators, BETWEEN,
logical operators, IS NULL, IS NOT NULL
• Data Manipulation: INSERT, DELETE,UPDATE
Unit4:IntroductiontotheEmergingTrends 7
• Artificial Intelligence, Machine Learning, Natural Language Processing
,Immersive experience(AR,VR),Robotics,Big data and its characteristics,
Internet of Things(IoT), Sensors, Smart cities, Cloud Computing and Cloud
Services(SaaS, IaaS,PaaS);Grid Computing, Block chain technology

PAGE:6
Name of the chapter : Introduction to Computer System
Topic Covered

• Introduction to computer and computing: evolution of computing devices, components


of a Computer System and their inter connections,Input/Output devices.
• Computer Memory: Units of memory,types of memory–primary and secondary,data
deletion,its recovery and related security concerns.
• Software: purpose and types – system and application software, generic and specific
purpose software
Key Points
Hardware:-Computer hardware refers to the physical components of a computer system,
including the central processing unit (CPU), memory, storage devices, input devices
(keyboard, mouse), output devices (monitor, printer), and other peripherals. It encompasses
the tangible, electro-mechanical, and electronic elements that constitute a computer and
enable its functioning.
Integrated Circuit:An Integrated Circuit (IC) is a compact assembly of interconnected
electronic components, such as transistors, resistors, and capacitors, fabricated on a
semiconductor substrate. This miniaturized arrangement enables the creation of complex
electronic circuits, forming the basis of modern microprocessors, memory chips, and various
electronic devices.
Input Devices:Computer input devices are hardware components that allow users to provide
data and commands to a computer system. Examples include keyboards for typing, mice for
pointing and clicking, and scanners for converting physical documents into digital form.
These devices enable users to interact with and input information into the computer.
Output Devices:Computer output devices are hardware components that present or display
processed information from a computer to the user. Examples include monitors for visual
output, printers for producing hard copies of documents, and speakers for audio output. These
devices convey the results of computations and operations performed by the computer.
Central Processing Unit:The Central Processing Unit (CPU) is the primary component of a
computer responsible for executing instructions from programs. Acting as the "brain" of the
system, it performs arithmetic and logic operations, manages data, and coordinates the
functioning of other hardware components, crucial for overall computing functionality and
speed. It consists of Arithmetic Logic Unit, Control Unit & Registers
Arithmetic Logic Unit: The Arithmetic Logic Unit (ALU) is a fundamental component of a
computer's central processing unit (CPU) responsible for performing arithmetic and logical

PAGE:7
operations on binary data. It executes tasks like addition, subtraction, AND, OR, and other
operations, crucial for processing and manipulating information within the computer system.
Control Unit:The Control Unit is a critical component of a computer's central processing
unit (CPU) that manages and coordinates the execution of instructions. It decodes program
instructions, directs data flow within the CPU and between other system components, and
controls the overall operation of the processor to execute tasks in a programmed sequence.
Memory:Computer memory refers to the electronic components that store data and
instructions temporarily or permanently for processing by a computer. It includes RAM
(Random Access Memory) for temporary storage and ROM (Read-Only Memory) for
permanent storage. Memory is crucial for the execution and retrieval of information during
computer operations.
Primary Memory:Primary memory, also known as main memory or RAM (Random Access
Memory), is a volatile and fast-access computer storage that temporarily stores data and
instructions for the CPU. It plays a critical role in actively running programs and allows
quick access to information needed for ongoing computational tasks.
Secondary Memory:Secondary memory refers to non-volatile storage devices in a computer
system, such as hard drives, solid-state drives, and external storage. Unlike primary memory
(RAM), it retains data even when the power is off. Secondary memory is used for long-term
storage of files, applications, and the operating system.
Registers:Memory registers are small, high-speed storage locations within a computer's
central processing unit (CPU). They temporarily hold data and instructions that the CPU is
actively processing. Registers play a crucial role in facilitating quick access to information
and supporting the efficient execution of instructions during program operation.
Cache Memory:Cache Memory is a high-speed volatile computer memory located between
the central processing unit (CPU) and main memory. It stores frequently accessed data and
instructions to expedite retrieval, enhancing overall system performance by reducing the time
it takes for the CPU to access frequently used information during program execution.
System Bus:The System Bus is a communication pathway that connects the major
components of a computer system, facilitating data transfer between the central processing
unit (CPU), memory, and peripheral devices. It comprises the address bus, data bus, and
control bus, coordinating the flow of information within the computer architecture.
Data Deletion-It is the simple process of deleting a file and placing it into the Recycle Bin or
Trash.
Data recovery-It is a process of retrieving deleted, inaccessible, lost, corrupted, damaged, or
formatted data from secondary storage/ removable media .
PAGE:8
Data security -It is the process of protecting corporate data and preventing data loss through
unauthorized access.
Software -It is basically a set of instructions or commands that tell a computer what to do.
System Software-It is a program designed to run a computer's hardware and applications and
manage its resources, such as its memory, processors, and devices.
Application Software-It is a type of computer program that performs a specific personal,
educational, and business function.
Generic software- Generic software is a system designed for general public usage.
Specific software-It is software that is created for a specific purpose, organization, or
individual.
30 Objective Question (1 Mark )
Q1. A computer is a/an ............ device.
a) Mechanical
b) Electrical
c) Electronic
d) Telecommunication
Ans c) Electronic
Q2. The physical components of the computer are known as
a) Software
b) Program
c) Hardware
d) Both A and C
Ans c) Hardware
Q3. Which of the following is not related to a personal computer:
a) Processor
b) Onboard
c) Motherboard
d) Keyboard
Ans b) Onboard
Q4. Which of the following is not a type of computer:
a) Smart Phone
b) Smart watch
c) Biometric
d) Tablet PC
Ans c) Biometric

PAGE:9
Q5. Which type of PC is available in your school computer laboratory?
a) IBM PC
b) Macbook
c) Chrome Book
d) Tablet PC
Ans a) IBM PC
Q6. Full form of ALU is:
a) Abacus Logarithmic Unit
b) Arithmetic Logic Unit
c) Abacus Language Unit
d) Arithmetic Language Unit
Ans b) Arithmetic Logic Unit
Q7. Which of the following is a part of ALU?
a) Arithmetic Unit
b) Control Unit
c) Logic Unit
d) Both a) and c)
Ans d) Both a) and c)
Q8. First binary programmable computer based on Von Neumann architecture is:
a) UNIVAC
b) EDVAC
c) ENIAC
d) Mark I
Ans c) ENIAC
Q9. Arrange the following in increasing order of no of transistors on a single chip:
i) SLSI
ii) IC
iii) VLSI
iv) LSI
a) i) SLSI ii) IC iii) VLSI iv) LSI
b) ii) IC iii) VLSI iv) LSI i) SLSI
c) ii) IC iv) LSI iii) VLSI i) SLSI
d) iii) VLSI iv) LSI i) SLSI ii) IC
Ans c) ii) IC iv) LSI iii) VLSI i) SLSI

PAGE:10
Q10. Which of the following is the fastest memory?
a) RAM
b) Cache
c) ROM
d) Hard Disk
Ans b) Cache
Q11 Binary number system comprises of the digits:
a) 1, 2
b) 0, 1
c) a, b
d) i, ii
Ans b) 0, 1
Q12 ______ is volatile i.e. as long as the power is supplied to the computer, it retains the
data in it
a) RAM
b) CD
c) ROM
d) Hard Disk
Ans a) RAM
Q13 Arrange the following units of memory in decreasing order of storage
i) KB (Kilobyte)
ii) GB (Gigabyte)
iii) MB (Megabyte)
iv) TB (Terabyte)
a) iv) TB ii) GB i) KB iii) MB
b) ii) GB iv) TB i) KB iii) MB
c) iv) TB iii) MB i) KB ii) GB
d) iv) TB ii) GB iii) MB i) KB
Ans d) iv) TB ii) GB iii) MB i) KB
Q14 Which of the following is not an input device?
a) Scanner
b) Speakers
c) Webcam
d) Joystick
Ans b) Speakers

PAGE:11
Q15 ______ is an electronic pathway composed of cables which connects the major parts
of a computer system
a) Motherboard
b) Processor
c) Bus
d) Cache
Ans c) Bus
Q16. Which of the following cannot be the reason for data deletion from HDD?
a) Data lost due to shutting down the PC
b) Hacker attacking the system.
c) Bad sector in Hard Disk
d) Accidentally deleting a file.
Ans a) Data lost due to shutting down the PC
Q17. Which of the following is not a data recovery software?
a) Recuva
b) EaseUS
c) Disk Drill
d) Matlab
Ans d. Matlab
Q18. In which of the scenario do we need to recover data?
a) When disk is full.
b) When system performance has become slow.
c) When a photo or video has been accidentally deleted.
d) All of the above
Ans c) When a photo or video has been accidentally deleted.
Q19. Which of the following is an example of Proprietary software?
a) Linux
b) Windows
c) Mozilla Firefox
d) None of the above
Ans b) Windows
Q20. Cryptographic utilities are used to ___________ files to prevent unauthorized users.
a) Encrypt
b) Decrypt
c) Both of these
d) None of thse
Ans c) Both of these

Q21. Operating System is an example of


a) System software
b) Utility program
c) Application software
d) None of the above
Ans a) System software

PAGE:12
Q22. _________ is a software that can be freely downloaded and even distributed to
others.

a) Open source software


b) Liteware
c) Shareware
d) Freeware
Ans d) Shareware
Q23. Word processing and desktop publishing are the examples of

a) Hardware
b) Software
c) CPU
d) None of these
Ans Software
Q24. The full form of OSS is ________________
a) Operating system software
b) Operating source software
c) Open system software
d) Open source software
Ans d) Open source software
Q25. An antivirus software is an example of __________
a) System software
b) Pirated software
c) Freeware
d) Utility software
Ans d)Utility software
Q26 ___________________ is designed to solve a specific problem or to do a specific
task.

a) System software
b) Utility software
c) User
d) Application software
Ans d) Application software
Q27 Which of the following is not a feature of a compiler?

a) Execution time is more


b) When all the syntax errors are removed execution takes place
c) Scans the entire program first and then translate it into machine code
d) Slow for debugging
Ans a) Execution time is more
Q28 Which of the following is not an example of system software?
a) Language Translator
b) Utility Software
c) Communication Software
d) Word Processors
Ans e) Word Processors

PAGE:13
Q29 What is the process of deleting all the data on the hard drive?
a) Delete
b) Erase
c) Formatting
d) Uninstall
Ans c) Formatting
Q30 A general purpose software is a type of ______________
a) System software
b) Database software
c) Package software
d) Application software
Ans e) Application software

10 Assertion and reason Based question ( 1 Mark )

Q1. Assertion (A): Computers use binary code (0s and 1s) to represent and process data.
Reason (R): Binary code is the fundamental language of computers, where 0
represents OFF and 1 represents ON in the context of electronic switches.
Ans Both A and R are true and R is the correct explanation for A.
Q2. Assertion (A): Main/Primary memory is volatile.
Reason (R): ROM which is a part of main memory is non-volatile.
Ans A is False but R is True.
Q3. Assertion (A): The CPU (Central Processing Unit) is often referred to as the "heart"
of the computer.
Reason (R): The CPU is responsible for executing instructions and performing
calculations, similar to the human heart's processing capabilities.
Ans A is False but R is True.
Q4. Assertion (A): RAM (Random Access Memory) is volatile memory.
Reason (R): RAM retains its data even when the computer is powered off.
Ans A is True but R is False.
Q5. Assertion (A): A scanner is an output device that produces hard copies of digital
documents.
Reason (R): Scanners use sensors to capture images or text from paper documents,
making them available for digital processing and storage.
Ans A is False but R is True.
Q6. Assertion : It is always good to keep the passwords encrypted while storing.
Reason : Encrypted data cannot be easily stolen by hackers.
Ans Both A and R are true and R is the correct explanation for A

PAGE:14
Q7. Assertion : Windows 10 is a system software.
Reason : The software that protects a computer system from computer virus is system
software
Ans A is True but R is False.
Q8. Assertion : Not all types of software are system software.
Reason : Application software are designed to carry out operations for a specific
application.
Ans Both A and R are true and R is the correct explanation for A
Q9. Assertion : A software designed for a bank will work only for the account holders of
that bank.
Reason: Customized software are tailor made software according to user
requirements.
Ans Both A and R are true and R is the correct explanation for A
Q10. Assertion : A system software is also called as a manager.
Reason: Utility software assists the computer in maintaining it’s performance.
Ans Both A and R are true but R is not the correct explanation for A
10 Short Knowledge/Understanding/Application Based Questions (2 Marks)

Q1. Differentiate between RAM and ROM.


Ans .
RAM ROM
i) Full form is Random Access Full form is Read Only Memory
Memory
ii) RAM is volatile memory that ROM is non-volatile memory that
temporarily stores the files you are permanently stores instructions for your
working on. computer.
.
Q2. Where is cache memory located and what is its use?
Ans Cache memory is located on the CPU itself or very close to it, typically on the same
chip as the CPU.
The primary purpose of cache memory is to store frequently accessed data and
instructions, providing the CPU with faster access to this information than fetching it
from the main memory (RAM).
Q3. List out two arithmetic and two logical operators
Ans Arithmetic operators: + – * /
Logical operators: > ,< , >= , <=, = , !=
Q4. Where registers are located and what are their uses?
Ans Registers are located inside the central processing unit (CPU), and they are the
smallest, fastest, and most accessible form of memory within a computer.

PAGE:15
CPU uses registers to either hold processing information or to store some part of data
or some memory address or some instructions.
Q5. What is the function of Control Unit in a CPU?
Ans The functions of control unit are:
i) It controls instruction execution.
ii) It guides the interpretation, flow and manipulation of data.
Q6. Deleting digitally stored data means changing the details of data at bit level, which
can bevery time consuming. Therefore, when any data is simply deleted, its address
entry ismarked as free, and that much space is shown as empty to the user, without
actuallydeleting the data.
In case data gets deleted accidentally or corrupted, there arises a need to recover
thedata. Recovery of the data is possible only if the contents/memory space marked
asdeleted have not been overwritten by some other data.
i) Can you recover the data once deleted? Justify
ii) Give any one security threat involved when we throw away electronic gadgets that
are non-functional.
Ans i) Yes, by Data Recovery. Data recovery is a process of retrieving deleted,
corrupted and lost data from secondary storage devices.
ii) ii) If these storage devices fall into the hands of mischief-mongers, they
can easily 1 recover data from such devices; this poses a threat to data
confidentiality.
Q7. What are the two main categories of system software?
Ans The two main categories of system software are:
a) Operating system- It is a program which acts as an interface between the user
and the hardware.
b) Language processor- It is responsible for converting a High level code to
machine language.
Q8. What is data deletion? How does it work?
Ans Data deletion is the process where the data is deleted from the system either
accidentally or intentionally.
Deleting stored data means changing the details of data at bit level, which can be
very time consuming. Therefore when any data is simply deleted it’s address entry is
marked as free, and that much space is shown empty to the user.
Q9. What is the difference between system software and application software.
Ans System Software Application software
System software is mainly designed for Application softwareis mainly designed
managing system resources. to accomplish tasks for specific
purposes.
Programming of system software is Programming of application software is
complex. comparatively easy.
A computer cannot run without system A computer can easily run without an
software. application software.
System software do not depend on Application software do depend on
application software. system software.

PAGE:16
Q10. What is the difference between customized software and generic software.
Ans Customized software Generic software
Designed for a specific user’s or Designed for a broad range of users
organization’s needs. with general needs.
Specific maintenance and support Standard maintenance and support
required. required.
Longer development time required to Shorter development time required.
meet all the needs.

10 Short Knowledge/Understanding/Application Based Questions (3 Marks)


Q1. What is the IPO cycle in a computer?
Ans The IPO cycle, which stands for Input-Processing-Output cycle, is a fundamental
concept in computer science and information processing. It describes the sequence of
operations that a computer follows to process data and produce results.
Here's an overview of each phase in the IPO cycle:
• Input: In this phase, data or information is collected from external sources or
input devices, such as keyboards, mice, sensors, or storage devices like hard drives
and network connections. Input can be in the form of text, numbers, images, sound,
or any other data type.
• Processing: In the processing phase, the computer performs various
operations on the input data. This can include calculations, transformations,
comparisons, sorting, filtering, and executing instructions specified by software
programs.
• Output: After processing, the computer generates results or output data.
Output can take various forms, such as displaying information on a screen, printing a
document, saving data to storage, sending data over a network, or producing sound
through speakers.
Q2. List out at least three differences difference between cache memory and registers in a
computer?
Ans

Cache Memory Registers


i) Cache memory offers fast access Registers are the fastest form of memory
times but is slower than registers in a computer, with almost instant access
times.

PAGE:17
ii) Cache memory is located between Registers are part of the CPU's
the CPU and the main memory. It architecture and are located directly on
can be on the CPU chip itself. the CPU chip.
iii) Cache memory is used to store Registers are used for temporary storage
frequently accessed data and of data and instructions that are actively
instructions from the main being processed by the CPU. They are
memory, optimizing overall crucial for executing instructions and
system performance by reducing performing calculations.
memory latency.
.
Q3. Write the full forms of the following:
SMPS USB CRT UPS BIOS PROM

Ans SMPS → Switched-Mode Power Supply


USB → Universal Serial Bus
CRT → Cathode Ray Tube
UPS → Uninterruptible Power Supply
BIOS → Basic Input Output System
PROM → Programmable Read-Only Memory

Q4. Mr Rakesh has eleven CDs each of capacity 700 MB containing MP3 songs of
legendary singers of Bollywood. After few years he discovers that the CDs are
becoming corrupt. So he wants to transfer the songs to a pen drive for keeping them.
How much minimumcapacity pen drive should he purchaseif pen drives are available
in 2 GB, 4 GB, 8 GB and 16 GB sizes?

Ans Capacity of 1 CD=700 MB


Capacity of 11 CDs=700*11=7700 MB
1024 MB = 1 GB
So no of GB in 7700 MB=7700/1024=7.5 GB
Hence Mr.Rakesh should purchase a 8 GB pendrive to transfer the songs in the 11
CDs.

PAGE:18
Q5. Write at least three differences between keyboard and mouse.
Ans
Keyboard Mouse
i) A keyboard is primarily used for A mouse is primarily used for pointing,
entering text, numbers, and selecting, and interacting with graphical
various commands. It is the elements on the computer screen. It
primary input device for typing provides precise cursor control.
and text-based input.
ii) Users interact with a keyboard by Users move a physical mouse on a flat
pressing physical keys, each of surface, and the movement is translated
which corresponds to a specific into corresponding on-screen cursor
character or function. movements. Mice have buttons for
clicking and scrolling wheels for
navigating content.
iii) Keyboards are commonly used for Mice are commonly used for navigating
word processing, data entry, graphical user interfaces, selecting files
programming, web browsing, and and icons, gaming, graphic design, and
executing keyboard shortcuts. web browsing.
iv) Keyboards offer a range of Right-clicking with a mouse opens
keyboard shortcuts for various context menus, providing quick access
functions, making them efficient to various options and actions related to
for tasks like copying, pasting, the selected item.
saving, and undoing actions.
.
Q6. Suman has discarded old, broken and malfunctioning Hard Disk without taking care
to delete data. Is it harmful in respect of security concern? Justify your answer.
Ans Yes, as it invites hackers/malware to see through your data. (Knowledge)
(1 mark to be awarded for yes/no and 2 mark for the correct justifications).

Q7. What is a data backup software? How can it help in data recovery?
Ans Data backup software is a software whose primary function is to copy and save the
data to an external source. This could be either a drive, server, data centre, or the
cloud.
The main role of backup and recovery is to preserve critical data in case of loss or
damage. In case of a disaster — natural or manmade including a ransomware attack
the backed up data can be retrieved and restored.

PAGE:19
Q8. Give three techniques to prevent accidental file deletion.
Ans Three popular techniques to prevent accidental file deletion are as follows:
a) We can configure the Permissions Settings to allow us to grant or deny file
access to other users.
b) we can simply hide the files from the file properties option.
c) We can password protect the file using third party software.
Q9. Why is operating system also called a resource manager?
Ans a) The OS manages these resources and allocates them to particular programs.
b) The CPU is one kind of resource and the OS decides how much processor
time should be given for the execution of a particular program.
c) OS also manages memory and I/O devices when multiple users are working
simultaneously.
Q10. What is an OSS? How is OSS different from FOSS.
Ans Open source software is software developed and maintained by open collaboration,
and made available, typically at no cost, for anyone to use, examine, alter and
redistribute however they like.
Open Source Software refers to software whose source code is available to customers
while FOSS is a software that is both free software as well as open-source software.
(2 marks for correct definition and 1 mark for difference)
10 Short Knowledge/Understanding/Application Based Questions (4 Marks)
Q1. Modern computers are based on Von Neumann Architecture. What does Von
Neumann Architecture comprise of?
Ans Von Neumann architecture comprises of:
i) Central Processing Unit
ii) Memory to store data and programs
iii) Input and output devices
iv) Communication channels to send/receive the output data
Q2. Draw the block diagram of a computer system. Briefly write about the functionality
of each component.
Ans

Block diagram of a computer system.

PAGE:20
Three components of computer are:
• Central Processing Unit (CPU),
• Input Devices,
• Output Devices
Central Processing Unit: It is the brain of the computer system. It broadly comprises
of Arithmetic Logic Unit(ALU) and Control Unit(CU). ALU is responsible for
performing the various Arithmetic operations and Logical operations on integers. CU
is responsible for controlling all the activities which are performed inside the
computer system.
Input Devices: They accept data from the user or outside the environment. It sends
data & instructions in binary form to the computer for further processing. Example:
keyboards, mouse, scanners etc.
Output Devices: They receive data or information from memory. This data is
converted into human readable format and shown to the user.Example: Monitor,
Printer etc.

Q3. List out four differences between RAM and Hard Disk.
Ans .
RAM Hard Disk
i) It is a type of Primary Memory It is a type of Secondary Memory
ii) RAM is volatile memory that Hard Disk is non-volatile memory that
temporarily stores the files you are permanently stores data or instructions
working on. for your computer.
iii) RAM has higher speed than Hard Hard Disk has lower speed than RAM
Disk
iv) Cost of per unit memory is more in Cost of per unit memory is less in
RAM Hard Disk
.
Q4. What was the basic electronic component of:
1st Generation of Computers
2nd Generation of Computers
3rd Generation of Computers
4th Generation of Computers

PAGE:21
Ans 1st Generation of Computers mostly comprised of vacuum tubes
2nd Generation of Computers mostly comprised of transistors
3rd Generation of Computers mostly comprised of integrated circuits
4th Generation of Computers mostly comprised of VLSI circuits
Q5. Define the following terms in relation to computers:
a) Booting b) BIOS c)POST d) CMOS
Ans a) Booting
The booting process in a PC (Personal Computer) is the sequence of events that
occurs when you turn on the computer to start the operating system (OS). It involves
the computer's hardware and firmware working together to load the OS into memory,
allowing the computer to become functional.
b) BIOS
BIOS (Basic Input/Output System) is firmware that serves as the computer's system
software. Its primary role is to initialize the hardware and provide the initial software
environment for the boot process. BIOS configures critical hardware settings, such as
the system clock, CPU parameters, and boot device order.
It locates the bootable device (e.g., a hard drive or SSD) based on the boot order
specified in BIOS settings.
c)POST
The BIOS built into the motherboard's ROM (Read-Only Memory) chip initiates a
Power-On Self-Test (POST). During POST, the BIOS checks the hardware
components (CPU, RAM, storage devices, graphics card, etc.) to ensure they are
functioning correctly. Any detected issues are reported via beep codes or error
messages.
d) CMOS
CMOS stands for Complementary Metal-Oxide-Semiconductor. CMOS technology
is a semiconductor technology used to manufacture integrated circuits, and it is
particularly known for its low power consumption. In the context of personal
computers, the term "CMOS" is commonly associated with the CMOS battery, which
powers the CMOS chip on the motherboard and maintains vital system settings and
the system's real-time clock when the computer is turned off.
Q6. Give two reasons for data deletion. How can data deletion from unauthorized persons
be prevented?

PAGE:22
Ans The reasons for data deletion are as follows:
a) The storage device can malfunction or crash down leading to data loss.
b) Users can accidentally erase data from storage devices.
(1 mark each for any other reason of deletion)
Data deletion from unauthorized persons can be prevented by:
a) Limiting access to the computer system by using passwords.
b) Keep files encrypted to prevent it from unwanted modification.
(1 mark each for any other correct answer)
Q7. Give two similarities and two differences between a compiler and interpreter.
Ans Two similarities between compiler and interpreter are:
a) Both compiler and Interpreter are language translators.
b) Both compiler and interpreter are used to find errors in the source code and
debug them.
Differences are as follows:
Compiler Interpreter
It takes the entire program in one go. An interpreter takes a single line of
code at a time.
The compiler generates an intermediate The interpreter does not produce an
machine code. intermediate machine code.
The compiler is used by programming The interpreter is used by programming
languages such as C,C++,Java etc. languages such as Python, Ruby etc.
Q8. Give four major functions of an operating system.
Ans a) Allocates and deallocates the memory and it keeps a record of which part of
primary memory is being used by which process.
b) When more than one process runs on the system the OS decides how and
when a process will use the CPU.
c) It keeps records of the status and locations of files and allocates and
deallocates resources.
d) An operating system regulates device connection using drivers. The processes
may require devices for their use.
Q9. Give four techniques to prevent loss of data due to security reasons.
Ans a) Backing up the Data-It is always good to have a backup strategy or several
backups of the company’s data.
b) Encrypt Sensitive Data-Encryption makes it exceedingly difficult for an
unauthorized individual to comprehend or use stolen data.
c) Use SoftwareAnti-virus and anti-malware software protects our system from
programs that can wipe out data or from threats that can block access to our
critical files.
d) Having a Password Policy: Creating and enforcing a password policy makes
it more challenging for a bad actor to crack employees’ passwords and get
into your system.
Q10. What is language translator? Mention the three main types of language translators.
Ans A language translator is a program that converts source code into object code.
Generally, there are three types of translator:
Compiler: A compiler takes the source code as a whole and translates it into object
code all in one go.
Interpretor: An interpreter translates source code into object code one instruction at a
time.
Assembler: an assembler converts assembly level language code into machine
language code.
PAGE:23
07 Case Based Questions (5 Marks)
Q1. Ramesh wants to purchase a new PC. He is trying to choose a PC within his budget
which will work fast. Which of the following components are compulsory and which
are optional and explain why?
a) Scanner
b) Keyboard
c) Printer
d) Monitor
e) Mouse
Ans a) A scanner is not essential for the working of a PC. In future if Ramesh has to scan
documents or pictures regularly, he may buy it.
b) A computer keyboard is an essential input device used to enter characters and
functions into the computer system by pressing buttons, or keys. It is the primary
device used to enter text. A keyboard typically contains keys for individual letters,
numbers and special characters, as well as keys for specific functions.
c) A printer is not essential for the working of a PC. However if Ramesh frequently
needs hard copies of various documents from PC, he may buy it in future.
d) A computer monitor is an essential and mainoutput device for a PC. The primary
use of a monitor is to display images, text, video, and graphics information
generated by the computer via a computer's video card.
e) A mouse is an essential input device used to point at objects you see on the screen.
By pointing at an object, you tell the computer that you want to do something with
that object. For example, say you wanted to start a program. There's a small
picture, called an icon, on the computer screen that represents that program.
Q2. Sweta has recently installed new software on her 1 year old laptop after which the
speed of the laptop has become quite slow. She is confused regarding which of the
following must be upgraded for better speed. Help her to understand the role of each
of the following components and which of them will ultimately improve the speed of
the laptop.
a) Hard Disk
b) ROM
c) RAM
d) Processor
e) Network

PAGE:24
Ans a) Since laptop was working properly and the hard disk is relatively new, there is no
need to upgrade the hard disk.
b) ROM contains the programming that allows a computer to start up or regenerate
each time it is turned on. So the ROM is also not the cause of the problem.
c) Generally, the faster the RAM, the faster the processing speed. Since the laptop
has become slow after installation of a new software, there is a possibility that the
new software needs more RAM for smooth working of the laptop. Hece RAM
must be upgraded.
d) A processor also affects the speed of a laptop. But since the laptop was functioning
properly till recently and the laptop and itsprocessor being new, there is no need to
upgrade the processor.
e) A network has nothing to do with the speed of the laptop. Its role is only to transfer
files from one laptop to other.
Q3. Classify on which the following areas computers have a positive or negative impact.
Justify your answer with suitable reason.
a) Accuracy
b) Speed
c) Health
d) Employment
e) Social Relations
Ans a) Accuracy of calculations have been greatly enhanced by computers. Computers are
machines which can repeatedly do calculations with consistent accuracy.
b) Speed of doing various tasks have improved due to high processor speeds of a
computer.
c) Health of human beings often adversely affected due to working for long hours on
a computer. Improper postures can cause back, neck and shoulder pains, headache,
eye strain and overuse injuries of the arms and hands.You can help avoid
computer-related injuries with proper furniture, better posture and good working
habits.
d) Computer has led to reduction of employment opportunities for unskilled workers
whereas it had given rise to ample opportunities for skilled manpower.
e) On one hand people are becoming lonelier due to less time for interpersonal
relationships. On the other hand people areSocializing more using social platforms.
Hence to an extent computers are helping people to socialize more.

PAGE:25
Q4. Anisha was in the middle of a typing a letter in Microsoft Word when suddenly
power went off.
a) Do you think she will get back the entire text she had typed in the letter.
b) If not what is the reason?
c) What would you suggest her to not face the problem again?
d) Can you suggest any device to prevent the above problem?
e) Which is better a writeable DVD or an external hard disk for long term storage?
Ans a) I don’t think she will be able get back the entire letter.
b) Because the latest portions of the letter which was being typed was on the RAM
which being volatile loses its data as soon as power is switched off.
c) She should continuously save the work after every few moments.
d) She must use a UPS to avoid this type of data loss.
e) An external HDD will last longer than a writable DVD.
Q5. Sunil is a student of fine arts and wants to draw a potrait which he has to send
someone by email.
a) Do you think he should draw it on canvas and scan the image or can he draw it on
a PC? Which one is better if he knows how to draw on a PC?
b) Can a touchscreen make his work easier?
c) If he cannot afford a touchscreen, suggest him a suitable input device for drawing
theportrait.
d) He manages to draw a portrait but is unable to determine what type of printer
should be used. Suggest him a suitable printer along with the reason.
e) Do you think a separate graphics card is essential for drawing in a PC.
Ans a) Considering above scenario it will be better to draw on a PC because we can
repeatedly modify the portrait in the PC until he is satisfied. On the other hand the
same will not be possible on the canvas.

b) Yes a touchscreen can serve as a digital tablet and make work easier for an artist.

c) He will need compatible a digital pen and stylus if he doesn’t have a touchscreen.

d) He should use a plotter as it gives him the flexibility to print in various sizes on
various media.

e) No graphics card is not essential for drawing. However a graphics card can offload
work and reduce memory-bus-contention from the CPU and system RAM, therefore
the overall performance for a computer could improve in addition to increased
performance in graphics processing.

PAGE:26
Q6. Mr Samrat is a data recovery expert at ABC Computer Pvt limited company. He has
been assigned the task to keep the data in every system safe and protected from
unauthorized personnel.
i) Which among the following methods should he use to keep the company’s
data safe from outsiders
a) Install a disk backup software
b) Set password to authenticate users at the time of login
c) Perform boot time scan of the system
d) All the above.

ii) Which of the following is a sign that the data in removable disk is
corrupted?
a) Files in removable disk are opening slowly.
b) System is taking more time to open.
c) Files in removable disk could not be read.
d) None of the above

iii) A user in his company has mistakenly deleted a file. How can he get back
the file?
a) By creating the file once again.
b) By restoring it from the recycle bin.
c) By searching for the file in drives of the system
d) None of the above.

iv) Mr Samrat notices that whenever a pen drive is connected in his system
all files and folders in it become hidden. What could be the possible
reason for it?
a) Operating system has become corrupted.
b) File explorer is not working properly.
c) Pen drive has become faulty.
d) There may be a malware in the pen drive or system.

v) Which software would you suggest to increase the performance of the


hard disk.
a) Disk Cleaner
b) Anti Virus
c) Disk Boost
d) Disk Defragmenter
Ans i) b) Set password to authenticate users at the time of login
ii) c) Files in removable disk could not be read.
iii) b) By restoring it from the recycle bin.
iv) d) There may be a malware in the pen drive or system.
v) d) Disk Defragmenter
Q7. Mrs Sunita wants to buy a laptop for her personal work. She is a teacher in Indira Public
School. She has searched in the internet and she found two laptops with the same
configuration. One with DOS version and another with pre loaded Windows.
1.Why is the price of the pre loaded Windows system more than the DOS version?
a) DOS version is not user friendly.
b) DOS version does not support installing other software.
c) In pre-loaded Windows system an OS is already installed and it’s cost is included.
d) None of the above.

PAGE:27
2. Which software she needs to install in the DOS version?
a) Utility software
b) Application software
c) Operating system
d) None of the above.

3. She wants to install software for spread sheet work. Suggest a suitable software for
her.
a) MS Excel
b) MS Word
c) MS Power Point
d) All the above

4. Which software among the following should she update to protect her system from
virus?
a) Windows Media Player
b) Windows Defender
c) MS Office
d) None of the above

5. She wants to use the internet for surfing content. Which among the following
would be the most suitable software for it.
a) Internet Explorer
b) Mozilla Firefox
c) Google Chrome
d) All the above

Ans 1. c) In pre-loaded Windows system an OS is already installed and it’s cost is


included.
2. c) Operating system
3. a) MS Excel
4. b) Windows Defender
5. d) All the above

PAGE:28
Name of the chapter : Introduction to Python
Topic Covered
• Basics of Python programming,Python interpreter-interactive and script mode, the
structure of a program,
• Indentation,identifiers,keywords,constants,variables,types of operators,precedence
of operators,data
• Types,mutable and immutable data types,statements,expressions,evaluation and
comments, input and output statements
• Data type conversion,debugging.
• Control Statements:if-else,if-elif-else, while loop,forloop
• Lists: list operations-creating,initializing,traversing and manipulating lists,list
methods and built-infunctions.– len(),list(),append(),insert(),
count(),index(),remove(), pop(), reverse(), sort(), min(),max(),sum()
• Dictionary: concept to fkey-value pair, creating,initializing,traversing, updating and
deleting elements,dictionary methods and built-infunctions.– dict(), len(), keys(),
values(), items(), update(), del(), clear()

Key Points

Python interpreter To execute a program in a high-level language by translating it one line at


a time interactive mode, A way of using the Python interpreter by typing commands and
expressions at the prompt.
script mode, A way of using the Python interpreter to read and execute statements in a script.
In Python, everything is an object. For example, numbers, strings, functions, classes,
and modules are all objects. Every Python object has three core characteristics that define it
at a foundational level. These characteristics are: Value ,identity

In Python, variables don’t have an associated type or size, as they’re labels attached to
objects in memory

Python objects are concrete pieces of information that live in specific memory positions on
your computer.

An object’s value is probably the only characteristic that you’d want to change in your code.
An object that allows you to change its values without changing its identity is a mutable

In contrast, an object that doesn’t allow changes in its value is an immutable object.

Control Statements- It allows programmers to control the execution flow of a program or


one of its sections.
if statement- if statement consists of a Boolean expression followed by one or more
statements. If the condition is True, the statements under if statements are executed.
if else-An if else statement consists of a Boolean expression followed by one or more
statements. If the condition is True, the statements under if statements are executed. If the
condition is false, statements under else part is executed
if elif- An if statement followed by one or more elif Statements, that consists of Boolean
expressions and then followed by an optional else statement, which executes when all the
condition becomes false.

PAGE:29
Nested if - An if statement inside another if or elif statement(s).
Loop- executes a statement or group of statements multiple times
while loop- It consists of a Boolean expression written along with while keyword followed
by one or more statements which will be executed as long as condition is True
for loop- Executes a sequence of statements multiple times and abbreviates the code that
manages the loop variable
break - It is used to terminate the loop.
continue -It is used to skip all the remaining statements in the loop and move controls back
to the top of the loop.
pass-This statement does nothing. It can be used when a statement is required syntactically
but the program requires no action.
Definition :
A list is a data structure in Python that is a mutable, or changeable, ordered sequence of
elements.
Example:- L1=[10,25,100,500], L2=[1, 2, 2.5, 10.0, 'a', 'b'], L3=[1,[2,3],4]
List Creation:
L1=[] or L2=list( ) # To create empty list
L3=[10,25,100,500] # To create and initialize list
L4=eval(input("Enter elements of the list")) #to create and initialize by user input
List Traversing and Manipulation:
Every element of the list has an unique sequential index(position) starting from 0
List elements can be accessed and manipulated by index.
if LST=[3,6,9,12,15] then
LST[1] ---->refers second element, i.e 6
LST[3]=20 ----> modifies the 4th element as 20.
To traverse and display all elements of the list:-
for item in LST:
print (item)
List Operators:
Concatenation (+)
Joins two lists. For example if L1=[1,2,3], L2=[4,5] then L1+L2 ---> [1,2,3,4,5]
Replication ( * )
Replicates the list given number of time.
For example , L1*3 ----->[1,2,3,1,2,3,1,2,3]
Membership ( IN / NOT IN)
Checks if an element is present or not.
For example : 2 in L1---> True 2 in L2--->False
Comparison ( ==, !=, >, <, >=, <= )
Compares two lists element by element
For example:
L1==L2---->False L1!=L2= True L1>L2-----> False
Slice ( : )
To access a range of items in a list, you need to slice a list. One way to do this is to use the
simple slicing operator ":".
Syntax:

PAGE:30
Note: If step is omitted, default step in 1.
Example:
L = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
print(L[2:7])
# Prints ['c', 'd', 'e', 'f', 'g']

Note: Last index is always excluded.

Negative Index:
L = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
print(L[-7:-2])
# Prints ['c', 'd', 'e', 'f', 'g']

Built in Functions
len()
returns the no of size/no of elements. len(L1)---->3 , len(L2)----->2
min()
returns minimum element min(L1) ----->1
max()
returns maximum element max(L2) ----->5
sum()
returns sum of elements sum(L2) ----->9 sum(L1)----->6
List Functions
append()
adds an element at the end of the list
L1.append(10) ------> [1,2,3,10]
insert()
insert an element at a given index
L2.insert(1,2.5) ------->[4,2.5,5]

PAGE:31
count()
returns the frequency of an element
Val=[2,4,6,4,7,3,4]
Val.count(4)------>3
index()
returns the index of an element
Val.index(6)------>2
remove()
delete the element with a given value
Val.remove(7) -----> [2,4,6,4,3,4]
pop()
delete the element with a given index . If no index is given, last element is deleted
Val.pop(2) -----> Val=[2,4,4,7,3,4]
reverse()
Val.reverse( )----->[4,3,7,4,4,2]
arranges the elements of the list in a reverse order
sort()
arranges the elements of a list in ascending order.
cars = ['Ford', 'BMW', 'Volvo']
cars.sort() ----> ['BMW', 'Ford', 'Volvo']
clear( )
deletes all elements of the list
Num=[1,4,7,9]
Num.clear() -----> Will give empty list
extend()
Merge the elements of a list in the current list
L1.extend(L2) ----->[1,2,3,4,5]
L2.extend(L1) ------>[4,5,1,2,3]
Dictionary
• Dictionary has some similarities with string, list and tuple but it is different in terms
of storing and accessing an element. String, list and tuple are sequences whereas a
dictionary is a mapping. Rather than having an index associated with each element,
Dictionaries in Python have a key associated with each element. Python Dictionaries
are a collection of key value pairs.
• In other ways, you can think keys as user defined indices.
• In English Dictionary, we search any word for meaning associated with the word.
Here Word is the Key and meaning is the value.

Dictionary Creation:
• Syntax:
<dictionay_name>={<key1>:<value1>, <key2>:<value2>, ……..
<keyn>:<value n>}
• Example:
Price={ ‘Redmi Note8’: 10500, ‘Galaxy A70s’: 25900,
‘OppoA31’:12490}
Here ‘Redmi Note8’, ‘Galaxy A70s’ and ‘Oppo A31’ are Keys and 10500, 25900,
12490 are values.

• Dict1={} #Empty Dictionary


• TeacherCount={‘PGT’:10, ‘TGT’:7, ‘PRT’:5}

PAGE:32
• Note: Keys of a Dictionary must be of immutable types, such as:
* A Python string
* A number.
* A tuple (containing only immutable types)
If we try to give a mutable type as key, Python will give an error.

Accessing elements of a Dictionary:


• We need a key to access any element of a Dictionary likewise in lists, strings and
tuples we used index to access any element.
• Example:
>>> TeacherCount={'PGT':10, 'TGT':7, 'PRT':5}
>>> TeacherCount{'PGT': 10, 'TGT': 7, 'PRT': 5}
>>> TeacherCount['PGT']
10
• Note: Attempting to access a key that doesn’t exist causes an error

Traversing a Dictionary:
• Traversal of a collection means accessing and processing each element of it.
• for loop is efficient to traverse any collection and sequence. for loop will get every
key of Dictionary and we can access every element of the Dictionary based on the
keys.
• Example:
>>> TeacherCount={'PGT':10, 'TGT':7, 'PRT':5}
>>> TeacherCount
{'PGT': 10, 'TGT': 7, 'PRT': 5}
>>> for i in TeacherCount:
print('Key is ',i, 'Value is ',TeacherCount[i])
Key is PGT Value is 10
Key is TGT Value is 7
Key is PRT Value is 5

Accessing Key and Values Simultaneously:


• Accessing all keys in a Dictionary in one go:
<dictionary>.keys()
Example:
>>> TeacherCount={'PGT':10, 'TGT':7, 'PRT':5}
>>> TeacherCount
{'PGT': 10, 'TGT': 7, 'PRT': 5}
>>> TeacherCount.keys()
dict_keys(['PGT', 'TGT', 'PRT'])
• Accessing all values in a Dictionary in one go:
<dictionary>.values()
Example:
>>> TeacherCount.values()
dict_values([10, 7, 5])

Characteristics of a Dictionary:
• Unordered Set:
A dictionary is a unordered set of key:value pair.

PAGE:33
• Not a Sequence:
Unlike a string, list and tuple, a dictionary is not a sequence because it is unordered
set of elements. The sequences are indexed by a range of ordinal numbers. Hence,
they are ordered, but a dictionary is an unordered collection.
• Indexed by keys, Not numbers:
Dictionaries are indexed by keys. Keys are immutable type. But the values of a
dictionary can be of any type.
• Keys must be unique:
Each keys of a Dictionary must be unique. However two unique keys can have same
values.
• Mutable:
Like lists, dictionaries are mutable. We can change the value of a key in place.
• Internally stored as Mappings:
Internally, the key:value pairs of a dictionary are associated with one another with
some internal function (called hash-function). This way of linking is called mapping.

Multiple ways of Creating Dictionaries:


1. Initializing a Dictionary:
In this method all the key:value pairs of a dictionary are written collectively,
separated by commas and enclosed in curly braces.
Example:
T20Cricketer={'Name':'Virat', 'Runs':2794, 'Age':31}
2. Adding key:value pairs to an empty Dictionary:
In this method, first we need to create an empty dictionary and then keys and values
are added to it one pair at a time.
Two ways of creating empty dictionary:
■ T20Cricketer={}
and
■ T20Cricketer=dict()
Next step is to add key:value pairs, one at a time as per syntax given below:
<dictionary>[<key>]=<value>
Example:
>>> T20Cricketer['Name']='Virat'
>>> T20Cricketer['Runs']=2794
>>> T20Cricketer['Age']=31
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
3. Creating a Dictionary using dict():
(i) Specify Key:Value pairs as keyword arguments to dict() function:
Example:
>>> T20Cricketer=dict(Name='Virat', Runs=2794, Age=31)
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
PAGE:34
(ii) Specify comma-separated Key:Value pairs:
Example:
>>> T20Cricketer=dict({'Name':'Virat', 'Runs':2794, 'Age':31})
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
(iii) Specify Key:Value pairs separately in form of sequences:
In this method, one list or tuple of individual key value pair is passed
as argument to dict().
Example1:
>>>T20Cricketer=dict([['Name','Virat'],['Runs',2794],
['Age',31]])
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
Example 2:
>>>T20Cricketer=dict((('Name','Virat'),('Runs',2794),
('Age',31)))
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
Example3:
>>>T20Cricketer=dict((['Name','Virat'],['Runs',2794],
['Age',31]))
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
Example 4:
>>>T20Cricketer=dict([('Name','Virat'),('Runs',2794),
('Age',31)])
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
• Adding Elements to Dictionary:
<dictionary>[<key>]=<value>
Example:
>>> T20Cricketer={'Name':'Virat','Runs':2794,
'Age':31}
>>> T20Cricketer['Country']='India'
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31, 'Country':'India'}
N.B: Key to be added must not exist in dictionary and must be unique. If the Key
already exists, then it will change the value of existing key and no new entry will
be added to dictionary.

• Updating Existing Elements in a Dictionary:


<dictionary>[<key>]=<value>
Example:
>>> T20Cricketer={'Name':'Virat','Runs':2794,
‘Age':31}
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
>>> T20Cricketer['Name']='Rohit'
>>> T20Cricketer
{'Name': 'Rohit', 'Runs': 2794, 'Age': 31}

PAGE:35
N.B: Key must exist in the dictionary otherwise new entry will be added to
dictionary.

• Deleting Elements from a Dictionary using del:


del <dictionary>[<key>]
Example:
>>> T20Cricketer={'Name':'Virat','Runs':2794,
‘Age':31}
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
>>> del T20Cricketer['Age']
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794}
N.B: Key must exist in the dictionary otherwise Python gives KeyError.

• Checking for Existence of a Key:


Membership operators in and not in are used to check for the existence of Keys only.
<key> in <dictionary>
<key> not in <dictionary>
Example:
>>> T20Cricketer={'Name':'Virat','Runs':2794,
'Age':31}
>>> 'Runs' in T20Cricketer
True
>>> 'Age' not in T20Cricketer
False
>>> 'Virat' in T20Cricketer
False
# Here ‘Virat’ is not a key

• Checking for Existence of a Value:


<value> in <dictionary>.values()
<value> not in <dictionary>.values()
Example:
>>> T20Cricketer={'Name':'Virat','Runs':2794,
'Age':31}
>>> 'Virat' in T20Cricketer.values()
True
• Functions and Dictionary Methods:
1. len(Dictionary):
Returns total number of elements present in the dictionary.
Example:
T20Cricketer={'Name':'Virat','Runs':2794,'Age':31}
>>> len(T20Cricketer)
3
2. Dictionary.keys():
Returns a list of keys of the dictionary.
Example:
>>> T20Cricketer.keys()
dict_keys(['Name', 'Runs', 'Age'])

PAGE:36
3. Dictionary.values():
Returns a list of values of the dictionary.
Example:
>>> T20Cricketer.values()
dict_values(['Virat', 2794, 31])

4. Dictionary.items() :
Returns all of the items of the dictionary as a sequence of (key,value) tuples
Example:
>>> T20Cricketer.items()
dict_items([('Name', 'Virat'), ('Runs', 2794), ('Age', 31)])

5. Dictionary.update(other dictionary) :
Merges key:value pairs from the other dictionary to the original Dictionary. It updates
the value of the keys if the keys exist in the original dictionary otherwise adds the
key:value pair to the original Dictionary.
Example:
>>> T20Cricketer
{'Name': 'Virat', 'Runs': 2794, 'Age': 31}
>>> T20Cricketer2
{'Name': 'Rohit', 'Age': 33, 'Country': 'India'}
>>> T20Cricketer.update(T20Cricketer2)
>>> T20Cricketer
{'Name': 'Rohit', 'Runs': 2794, 'Age': 33, 'Country': 'India'}
>>> T20Cricketer2
{'Name': 'Rohit', 'Age': 33, 'Country': 'India'}

6. del <Dictionary>[<key>]
Deletes key:value pair or element of the Dictionary.
Example:
>>> T20Cricketer
{'Name': 'Rohit', 'Runs': 2794, 'Age': 33, 'Country': 'India'}
>>> del T20Cricketer['Country']
>>> T20Cricketer
{'Name': 'Rohit', 'Runs': 2794, 'Age': 33}
7. del Dictionary
Deletes entire Dictionary
Example:
>>> del T20Cricketer2
>>> T20Cricketer2
NameError: name 'T20Cricketer2' is not defined
8. Dictionary.clear()
Removes all items of the Dictionary leaving the Dictionary empty.
Example:
>>> T20Cricketer2
{'Name': 'Rohit', 'Runs': 2773, 'Age': 33}
>>> T20Cricketer2.clear()
>>> T20Cricketer2
{}

PAGE:37
Nested Dictionary:
A Dictionary is called nested if there is at least one Dictionary as a value of key.
Example
>>> CSTeacher={'Name':{'Fname':'Rajat','Lname':'Bhatia'},'Desig':'PGT'}
>>> CSTeacher
{'Name': {'Fname': 'Rajat', 'Lname': 'Bhatia'}, 'Desig': 'PGT'}
>>> CSTeacher['Name']
{'Fname': 'Rajat', 'Lname': 'Bhatia'}
>>> CSTeacher['Name']['Fname']
'Rajat'

55 Objective Question (1 Mark )


Q1. What are the two modes of Python interpreter?
Ans Interactive mode and script mode
Q2. Identify the invalid identifier:
(a) sum1 (b) _sum (c) sum@ (d) SUM
Ans (c)
Q3. In ________ mode of Python, we can save the program.
Ans Script
Q4. Which is of the following is not a constant?
(a) True (b) “Hello” (c) 3.14 (d) sum
Ans (d)
Q5. Identify the immutable data type:
(a) dictionary (b) int (c) list (d) set
Ans (b)
Q6. Which one of the following is the correct extension of the Python file?
a) .py b) .python c) .p d) None of these
Ans (a)
Q7. Which is the correct operator for power(xy)?
a) X^y b) X**y c) X^^y d) None of the mentioned
Ans (b)
Q8. Python supports dynamic typing. – True / False
Ans True
Q9. a=5>2
What will be the data type of the variable a?
(a) True (b) int (c) bool (d) None of these
Ans (c) bool

PAGE:38
Q10. Which of the following is not a token :
(a) // (b) “a” (c) 3.14 (d) ##
Ans (d)
Q11 What will be the output of the following code snippet:
n=3
n=4
n=n+n
print(n)
(a) 7 (b) 6 (c) 1 (d) 8
Ans (d)
Q12 What will be the value of the following Python expression : 4 + 3 % 5
(a) 2 (b) 4 (c) 7 (d) Error
Ans (c)
Q13 Which function displays the memory location of an object/variable ?
Ans id( )
Q14 _____ spaces should be left for indentation.
(a) 2 (b) 3 (c) 4 (d) 1
Ans (c) 4
Q15 Python is case-sensitive – True / False.
Ans True
Q16. What keyword would you use to add an alternative condition to an if statement?
a) else if
b) elseif
c) elif
d) None of the above
Ans c) elif
Q17. How is a code block indicated in Python?
a) Brackets
b) Indentation
c) Key
d) None of the above
Ans b) Indentation
Q18. The order of execution of the statements in a program is known as:
a) flow of control
b) central flow
c)selection
d) iteration
Ans a) flow of control

PAGE:39
Q19. Number of elif in a program is dependent on the ___________
a) number of conditions to be checked
b) number of variables in a program
c) number of loops in a program
d) None of the above
Ans a) number of conditions to be checked
Q20. An ‘if’ condition inside another ‘if’ is called ___
a) Second if
b) nested if
c) another if
d) None of the above
Ans b) nested if
Q21. ____ is an empty statement in Python.
a) Jump
b) Fail
c) Empty
d) Pass
Ans d) Pass
Q22. Which of the following symbol is used to end an ‘if’ statement in Python?
a) Comma( , )
b) Colon( : )
c) Semi Colon( ; )
d) None of the above
Ans b) Colon( : )
Q23. Repetition of a set of statements in a program is made possible using _____________
a) Selection Constructs
b) Sequential Constructs
c) Looping Constructs
d) None of the above
Ans c) Looping Constructs
Q24. The statements in a loop are executed repeatedly as long as particular
condition _____________.
a) remains False
b) remains True
c) gives error
d) None of the above
Ans b) remains True
Q25. When the condition in loops becomes false, the loop _________
a) terminates
b) begin
c) restart
d) none of the above
Ans a) terminates
Q26 Consider the loop given below:
for i in range(7,4,-2) :
break
What will be the final value of i after this loop?
a) 4
b) 5
c) 7
d) -2
Ans b) 7

PAGE:40
Q27 Consider the loop given below:
for i in range(10,5,-3) :
print(i)
How many times will this loop run?
a) 3
b) 2
c) 1
d) Infinite
Ans b) 2
Q28 Consider the loop given below:
for i in range(3) :
pass
What will be the final value of i after this loop?
a) 0
b) 1
c) 2
d) 3
Ans c) 2
Q29 Consider the loop given below:
for i in range(2,4) :
print(i)
What value(s) are printed when it executes?
a) 3
b) 3 and 4
c) 2 and 3
d) 2,3 and 4
Ans c) 2 and 3
Q30 Function range(3) is equivalent to:
a) range(1,3)
b) range(0,3)
c) range(3,0,-1)
d) range(1,3,0)
Ans b) range(0,3)
Q31. Suppose L=[10,20,30,40,50,60] , then what is the value of L[::2]?
Ans [10, 30, 50]
Q32. If L1=[‘a’,’b’,’c’] then find 2*L1
Ans ['a', 'b', 'c', 'a', 'b', 'c']
Q33. Consider a list LST=[2,3,[1,5]] . Find the output of the statement: 1 in LST
Ans False.
Q34. If L=list(‘123’) then find the output of the statement : print(L)
Ans [‘1’,’2’,’3’]
Q35. If List1=[[‘a’,’b’,’c’],[10,20,30]] then find the value of len(List1)
Ans 2
Q36. Consider a list LST=[10,20,30,40]. Write a statement to insert element 50 at the last
position.
Ans LST.append(50)
Q37. Consider a list LST123=[1,2,3,4]. Write a statement to insert element 2.5 at index no
3.
Ans LST123.insert(3, 2.5)

PAGE:41
Q38. If LST = 'SUMMER' then find LST[::-1]
Ans REMMUS
Q39. Write a ststement to create an empty list.
Ans L=[] or L=list( )
Q40. Which of the following function is a standard library function and not a list function?
a. pop( ) b. max( ) c. extend( ) d. sort( )
Ans b. max( )
Q41 Which function is used to merge two lists into a single list?
Ans extend( )
Q42 Which operator will be used to make a copy of a list to another list?
a. = b. == c.+ d.*
Ans a.=
Q43 Write the result of the statement : print(list(range(5))
Ans [0,1,2,3,4]
Q44 Suppose a list L=[1,2,3,4,5]. Write a statement to remove all the elements a make an
empty list, i.e, L=[]
Ans L.clear()
Q45 Find the output: -
L=[0,[9,’a’],77.9,’KVS’,[‘Rahul’,’Viki’,’Vijay]]
print(L[:3]+L[1::-1])

Ans [0, [9, 'a'], 77.9, [9, 'a'], 0]


Q46. Which of the following is correct way of creating a dictionary?
a) Medals={‘Gold’=12,’Silver’=21,’Bronze’=32}
b) Medals={‘Gold’:12,’Silver’:21,’Bronze’:32}
c) Medals=[‘Gold’:12,’Silver’:21,’Bronze’:32]
d) Medals=(‘Gold’:12,’Silver’:21,’Bronze’:32)

Ans b) Medals={‘Gold’:12,’Silver’:21,’Bronze’:32}
Q47. Dictionary is a _______________
a) Set b) Sequence c) Mapping d) None of the options
Ans c) Mapping
Q48. Which one of the following statement is not True?
a) Dictionary is value mutable.
b) Dictionary is key immutable.
c) Dictionary is a mapping.
d) Dictionary is an ordered set of items.
Ans d) Dictionary is an ordered set of items.
Q49. Find out the odd one from the following:
a) Integer b) String c) Float d) Dictionary
Ans d) Dictionary
Q50. Which of the following statement is wrong?
a) D={1:2,3:4,4:5}
b) D={[1,2]:’Tarun’,[3,5]:’Komal’,[4,6,7]:’Sampreet’}
c) D=dict({1:’Madhu’,2:’Karan’,3:’Mohan’})
d) D={’Tarun’: [1,2],’Komal’: [3,5],’Sampreet’: [4,6,7]:}

Ans D={[1,2]:’Tarun’,[3,5]:’Komal’,[4,6,7]:’Sampreet’}

PAGE:42
Q51. T20Cricketer={'Name':'Virat', 'Runs':2794, 'Age':31}
Barun is trying to delete all the key value pairs of the dictionary using various
methods. Which of the following statement will not full fill his wish?
a) T20Cricketer.clear()
b) del T20Cricketer[‘Name’], T20Cricketer[‘Runs’], T20Cricketer[‘Age’]
c) T20Cricketer=dict()
d) del T20Cricketer
Ans del T20Cricketer
Q52. Predict the output of the following code:
T20Cricketer={'Name':'Virat', 'Runs':2794, 'Age':31}
print('Virat' in T20Cricketer)
a) False b) True c) Error d) ‘Virat’
Ans a) False
Q53. Predict the output of the following code:
Marks={‘Amar’:87,’Neel’:45,’Rupsa’:92}
print(len(Marks))
a) 6 b) 3 c) 5 d) Error
Ans b) 3
Q54. Predict the output of the following code:
Marks={‘Amar’:87,’Neel’:45,’Rupsa’:92}
for i in Marks:
print(i, end=’ ‘)
a) ‘Amar’ ‘Neel’ ‘Rupsa’
b) 87 45 92
c) 87
45
92
d) ‘Amar’
‘Neel’
‘Rupsa’
Ans a) ‘Amar’ ‘Neel’ ‘Rupsa’
Q55. Predict the output of the following code:
T20Cricketer={'Name':'Virat', 'Runs':2794, 'Age':31}
T20Cricketer2={'Name': 'Rohit', 'Age': 33, 'Country': 'India'}
T20Cricketer.update(T20Cricketer2)
print(T20Cricketer)
print(T20Cricketer2)
a) {'Name': 'Rohit', 'Runs': 2794, 'Age': 33}
{'Name': 'Rohit', 'Age': 33, 'Country': 'India'}
b) {'Name': 'Virat', 'Runs': 2794, 'Age': 31, 'Country': 'India'}
{'Name': 'Rohit', 'Age': 33, 'Country': 'India'}
c) {'Name': 'Rohit', 'Runs': 2794, 'Age': 33, 'Country': 'India'}
{'Name': 'Rohit', 'Age': 33, 'Country': 'India'}
d) {'Name': 'Rohit', 'Age': 33, 'Country': 'India'}
{'Name': 'Rohit', 'Runs': 2794, 'Age': 33, 'Country': 'India'}
Ans c) {'Name': 'Rohit', 'Runs': 2794, 'Age': 33, 'Country': 'India'}
{'Name': 'Rohit', 'Age': 33, 'Country': 'India'}

PAGE:43
20 Assertion and reason Based question ( 1 Mark )

Mark the correct choice as


(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
Q1. Assertion (A): We cannot change the value of an integer variable.
Reasoning (R): Integer is immutable.
Ans (a)
Q2. Assertion (A): Comments provide extra information in a program.
Reasoning (R): Comments are not executed.
Ans (b)
Q3. Assertion (A): Strings can be multi-line or single line.
Reasoning (R): Strings are mutable.
Ans (c)
Q4. Assertion (A): Interactive mode can be used for testing small lines of code.
Reasoning (R): It executes the lines of code in an interactive manner.
Ans (a)
Q5. Assertion (A): Bug is any error in a program.
Reasoning (R): Debugging is the process of removal of error in a program.
Ans (b)
Q6. Assertion.(A) Python’s pass statement is an empty statement
Reason(R). An empty statement does nothing

Ans (a)
Q7. Assertion. (A) The flow of control in a program can occur sequentially, selectively
or iteratively.
Reason. (R). The sequence construct means that the statement will get executed
sequentially.

Ans (b)
Q8. Assertion. (A) Python statement ‘if’ represents selection construct.
Reason. (R). The selection construct means the execution of a set of statements,
depending upon the outcome of a condition.
Ans (a)
Q9. Assertion. (A) The for loop is a counting loop that works with sequences of values.
Reason. (R). The range( ) function generates a sequence of list type.
Ans (b)
Q10. Assertion. (A) Both break and continue are jump statement
Reason. (R). Both break and continue can stop the loops and hence can substitute
one another.
Ans (c)

PAGE:44
Q11. Assertion (A): List can be changed after creation.
Reason (R): List are mutable.
Ans Option a.
Q12. Assertion (A): remove( ) method removes all elements from a list
Reason (R): len ( ) function is used to find the length of list
Ans d. A is false but R is true.
Q13. Assertion (A): Elements of a list are separated by comma.
Reason (R): List is enclosed by a pair of straight brackets.
Ans b. Both A and R are true but R is the not correct explanation of A.
Q14. Assertion (A): clear( ) method removes all elements from a list
Reason (R): sort ( ) function is used sort a list in descending order
Ans c. A is true but R is false.
Q15. Assertion (A): append( ) method is used to add an element at the end of a list
Reason (R): extend ( ) function is used to merge two lists into a single list
Ans b. Both A and R are true but R is the not correct explanation of A.
Q16. Assertion (A): Dictionaries are mutable data type.
Reasoning (R): We can change the values of the dictionaries.

Ans (a) Both (A) and (R) are true and (R) is the correct explanation for (A).
Q17. Assertion (A): Dictionaries are mutable data type.
Reasoning (R): We cannot change the keys of the dictionaries.

Ans (b) Both (A) and (R) are true and (R) is not the correct explanation for (A).
Q18. Assertion (A):Items in dictionaries are unordered.
Reasoning (R):Internally, the key: value pairs of a dictionary are associated with one
another with some internal function (called hash-function). This way of linking is
called mapping.
Ans (a) Both (A) and (R) are true and (R) is the correct explanation for (A).
Q19. Assertion (A): We can update values of a dictionary by the help of keys.
Reasoning (R):It is not necessary that the key has to present in the dictionary.

Ans (c) (A) is true but (R) is false.


Q20. Assertion (A): We can add new key, value pairsto a dictionary.
Reasoning (R): Key to be added must not exist in dictionary and must be unique. If
the Key already exist, then it will change the value of existing key and no new entry
will be added to dictionary.

Ans. (a) Both (A) and (R) are true and (R) is the correct explanation for (A).

20 Short Knowledge/Understanding/Application Based Questions (2 Marks)

Q1. Write any four rules for naming an identifier.


Ans (a) It should not be a reserved word
(b) It can start with an alphabet or underscore.
(c) It cannot contain any special character
(d) It can contain digits but not in the starting position.

PAGE:45
Q2. State any two differences between ‘=’ and ‘= =’.

Ans
= ==

Assignment operator Relational operator

No return value. Returns True / False.

Q3. State any two types of operators with example.

Ans Logical operator – and, or, not


Arithmetic operator - +, -, /, *
Q4. What is the difference between ‘/’ and ‘//’.
Ans

/ //

Division operator Floor division operator

E.g. 5 / 2 = 2.5 E.g. 5 // 2 = 2


Q5. Give two ways of writing multi-line strings.
Ans

Method 1 Method 2

s= “Hello \ s= ‘ ‘ ‘ Hello
Everyone” Everyone ‘ ‘ ‘
Q6. What is range() function? Give an example.

Ans The range() function returns a sequence of numbers, starting from 0 by default, and
increments by 1 (by default), and stops before a specified number.
Syntax: range(start, stop, step)
Example:
x = range(3, 7)
for n in x:
print(n)
Output:
3
4
5
6

PAGE:46
Q7. What is the difference between break and continue
Ans
Basis for
break continue
comparison

It is used for the termination of


It is used for the termination of all the
Use the only current iteration of the
remaining iterations of the loop.
loop.

The control will pass to the


Control after using
The line which is just after the loop will next iteration of that current
break/continue
gain control of the program. loop by skipping the current
statement
iteration.

It performs early execution of


Causes It performs the termination of the loop. the next loop by skipping the
current one.

Q8. Write the output of the following code:


x=5
while(x<15):
print(x**2)
x+=3
Ans 25
64
121
196
Q9. Write the output of the following code:
val = 10
total = 0

for count in range(1,val,3):


total = total + count
if count % 2 == 0:
print(count*10)
else:
print(count)
print (total)
Ans 1
40
7
12
Q10. Find errors in the following code and write the correct code after underlining it.
x = int(input(“Enter value”)
for k in range[0,20]
if x=k
print(x+k)
else:
Print(x-k)
Ans x = int(input("Enter value"))
for k in range(0,20):
if x==k:
print(x+k)
else:
print(x-k)

PAGE:47
Q11. Predict the output:-
L1, L2=[1,2,3],[1,2,3]
L3=[1,[2],3]
print(L1==L2)
print(L2==L3)
Ans True
False
Q12. What is the difference between pop(index) and pop( ) function?
Ans pop(index) function deletes the element from i th index of the list.
pop( ) function deletes the last element from the list.
Q13. What is the difference between remove( ) and pop( ) function?
Ans The argument of pop( ) function is an index. It deletes the element from the given
index of the list.
The argument of delete( ) function is an element. It deletes the first occurrence
element from the list.
Q14. Predict the output of the following code fragment:-
values =[ ]
for i in range (1,4):
values.append(i)
print(values)
Ans [1,2,3]
Q15. Predict the output of the following code:-
a=[4,3,2,5,6]
print(a[:-3:-1])
print(a[-3:4])
Ans [6, 5]
[2, 5]
Q16. Write a python statement to create a dictionary ‘Marks5Subs’ having following
items: (Please don’t consider the column headers)
Name Marks of 5 Subjects
Sawan 67,74,56,48,87
Ankit 34,46,39,21,41
Puja 91,87,73,82,95
Arnab 78,98,97,95,99

Ans Marks5Subs={'Sawan':[67,74,56,48,87],'Ankit':[34,46,39,21,41],
'Puja':[91,87,73,82,95],'Arnab':[78,98,97,95,99]}
Q17. Write a python statement to create a dictionary ‘Currency’ having following items:
(Please don’t consider the column headers)
Country Currency
India Indian Rupee
Russia Ruble
USA Dollar
Japan Yen
Ans Currency={'India':'Indian Rupee','Russia':'Ruble',
'USA':'Dollar','Japan':'Yen'}

PAGE:48
Q18. Write a python statement to create a dictionary ‘NationalBird’ having following
items: (Please don’t consider the column headers)
Country National Bird
India Peacock
Australia Emu
Bahamas Flamingo
Italy Sparrow
New Zealand Kiwi
Ans NationalBird={'India':'Peacock','Australia':'Emu','Bahamas':'Flamingo',
'Italy':'Sparrow','New Zealand':'Kiwi'}
Q19. Ranit has written a python code to create a dictionary and display the values of the
dictionary using a loop but it is showing errors. Help him to find out errors and
underline the corrections.
Stds={'IX';153,'X';143,'XI';147,'XII';89}
for i in Std:
Print(i)
Ans Stds={'IX':153,'X':143,'XI':147,'XII':89}
for i in Stds:
print(Stds[i])
Q20. Sharmili has written a python code to create a dictionary Stds that stores student’s
strength of classes IX, X, XI and XII and it will calculate the total student’s strength
it is showing errors, Help her to find out errors and underline the corrections.
Stds={'IX':153,'X':143,'XI':147,'XII':89
Sum=1
for i in Stds.value():
Sum=+i
print(Sum)
Ans. Stds={'IX':153,'X':143,'XI':147,'XII':89}
Sum=0
for i in Stds.values():
Sum+=i
print(Sum)
20 Short Knowledge/Understanding/Application Based Questions (3 Marks)
Q1. What is data type conversion? State its two types with example.
Ans Conversion of one data type to another is known as data type conversion.
Two types - implicit and explicit(type casting).
Implicit - 5 / 2 = 2.5
Explicit - int(3.25) → 3
Q2. Define Dynamic Typing. Give an example.
Ans The value allotted to a variable can be changed dynamically in a program.
E.g.:
a=10
print(a)
a=”Hello” # changing the value of the variable

PAGE:49
Q3. Using example, explain the difference between mutable and immutable datatype.
Ans If the value of variable of a data type can be changed without affecting its address
then it is known as mutable data type, else it is known as immutable data type.
Q4. What is the use of comments in a program ? What are its two types ?
Ans Comments provide extra information for increasing the readability of a program.
Two types - single line comment and multi-line comment.
Q5. What do you mean by the precedence of operators ?
Ans Operator precedence affects how an expression is evaluated.
For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has
higher precedence than +, so it first multiplies 3*2 and then adds into 7.

Q6. Write a program to find the sum of the given series.


1 + x^2/2 + x^3/3 + … x^n/n
Ans n=int(input("Enter the number of terms:"))
x=int(input("Enter the value of x:"))
sum1=1
for i in range(2,n+1):
sum1=sum1+((x**i)/i)
print("The sum of series is",round(sum1,2))
Q7. Write a program to reverse a number using while loop.
Ans num = int (input (“Enter a number: “))
reversed_num = 0
while num != 0:
digit = num % 10
reversed_num = reversed_num * 10 + digit
num = num/10
print("Reversed Number: " + str(reversed_num))
Q8. Write a program to calculate the factorial of a number.
Ans n = int (input (“Enter a number: “))
factorial = 1
if n >= 1:
for i in range (1, n+1):
factorial = factorial *i
print (“Factorial of the given number is: “, factorial)
Q9. Write a program to check whether the number entered by the user is Perfect number.
Ans n = int(input("Enter any number: "))
sum1 = 0
for i in range(1, n):
if(n % i == 0):
sum1 = sum1 + i
if (sum1 == n):
print("The number is a Perfect number!")
else:
print("The number is not a Perfect number!")

PAGE:50
Q10. Write a program to print the given pattern.
*
**
***
****
*****
Ans for i in range(1, 6):
for j in range(1, i+1):
print(‘*’, end = " ")
print()
Q11. Write a program to find the average from a given list of integers.
Ans L=[5,8,3,4,6]
sum=0
for i in L:
sum+=i
avg=sum/len(L)
print(avg)
Q12. Predict the output of the following code:-
M=[]
M1=[]
M2=[]
for i in range(1,10):
M.append(i)
for i in range(10,1,–2):
M1.append(i)
for i in range(len(M1)):
M2.append(M1[i]+M[i])
M2.append(len(M)-len(M1))
print(M2)
Ans [11, 10, 9, 8, 7, 4]
Q13. What is the difference between sort( ) and sorted( ) function?
Ans sort( ) function will modify the list from which the function has been called while
sorted( ) function will create a new list which is given as argument.
sort( ) function works upon list onlt while sorted( ) function will work upon any
iterative sequence.
Q14. Predict output of the following code:-
for Name in ['Jayes', 'Ramya', 'Taruna', 'Suraj'] :
print(Name)
if Name[0]=='T':
break
else :
print('Finished!')
print('Got it!')
Ans Jayes
Finished!
Got it!
Ramya
Finished!
Got it!
Taruna

PAGE:51
Q15. Write a program that takes first 5 and last 5 elements of a list and stores them into another list.
Ans L=[1,1,2,3,5,4,7,9,5,4,9,6]
if len(L)<10:
print("Insufficient elements")
else:
LST=L[:5]+L[-5:]
print(L)
print(LST)
Q16. Consider the following Dictionary.
Capital={'India':'New Delhi', 'Iran':'Teheran', 'Nepal':'Kathmandu', 'Russia':'Moscow'}
Write statements to do the following:
a) To insert a new item for the country Japan.
b) To display name of the countries from the dictionary Capital.
c) To display name of the capitals from the dictionary Capital.
Ans a) Capital['Japan']='Tokyo'
b) print(Capital.keys())
c) print(Capital.values())
Q17. Consider the following Dictionary.
Goals2023={‘Messi’:26,’Ronaldo’:35,‘Haaland’:25,’Neymar’:20}
Write statements to do the following:
a) To modify the Goals of Neymar as 18.
b) To delete the record of Haaland.
c) To display the goals of Ronaldo.
Ans a) Goals2023['Neymar']=18
b) del Goals2023['Haaland']
c) print(Goals2023[‘Ronaldo’])
Q18. Write a python program to store details of five teachers having Employee ID, Name and
Designation to a dictionary and display only the details of those teachers whose name starts
with ‘R’ and designation is ‘PGT’.
Ans Teacher={'Emp1':{'EmpId':3698,'Name':'Rabi','Desig':'PGT'},
'Emp2':{'EmpId':9821,'Name':'Sachin','Desig':'PRT'},
'Emp3':{'EmpId':8219,'Name':'Ruksana','Desig':'TGT'},
'Emp4':{'EmpId':2195,'Name':'Martin','Desig':'TGT'},
'Emp5':{'EmpId':1975,'Name':'Robin','Desig':'PGT'}}
for i in Teacher.values():
if i['Name'][0]=='R' and i['Desig']=='PGT':
print(i)
Q19. Predict the output of the following code:
Goals2023={'Messi':26,'Ronaldo':35,'Haaland':25,'Neymar':20}
for i in Goals2023:
if len(i)>6:
print(i)
for i in Goals2023:
if Goals2023[i]>25:
print(i,Goals2023[i])
for i in Goals2023:
if Goals2023[i]%2==0:
print(i,Goals2023[i])
Ans Ronaldo
Haaland
Messi 26
Ronaldo 35
Messi 26
Neymar 20

PAGE:52
Q20. Soham wants to write a Python Code to calculate frequency of each distinct element
of a list but he is struggling at some points help him to complete the code.
Example:
Input: [12, 34, 21, 45, 21, 45, 12, 21, 32, 21, 21]
Output: {12: 2, 34: 1, 21: 5, 45: 2, 32: 1}

Code:
L=[12,34,21,45,21,45,12,21,32,21,21]
D={}
for ____________: #Statement 1
if i_______D: #Statement 2
_______________ #Statement 3
else:
D[i]+=1
print(L)
print(D)
a) Complete Statement 1 to traverse each element of the list one by one.
b) Complete Statement 2 to check whether i is not present in D as keys.
c) Complete Statement 3 to insert an entry for i in D with appropriate value.
Ans. a) Statement 1: for i in L:
b) Statement 2: if i not in D:
c) Statement 3: D[i]=1
20 Short Knowledge/Understanding/Application Based Questions (4 Marks)
Q1. Vedansh is a Python programmer working in a school. He has written the following
code, but it contains mistakes.

n1=Int ( input ( “Enter the number)) # statement 1


2n=int ( input ( “Enter the number”)) # statement 2
rem= n1 % n2 # statement 3
print(“rem” ) # statement 4
As a Python expert, help him by answering the following questions:
(a) Identify the statements that don’t contain any errors.
(b) Write the correct code for the statements containing error.
(c) Which type of operator is being used in statement 3.
(d) What will be the output if the input is 10 and 6 respectively for n1 and n2.
Ans (a) statement 3
(b) n1=int ( input ( “Enter the number”)) # statement 1
n2=int ( input ( “Enter the number”)) # statement 2
print(rem) # statement 4
(c) Arithmetic operator
(d) 4

PAGE:53
Q2. Soham has chosen the following names for some variables, give reasons why they are
invalid :
(a) 1sum
(b) sum@
(c) sum of num
(d) class
Ans (e) 1sum - starts with digit
(f) sum@ - contains special character ‘@’
(g) sum of num - contains space
(h) class - keyword
Q3. Rohan is trying to guess the size of following strings , help him to do so:

(a) (b)
‘\n’ “Ram’s”

(c) (d)
“ “ “ Hi “Hi \
All “ “ “ All”
Ans (a) 1 (b) 5 (c) 6 (d) 5
Q4. Find the output of the following code:
a,b,c=10,20,30
a,c,b=b-5,a-3,c-6
print(a,b,c)
Ans 15 24 7
Q5. Find the output of the following code snippets:
(a) type(‘None’) (b) type(None)
(c) print( print(“OK”)) (d) type(0o56)
Ans (a) string (b) None (c) None (d) int
Q6. What do you mean by looping construct in Python? Explain for loop and while loop
with their syntax and appropriate examples.
Ans The looping construct means repetition of a set of statements on the basis of a
condition test. Furthermore, till the time a condition turns out to be true or false
depending upon the loop, the repetition of a set of statements takes place again and
again.
for loop
A for loop is a type of loop that runs for a preset number of times. It also has the
ability to iterate over the items of any sequence, such as a list or a string.

PAGE:54
Syntax
for i in <collection>:
<loop body>
Example
for i in range(10): # collection of numbers from 0 to 9
print(i)
Here, collection is a list of objects. The loop variable, i, takes on the value of the next
element in collection each time through the loop. The code within loop body keeps
on running until i reach the end of the collection.
while loop
With the while loop, we can execute a block of code as long as a condition is true.
Syntax
while <condition>:
<loop body>
In a while loop, the condition is first checked. If it is true , the code in loop body is
executed. This process will repeat until the condition becomes false.
This piece of code prints out integers between 0 and 9 .
Example
n=0
while n < 10: # while n is less than 10,
print(n) # print out the value of n
n += 1 #
Q7. What do you mean by jumping statements in Python? Explain break, continue and
pass with appropriate examples.
Ans In Python, jumping statements are used to control the flow of a program by altering the
normal execution sequence. They allow you to change the order in which statements are
executed in a loop or conditional block. The three common jumping statements in Python are
break, continue, and pass.
break:
The break statement is used to exit the current loop prematurely, whether it's a for loop or a
while loop.
It is typically used when a certain condition is met, and you want to terminate the loop
immediately.
Example:
for i in range(1, 6):
if i == 3:
break # This will exit the loop when i is equal to 3
print(i)
continue:
The continue statement is used to skip the current iteration of a loop and proceed to the next
iteration.
It is often used when you want to skip some specific values or conditions but continue with
the loop.
Example:
for i in range(1, 6):
if i == 3:
continue # This will skip iteration when i is equal to 3
print(i)
pass:

The pass statement is a placeholder statement that does nothing. It is often used as a
placeholder when you need a statement syntactically but don't want to execute any code.

PAGE:55
Example:
for i in range(1, 4):
if i == 2:
pass # This will do nothing when i is equal to 2
else:
print(i)
Q8. Write a program to check if input number is a prime number.
Ans num = int(input("Enter a number: "))
if num > 1:
# check for factors
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
break
else:
print(num,"is a prime number")
# if input number is less than
# or equal to 1, it is not prime
else:
print(num,"is not a prime number")
Q9. Write a program to check whether a year is leap year or not.
Ans input_year = int(input("Enter the Year to be checked: "))
if (( input_year%400 == 0) or (( input_year%4 == 0 ) and ( input_year%100 != 0))):
print("%d is Leap Year" %input_year)
else:
print("%d is Not the Leap Year" %input_year)
Q10. Write a program to display the Fibonacci series upto nth term.
Ans #Python program to generate Fibonacci series until 'n' value
n = int(input("Enter the value of 'n': "))
a=0
b=1
sum = 0
count = 1
print("Fibonacci Series: ", end = " ")
while(count <= n):
print(sum, end = " ")
count += 1
a=b
b = sum
sum = a + b

Q11. Predict the output of the following code:-


Moves=[11, 22, 33, 44]
Queen=Moves
Moves[2]+=22
L=len(Moves)
for i in range (L):
print (“Now@”, Queen[L-i-1], “#”, Moves [i])

Ans Now@ 44 # 11
Now@ 55 # 22
Now@ 22 # 55
Now@ 11 # 44

PAGE:56
Q12. Write a program to count positive numbers, negetive numbers and zeroes from a list of
integers. The list elements will be entered by the user.
Ans L=[]
p,n,z=0,0,0
s=int(input("Enter size of the list:"))
for i in range(s):
x=int(input("Enter element:"))
L.append(x)
if x>0:
p=p+1
elif x<0:
n=n+1
else:
z=z+1
print(L)
print("Postive Numbers=",p)
print("Negative Numbers=",n)
print("Zeroes=",z)
Q13. Write a program to input a list and an element and remove all occurences of the given
element from the list.
Ans Lst=eval(input(“Enter a list”))
item=int(input(“Enter thr item to remove”))
c=Lst.count(item)
if c==0:
print(“Item not found”)
else:
while(c>0):
i=Lst.index(item)
Lst.pop(i)
c-=1
print(Lst)
Q14. Given a list of integers, write a program to sum of even mumbers and odd numbers.
Ans L=[5,8,9,7,5,4]
sumeven, sumodd=0,0
for i in L:
if i%2==0:
sumeven+=i
else:
sumodd+=i
print(L)
print("Sum of even Numbers=",sumeven)
print("Sum of odd Numbers=",sumodd)

Q15. Identify the operators along with their names from the following statements:-
a. 5 in [1,2,3,4,5]
b. [1,2,3]*2
c. [1,2,3,4,5][1:3]
d. [1,2,3]+[4,5]

Ans a. in – membership operator


b. * - replication operator
c. : - slice operator
d. + - concatenation operator

PAGE:57
Q16. Predict the output of the following code:
Teacher1,Teacher2={'EmpId':3698,'Name':'Robin','Desig':'PGT',
'Sub':'Chemistry'},{'EmpId':9821,
'Name':'Sachin','Desig':'PRT','HomeTown':'Patna'}
print(Teacher1)
print(Teacher2)
Teacher1.update(Teacher2)
print(Teacher1)
print(Teacher2)
Ans {'EmpId': 3698, 'Name': 'Robin', 'Desig': 'PGT', 'Sub': 'Chemistry'}
{'EmpId': 9821, 'Name': 'Sachin', 'Desig': 'PRT', 'HomeTown': 'Patna'}
{'EmpId': 9821, 'Name': 'Sachin', 'Desig': 'PRT', 'Sub': 'Chemistry', 'HomeTown':
'Patna'}
{'EmpId': 9821, 'Name': 'Sachin', 'Desig': 'PRT', 'HomeTown': 'Patna'}
Q17. Predict the output of the following code:
Marks5Subs={'Sawan':[67,74,56,48,87],'Ankit':[34,46,39,21,41],
'Puja':[91,87,73,82,95],'Arnab':[78,98,97,95,99]}
print(max(Marks5Subs['Sawan']))
print(min(Marks5Subs['Ankit']))
print(len(Marks5Subs['Arnab']))
print(len(Marks5Subs))
Ans 87
21
5
4
Q18. Predict the output of the following code:
Age={'Sawan':67,'Ankit':34,'Puja':21,'Arnab':23}
print(list(Age.items()))
del Age['Sawan']
print(Age)
Age.clear()
print(Age)
del Age
print(Age)
Ans [('Sawan', 67), ('Ankit', 34), ('Puja', 21), ('Arnab', 23)]
{'Ankit': 34, 'Puja': 21, 'Arnab': 23}
{}
NameError: name 'Age' is not defined
Q19. Predict the output of the following code:
Result={'PT1':{'Suresh':35,'Kabir':29,'Lisa':17,'Hina':36},
'HYE':{'Suresh':87,'Kabir':56,'Lisa':87,'Hina':65},
'PT2':{'Suresh':37,'Kabir':23,'Lisa':27,'Hina':33},
'SEE':{'Suresh':78,'Kabir':65,'Lisa':89,'Hina':75}}
T_Suresh=T_Kabir=T_Lisa=T_Hina=0
for i in Result:
T_Suresh+=Result[i]['Suresh']
T_Kabir+=Result[i]['Kabir']
T_Lisa+=Result[i]['Lisa']
T_Hina+=Result[i]['Hina']
print(T_Suresh)

PAGE:58
print(T_Kabir)
print(T_Lisa)
print(T_Hina)
Ans 237
173
220
209
Q20. Predict the output of the following code:
Teacher1=Teacher2={'EmpId':3698,'Name':'Robin','Desig':'TGT'}
Teacher1['Desig']='PGT'
Teacher2['Sub']='CS'
print(Teacher1)
print(id(Teacher1))
print(Teacher2)
print(id(Teacher2))
Ans. {'EmpId': 3698, 'Name': 'Robin', 'Desig': 'PGT', 'Sub': 'CS'}
50519352
{'EmpId': 3698, 'Name': 'Robin', 'Desig': 'PGT', 'Sub': 'CS'}
50519352
15 Case Based Questions (5 Marks)
Q1. Namita is trying to understand the concept of literal, help him by answering the
following questions:
(a) what is literal
(b) state any two types of literals
(c) Name the special literal
(d) give an example of integer literal
(e) what is Boolean literal ?
Ans (a) Literal represents a value of a particular data type
(b) string literal and boolean literal.
(c) None
(d) 527
(e) True / False
Q2. Rakesh is unable to understand the difference between statement and expression,
write differences between them along with examples.
Ans

PAGE:59
Q3. Shilu has to write a program to accept the name of a person and greet him/her in the
following manner:
Hello <name>, welcome to our class.
Help Shilu to write the program.
Ans n=input(“Enter the name:”)
print(“Hello”,n, “welcome to our class”)
Q4. Write a program to accept two numbers and print their sum in the following manner:
The sum of <n1> and <n2> is <n1+n2>.
Ans n1=int(input(“Enter the number:”))
n2=int(input(“Enter the number:”))
print(“The sum of” ,n1,” and “, n2,” is”,n1+n2)
Q5. Find the output of the following:
(a) “ “ and “Hello”
(b) 2 and 4
(c) ‘a’ or ‘b’
(d) True and ‘Hi’
(e) 0 or 5
Ans (f) “ “ and “Hello” → “Hello
(g) 2 and 4 → 4
(h) ‘a’ or ‘b’ → a
(i) True and ‘Hi’ → Hi
(j) 0 or 5 - 5
Q6. Mr. Aakash wants to calculate electricity charges based on the number of consumed
electricity units and other charges. Write a program in Python to generate electricity
bill as per the following conditions.
i. If unit consumed <= 100 then cost per unit is Rs 3.46
ii. If unit consumed >= 101 and <= 300 then cost per unit is Rs 7.43
iii. If unit consumed >= 301 and <= 500 then cost per unit is Rs 10.32
iv. If unit consumed >= 501 then the cost per unit is Rs 11.71
v. Line rent is Rs 1.45 per unit.
vi. Additional fixed Meter rent is Rs 100.
vii. The tax on the bill is 16 percent which can be taken as 0.16.
Ans unit = int(input("Enter your unit: "))
if unit <= 100:
bill = unit * 3.46
elif unit >= 101 and unit <= 300:
bill = 346 + ((unit - 100) * 7.43)
elif unit >= 301 and unit <= 500:

PAGE:60
bill = 346 + 1486 + ((unit - 300) * 10.32)
else:
bill = 346 + 1486 + 2064 + ((unit - 500) * 11.71)
print("Bill Per Unit:",bill)
bill = bill + (unit*1.45)
print("Bill after adding Line rent:",bill)
bill = bill + 100
print("Bill after adding Meter rent:",bill)
bill = bill + (bill*0.16)
print("Total Bill after adding tax:",bill)
Q7. Mr. Ravi is a class teacher in Modern Public School. He wants to determine the
student's grade based on the results of five subjects and the criteria given below.
Average Mark Grade
91-100 A1
81-90 A2
71-80 B1
61-70 B2
51-60 C1
41-50 C2
33-40 D
21-32 E1
0-20 E2
Write an appropriate program in Python to find out the grade of a student.
Ans print("Enter Marks Obtained in 5 Subjects: ")
markOne = int(input())
markTwo = int(input())
markThree = int(input())
markFour = int(input())
markFive = int(input())
tot = markOne+markTwo+markThree+markFour+markFive
avg = tot/5
if avg>=91 and avg<=100:
print("Your Grade is A1")
elif avg>=81 and avg<91:
print("Your Grade is A2")
elif avg>=71 and avg<81:
print("Your Grade is B1")
elif avg>=61 and avg<71:
print("Your Grade is B2")
elif avg>=51 and avg<61:
print("Your Grade is C1")
elif avg>=41 and avg<51:
print("Your Grade is C2")
elif avg>=33 and avg<41:
print("Your Grade is D")

PAGE:61
elif avg>=21 and avg<33:
print("Your Grade is E1")
elif avg>=0 and avg<21:
print("Your Grade is E2")
else:
print("Invalid Input!")
Q8. A list is a standard data type in Python that can store a sequence of values belonging to any
type. Lists are enclosed in a pair of square brackets. These are mutable, i.e, elements can be
changed by the user. Every element of a list has an index. Indexing begins from zero.
Questions:-
I.List defined within a list is called:-
a. nested list b. super list c. sub list d. hidden list
II. In Python, list is of type:-
a. Immutable b. Mutable c. Both a & B d. None of a & b
III. If a list contains n elements, then the index of the last element will be:-
a. 0 b. n c. n+1 d. n-1
IV. Which type of the bracket is used to define a list?
a. ( ) b. { } c. [ ] d. <>
V. List can contain values of these types:-
a. integers b. float c. string d. all of these
Ans I. a II.b III.d IV.c V.d
Q9. Amit has created two lists L1=[6,2,3,8] and L2=[1,5,4]
He has been asked by his teacher to write the code for the following tasks:-
I. To predict the output of the code:-

L3=L2.extend(L1)
print(L3)
II. To display smallest number from L3
III.To add 2nd element from L1 and 3rd element from L2
IV. To arrange the elements of L3 in descending order
V. To predict the output : L1[:2]+L2[2:]
Ans I. [1,5,4,6,2,3,8]
II. min(L3)
III. L1[1] + L2[2]
IV. L3.sort(reverse=True)
V. [6,2,4]
Q10. Rakesh wants to write a program to count the number of vowels from the word 'Alexander'
by converting it into a list. But the program does not run due to errors. Help Rakesh to
identify and rectify the errors so that program can run:-

L=List('Alexander')
count==0
For i in L:
if i within 'aeiouAEIOU'
count=+1
print(count)

Ans L=list('Alexander')
count=0
for i in L:
if i in 'aeiouAEIOU'
count+=1
print(count)

PAGE:62
Q11. Raman has stored record of a student in a list as follows:-
rec=[‘Thomas’,’C-25’,[56,98,99,72,69],78.8]
Suggest him the Python statements to do the following tasks:-
a. To find the percentage
b. To find marks of 5th subject
c. Maximum marks of the student
d. To find total marks
e. To change the name from ‘Thomas’ to ‘ Charles’
Ans a. rec[3]
b. rec[2][4]
c. max(rec[2])
d. rec[0]+rec[1]+rec[2]+rec[3]+rec[4] or sum(rec)
e. rec[0]=‘Charles’
Q12. Rehana has a list of both positive numebers. She has been given a task to separate
positive and negetaive numbers into two different lists and finally to delete the
original list. She has written a code where some statements incomplete. Complete the
imcomplete statements by filling in the blanks:-
Numbers=[5,-8,9,-7,5,-4]
Pos, Neg= ____ #Statement 1: To initialize empty lists
for i in range( ): # Statement 2: To write the range to access all elements
if Numbers[i]>=0:
____________ # Statement 3: To add element in POS
else:
_____________ # Statement 4: To add element in another list
____________ #Statement 5: To delete the original list
print (Pos)
print(Neg)
print("Task Completed")
Ans a. Statement 1: Pos, Neg=[],[]
b. Statement 2: for i in range(len(Numbers)):
c. Statement 3: Pos.append(Numbers[i])
d. Statement 4: Neg.append(Numbers[i])
e. Statement 5: del Numbers
Q13. Write a menu driven program to store marks of students with the following features:
Press 1 to add a new student’s record.
Press 2 to update an existing student’s record.
Press 3 to delete an existing student’s record who have taken TC
Press 4 to display a particular student’s record.
Press 5 to display records of all students
Press 6 to exit
Ans Record={}
while True:
print('Press 1 to add a new student’s record')
print('Press 2 to update an existing student’s record')
print('Press 3 to delete an existing student’s record who have taken TC')
print('Press 4 to display a particular student’s record')
print('Press 5 to display records of all students')
print('Press 6 to exit')
op=int(input('enter the value'))
if op==1:

PAGE:63
Name=input('Enter Name')
Marks=int(input('Enter Marks'))
Record[Name]=Marks
elif op==2:
Name=input('Enter Name')
Marks=int(input('Enter Marks'))
Record[Name]=Marks
elif op==3:
Name=input('Enter Name')
del Record[Name]
elif op==4:
Name=input('Enter Name')
print(Record[Name])
elif op==5:
print(Record)
elif op==6:
break
else:
print('Wrong Choice')
Q14. Write a menu driven program to show category wise student enrolment details of a
KV with the following features.
Press 1 to add a new category.
Press 2 to update an existing category.
Press 3 to delete an existing category
Press 4 to display enrolment of a particular category.
Press 5 to display all category wise enrolment.
Press 6 to exit
Ans Enrol={}
while True:
print('Press 1 to add a new category')
print('Press 2 to update an existing category')
print('Press 3 to delete an existing category')
print('Press 4 to display enrolment of a particular category')
print('Press 5 to display all category wise enrolment')
print('Press 6 to exit')
op=int(input('enter the value'))
if op==1:
Cat=input('Enter Category')
Tot=int(input('Enter enrolment under the Category'))
Enrol[Cat]=Tot
elif op==2:
Cat=input('Enter Category')
Tot=int(input('Enter enrolment under the Category'))
Enrol[Cat]=Tot
elif op==3:
Cat=input('Enter Category')
del Enrol[Cat]
elif op==4:
Cat=input('Enter Category')
print(Enrol[Cat])

PAGE:64
elif op==5:
print(Enrol)
elif op==6:
break
else:
print('Wrong Choice')
Q15. Write a menu driven program to simulate Bank Application with the following
features:
Press 1 to open a savings bank account
Press 2 to deposit money
Press 3 to withdraw money
Press 4 to check balance
Press 5 to exit
Ans Acc={}
AccNo=1000
while True:
print('Press 1 to open a savings bank account')
print('Press 2 to deposit money')
print('Press 3 to withdraw money')
print('Press 4 to check balance')
print('Press 5 to exit')
op=int(input('enter the value'))
if op==1:
Name=input('Enter Name')
Age=int(input('Enter Age'))
AccNo+=1
Acc[AccNo]={'Name':Name,'Age':Age,'Bal':0}
elif op==2:
Ac=int(input('Enter Account No'))
Amt=int(input('Enter the amount to be deposited'))
for i in Acc:
if i==Ac:
Acc[i]['Bal']+=Amt
elif op==3:
Ac=int(input('Enter Account No'))
Amt=int(input('Enter the amount to be deposited'))
for i in Acc:
if i==Ac:
Acc[i]['Bal']-=Amt
elif op==4:
Ac=int(input('Enter Account No'))
for i in Acc:
if i==Ac:
print(Acc[i])
elif op==5:
break
else:
print('Wrong Choice')

PAGE:65

You might also like