XI Informatics Practices
XI Informatics Practices
कोलकाता सींभाग
KENDRIYA VIDYALAYA SANGATHAN
KOLKATA REGION
अध्ययन सामग्री
STUDY MATERIAL
कक्षा : ग्यारहवी ीं
CLASS: XI
इन्फॉमैटिक्स प्रैक्टिसेज
Informatics Practices (065)
2023-24
कोलकाता सींभाग
KOLKATA REGION
PAGE:1
Chief Patron :- Mr. Y. Arun Kumar
Deputy Commissioner, KVS RO Kolkata
Patrons :- 1) Mr. Sanjib Sinha
Assistant Commissioner, KVS RO Kolkata
2)Mr. Chintapalli Vijaya Ratnam
Assistant Commissioner, KVS RO Kolkata
3)Mr. Dibakara Bhoi
Assistant Commissioner, KVS RO Kolkata
4) Mr. Amit Baidya
Assistant Commissioner, KVS RO KOL.
Co-Ordinator :- Mr. Amarendra Kumar Jha
Principal I/C,KV NO-1 AFS Kalaikunda
PAGE:2
Salient features of this Study Material
1. Targeting 100% pass rate.
2. Ensuring a minimum level of learning.
3. Providing support for improving risers and other students of Class XI in the
subject of IP (Informatics Practices).
4. Provide an introduction to the chapter, including its relevance and importance.
5. Summarize the key concepts and takeaways from the chapter.
6. Multiple Choice Questions (MCQs):
Present a set of multiple-choice questions related to the chapter .Include
options for each question and provide correct answers.
7. Assertion and Reason-Based Questions:
Include assertion and reason-based questions to test logical reasoning. and
provide correct answers.
8. Questions of 2 Marks (Knowledge/Understanding/Application-Based )
Create questions related to identifying errors in code or predicting program
output and Include model answers.
9. 3 Marks Questions (Knowledge/Understanding/Application-Based):
Formulate questions requiring a deeper understanding of the chapter.
Include questions that test the application of concepts and provide model
answers.
10.4 Marks Questions (Knowledge/Understanding/Application-Based):
Include comprehensive questions combining various aspects of the chapter.
Cover topics like application, output, errors, and in-depth understanding and
provide detailed model answers
11.Case Study-Based Questions:
Include case study questions that require students to analyse and apply their
knowledge to real-world scenarios. Provide model answers or suggested
approaches to solving the case studies.
PAGE:3
INDEX
1 DISTRIBUTION OF MARKS 05
2 Syllabus 06
2 UNIT-1
Introduction to Computer System 07-28
3 UNIT-2
Introduction to Python 29-65
4 UNIT-3
Database concepts and the Structured 66-87
Query Language
5 UNIT-4
Introduction to Emerging Trends 87-98
PAGE:4
Units and Marks
UNIT UNIT NAME MARKS
1 Introduction to Computer System 10
2 Introduction to Python 25
3 Database concepts and the 30
Structured Query Language
4 Introduction to Emerging Trends 5
5 Practical 30
TOTAL 100
PAGE:5
Syllabus of Class XI IP (2023-2024)
PAGE:6
Name of the chapter : Introduction to Computer System
Topic Covered
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
PAGE:12
Q22. _________ is a software that can be freely downloaded and even distributed to
others.
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?
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
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)
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.
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
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?
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
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.
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
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
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.
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']
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.
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.
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
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.
PAGE:35
N.B: Key must exist in the dictionary otherwise new entry will be added to
dictionary.
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'
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 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 )
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. (a) Both (A) and (R) are true and (R) is the correct explanation for (A).
PAGE:45
Q2. State any two differences between ‘=’ and ‘= =’.
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
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.
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.
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
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]
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
Name of the chapter : Database concepts and the
Structured Query Language
Topic Covered
• 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
• Advantages of using Structured Query Language, Data Definition Language, Data Query
Language and Data Manipulation Language, Introduction to MySQL, Creating a
databaseusing MySQL,Data Types
• Data Definition:CREATE DATABASE, CREATE TABLE, DROP, ALTER
• Data Query: SELECT, FROM, WHERE with relational operators, BETWEEN, logical operators,
IS NULL, IS NOT NULL
• Data Manipulation: INSERT, DELETE,UPDATE
Key Points
Candidate KeyAll the attributes combinations inside a relation that can serve as primary key.
Constraint Rule and conditions set for data being stored in a database.
DDL Data Definition Language. SQL part-language that facilitates defining creation/ modification
etc. of database objects such as tables, indexes, sequences etc.
DML Data Manipulation Language. SQL part-language that facilitates manipulation (addition/
deletion/ modification) of data residing in database object.
Primary Key A set of one or more attributes that can uniquely identify tuples within the relation.
Relation A table having non-empty atomic values with unordered rows and columns is relation.
SQL Structured Query Language. A non-procedural UGL used for querying upon relational database.
Tuple A row in a relation is called tuple. View A virtual table that does not really exist in its own
right but is instead derived from one or more underlying base tables in called a view
Execution :
PAGE:66
Fundamental components of a query used to retrieve specific data from a database table.
This clauses allow you to specify :
❖ What data you want to retrieve (SELECT),
❖ Which table it should come from (FROM),
❖ Which specific rows should be included based on a condition (WHERE).
Description of each:
(i) SELECT:
➢ used to specify which columns or expressions you want to retrieve from a database
table.
➢ It is followed by a comma-separated list of column names or expressions enclosed in
parentheses.
(ii) FROM:
➢ Specifies the table or tables from which you want to retrieve data.
➢ It follows the SELECT clause in the SQL query.
➢ You can query data from one or more tables by listing them after the FROM keyword,
separated by commas.
(iii) WHERE:
➢ Used to filter the rows that are returned from the database table based on a specified
condition.
➢ It follows the FROM clause and is followed by a condition that determines which
rows should be included in the result set.
➢ The condition can include
o Relational Operators (e.g., '=', '<', '>', '<=', '>=', '<>'),
PAGE:67
o Logical Operators (e.g., AND, OR),
o Other functions or expressions.
Example: SELECT
column1, column2
FROM
table_name
WHERE
column1 <= 'value';
(b) Range Operator Between. : The BETWEEN operator in SQL is used to filter rows based on a
specified range of values.
SELECT
ProductName, Price
FROM
Products
WHERE
Price BETWEEN 10 AND 50;
(c) Logical Operator : Logical operator is used to combine two or more logical expression,
(i) And – evaluated true if all the logical expression is true otherwise false. E.g.
SELECT
*
FROM
Customers
WHERE
Country = 'USA' AND City = 'New York';
(ii) Or - evaluated true if any the logical expression is true otherwise false. e.g.
SELECT
*
FROM
Products
WHERE
Category = 'Electronics' OR Price < 50;
(d) Comparing NULL :
is null, is not null NULL (Absence of value) value cannot be compared using Relational
operator.
PAGE:68
This statement is used to check whether column contains NULL or not. E.g.
SELECT
*
FROM
Customers
WHERE
PhoneNumber IS NULL;
PAGE:69
Ans Structured Query Language
Q14 A ____________ is a subset of DML that just deals with information retrieval.
a. Query Language
b. Structure Language
c. Both a) and b)
d. None of the above
Ans Query Language
Q15 A ______________ is a language that enables users to access and manipulate data in a
database.
a. Data Manipulation Language (DML)
b. Data Definition Language (DDL)
c. Both a) and b)
d. None of the above
Ans Data Manipulation Language (DML)
Q16. What SQL clause is used to specify the columns you want to retrieve from a table?
(A) SELECT
(B) FROM
(C) WHERE
(D) INSERT
Ans A) SELECT
Q17. Which SQL clause specifies the table from which data should be retrieved?
(A) SELECT
(B) FROM
(C) WHERE
(D) UPDATE
Ans B) FROM
Q18. What SQL operator is used for exact value matching in a WHERE clause?
(A) LIKE
(B) BETWEEN
(C) =
(D) AND
Ans C) =
Q19. Which SQL operator is used to check if a column value falls within a specified range?
(A) LIKE
(B) BETWEEN
(C) =
(D) AND
Ans B) BETWEEN
Q20. What is the purpose of the IS NULL operator in SQL?
(A) It checks if a column contains a specific value.
(B) It checks if a column is empty.
(C) It checks if a column is not empty.
(D) It checks if a column exists.
Ans B) It checks if a column is empty.
Q21. Which logical operator combines multiple conditions in a WHERE clause with an OR
relationship?
(A) AND
(B) OR
PAGE:70
(C) NOT
(D) XOR
Ans B) OR
Q22. What SQL statement is used to add new records to a database table?
(A) INSERT
(B) DELETE
(C) UPDATE
(D) ALTER
Ans A) INSERT
Q23. Which SQL clause is used to delete records from a database table?
(A) INSERT
(B) DELETE
(C) UPDATE
(D) ALTER
Ans B) DELETE
Q24. Which SQL clause is used to modify existing records in a database table?
(A) INSERT
(B) DELETE
(C) UPDATE
(D) ALTER
Ans C) UPDATE
Q25. Which SQL statement is used to remove all records from a table?
(A) TRUNCATE
(B) DROP
(C) DELETE
(D) REMOVE
Ans C) DELETE
Q26 What does the SQL WHERE clause do?
(A) It specifies which columns to retrieve.
(B) It filters the rows to include based on a condition.
(C) It specifies the table to query.
(D) It sorts the result set.
Ans B) It filters the rows to include based on a condition.
Q27 What is the purpose of the NOT operator in a SQL WHERE clause?
(A) It negates a condition.
(B) It checks if a column is empty.
(C) It checks if a column exists.
(D) It combines conditions with OR.
Ans A) It negates a condition.
Q28 Which SQL clause is used to update data in a table with new values?
(A) INSERT
(B) DELETE
(C) UPDATE
(D) ALTER
Ans C) UPDATE
Q29 What SQL operator is used for pattern matching in a WHERE clause?
(A) LIKE
(B) BETWEEN
(C) =
PAGE:71
(D) AND
Ans A) LIKE
Q30 Which SQL operator checks if a column value is not equal to a specified value in a WHERE
clause?
(A) LIKE
(B) BETWEEN
(C) <>
(D) AND
Ans C) <>
10 Assertion and reason Based question ( 1 Mark )
In the following questions, a statement of Assertion (A) is followed by statement of Reason . (R).
Mark the correct choice as :
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true and R is not the correct explanation of A.
(c) A is true but R is false (or partly true)
(d) A is false (or partly true ) but R is true.
(e) Both A and R are false or not fully true.
Q1. Assertion : A data table can have only one Primary key.
Reason : In a data table, there can be only one attribute/field containing
unique values for each row.
Ans A is true but R is false (or partly true)
Q2. Assertion : There can be multiple options for choosing a primary key in a data
table.
Reason : All attribute combinations inside a data table that contain unique values
for each row, are the candidates keys.
Ans Both A and R are true and R is not the correct explanation of A
Q3. Assertion : All types of keys contain unique values A data table can have only one
Primary key.
Reason : In a data table, there can be only one attribute/field containing
unique values for each row.
PAGE:72
Reason : The WHERE clause specifies conditions to filter rows in a query.
Ans (C) The assertion is true, but the reason is false.
Q8. Assertion: The IS NULL operator in SQL checks if a column has a value.
Reason : The IS NULL operator checks if a column contains a specific value.
Ans (C) The assertion is true, but the reason is false.
Q9. Assertion: The SQL DELETE statement is used to add new records to a database table.
Reason : The DELETE statement removes records from a database table.
Ans (B) Both the assertion and reason are true, but the reason does not explain the assertion.
Q10. Assertion: The SQL BETWEEN operator is used for exact value matching in a WHERE
clause.
Reason : The BETWEEN operator checks if a column value falls within a specified range.
Ans (A) Both the assertion and reason are true, and the reason correctly explains the assertion.
10 Short Knowledge/Understanding/Application Based Questions (2 Marks)
Q1. Differentiate between DDL and DML with one Example each.
Ans DDL DML
Stands for Data definition language Stands for Data manipulation language
Consists of commands used to Consist of commands used to modify the
modify the metadata of a table. data of a table.
Example- create table, alter table, Example- insert, delete, update
drop table
Table : Transaction
T1 CREDIT 1000 C3
T2 DEBIT 1500 C1
CNo CNAME
C1 ZEESHAN
C2 AMAN
PAGE:73
C3 JASPREET Table : Customer
(i) What is the degree of the table Transaction ? what is the cardinality of the table
Customers ?
ii. Identify the primary key and candidate keys from the table Transcations.
PAGE:74
Write an SQL query to update the price of a product with a ProductID of 101 to $25.50.
Ans UPDATE Products SET Price = 25.50 WHERE ProductID = 101;
10 Short Knowledge/Understanding/Application Based Questions (3 Marks)
Q1. Differentiate between Primary Key and Alternate Key.
Ans Primary keys Alternate keys
Primary keys - Contain one or more Alternate keys - Contain one or more
columns whose combined values columns whose combined values
uniquely identify every row in a uniquely identify every row in a table.
table. Each table can have only one
primary key.
Q2. In a multiplex, movies are screened in different auditoriums. One movie can be shown in
more than one auditorium. In order to maintain the record of movies,
the multiplex maintains a relational database consisting of two relations viz. MOVIE and
AUDI respectively as shown below:
Movie(Movie_ID, MovieName, ReleaseDate)
Audi(AudiNo, Movie_ID, Seats, ScreenType,TicketPrice)
a) Is it correct to assign Movie_ID as the primary key in the MOVIE relation? If no, then
suggest an appropriate primary key.
b) Is it correct to assign AudiNo as the primary key in the AUDI relation? If no, then suggest
appropriate primary key.
c) Is there any foreign key in any of these relations?
Ans a) Yes, because every movie will have it's unique id.
b) Yes, because every auditorium will be assigned a unique id. No two auditoriums will have same id.
c) Yes, Movie_ID in Audi table is the foreign because it references the Movie_ID in the Movie table.
Q3. An organisation wants to create a database EMPDEPENDENT to maintain following details
about its
employees and their dependent.
EMPLOYEE(AadharNumber, Name, Address,Department,EmployeeID)
DEPENDENT(EmployeeID, DependentName, Relationship)
a) Name the attributes of EMPLOYEE, which can be used as candidate keys.
b) The company wants to retrieve details of dependent of a particular employee. Name the
tables and the key which are required to retrieve this detail
c) What is the degree of EMPLOYEE and DEPENDENT relation?
Ans a) AadharNumber and EmployeeID can be used for candidate keys because they are unique to
every employee.
b) Employee and Dependent tables are required. EmployeeID is the key to retrieve the
required data.
c) Degree of Employee relation = 5 and degree of Dependent relation = 3
The number of attributes in a relation is called the Degree of the relation.
Q4. Why foreign keys are allowed to have NULL values? Explain with an example.
Ans In a relational database, a foreign key is a field that refers to the primary key in another table.
The foreign key establishes a link or relationship between two tables.
In some database systems, foreign keys are allowed to have NULL values,
Allowing foreign keys to have NULL values can be useful in certain scenarios,
such as when one have optional relationships between tables. In such cases,
the absence of a foreign key value indicates that there is no corresponding
entry in the referenced table.
Q5. Compared to a file system, how does a database management system avoid redundancy in
PAGE:75
data through a database?
Ans A database management system (DBMS) is designed to provide a structured and efficient way
to store, retrieve, and manage data. Compared to a file system, a DBMS offers several
features and mechanisms to avoid redundancy in data and promote data integrity. Here are
some key ways in which a DBMS
achieves this:
Data Normalization:
Reduction of Redundant Data:
Foreign Keys: DBMSs use foreign keys to establish relationships between tables.
Data Type Enforcement: DBMSs enforce consistent data types for columns, preventing the
storage of incompatible data.
Constraints: Integrity constraints, such as unique constraints and check constraints, ensure
that data adheres to specified rules, preventing the insertion of duplicate or inconsistent
information.
ACID Properties:
Atomicity, Consistency, Isolation, Durability (ACID): DBMSs adhere to these fundamental
properties
Q6. Explain the purpose of SQL transactions and why they are important in database
management.
Ans SQL transactions are used to ensure the atomicity, consistency, isolation, and durability
(ACID) properties of a database. Transactions are important to maintain data integrity by
allowing a series of SQL statements to be executed as a single, indivisible unit, ensuring that
either all changes are applied or none.
Q7. Describe the differences between the SQL INNER JOIN, LEFT JOIN, and RIGHT JOIN
operations. Provide an example for each
Ans INNER JOIN: Returns records that have matching values in both tables.
Example: SELECT * FROM Table1 INNER JOIN Table2 ON Table1.ID = Table2.ID;
LEFT JOIN: Returns all records from the left table (Table1), and the matched records from
the right table (Table2). Unmatched records from Table2 will contain NULL values.
Example: SELECT * FROM Table1 LEFT JOIN Table2 ON Table1.ID = Table2.ID;
RIGHT JOIN: Returns all records from the right table (Table2), and the matched records
from the left table (Table1). Unmatched records from Table1 will contain NULL values.
Example: SELECT * FROM Table1 RIGHT JOIN Table2 ON Table1.ID = Table2.ID;
Q8. You have a database table named "Orders" with columns "OrderID," "CustomerID," and
"OrderDate." Write an SQL query to retrieve the number of orders placed by each customer.
Ans SELECT
CustomerID, COUNT(OrderID) AS OrderCount
FROM
Orders
GROUP BY
CustomerID;
Q9. Describe the purpose of SQL indexes and their significance in database performance
optimization.
Ans SQL indexes are data structures that improve the speed of data retrieval by allowing the
database management system to locate specific rows more quickly, similar to the index in a
book. They enhance database performance by reducing the need for the database engine to
scan the entire table when searching for specific data.
Q10. You have a database table named "Students" with columns "StudentID," "FirstName,"
"LastName," and "Age." Write an SQL query to delete all students below the age of 18.
PAGE:76
Ans DELETE FROM Students WHERE Age < 18;
10 Short Knowledge/Understanding/Application Based Questions (4 Marks)
Q1. Consider the following table ACTIVITY and COACH and answer the following parts of this
question :Table : ACTIVITY
TABLE COACH
PAGE:77
1 Amit 2000 IT PGT
2 Sunit 1500 HISTORY TGT
3 Naina 1800 MATH PGT
Write the sql command for the following queries and answer the question
a. What is degree and Cardinality of the Table : Teacher
b. Identify the primary key in the table
c. Display the records of all PGT staff
d. Increase the salary of teachers of Math Department.
Ans a. Degree 5, Cardinality 3
b. b.TID
c. Select * from Teacher Where TDesig =PGT;
d. Update Teacher set salary= salary + salay *20/100 Where TDept=Math
Q4. Suppose your school management has decided to conduct cricket matches between
students of class XI and Class XII. Students of each class are asked to join any one of the
four teams — Team Titan, Team Rockers, Team Magnet and Team Hurricane. During
summer vacations, various matches will be conducted between these teams. Help your
sports teacher to do the following:
a) Create a database “Sports”.
b) Create a table “TEAM” with following considerations:
i) It should have a column TeamID for storing an integer value between 1 to 9,
which refers to unique identification of a team.
ii) Each TeamID should have its associated name (TeamName), which should be a
string of length not less than 10 characters
c. Using table level constraint, make TeamID as primary key
d. Show the structure of the table TEAM using SQL command.
Ans a.Create database Sports;
use Sports
b. create table team (teamidint(1), teamname varchar(10));
c. alter table team add primary key (teamid);
d. desc team;
Q5. Consider the following table STOCK and DEALERS and answer the following parts of this
question :
Table :STOCK
Item
No Item Dcode Qty UnitPrice StockDate
5005 Ball Pen 0.5 102 100 16 31-Mar-10
5003 Bal Pen 0.25 102 150 20 01-Jan-10
5002 Gel Pen Premium 101 125 14 14-Feb-10
5006 Gel Pen Classis 101 200 22 01-Jan-09
5001 Eraser Small 102 210 5 19-Mar-09
5004 Eraser Big 102 60 10 12-Dec-09
5009 Sharpener Classis 103 160 8 23-Jan-09
Table :DEALERS
Dcode Dname
101 Reliable Stationers
PAGE:78
103 Classis Plastics
102 Clear Deals
Give the output of the following SQL queries:
(i) SELECT COUNT(DISTINCT Dcode)
FROM STOCK;
(ii) SELECT QTY*UnitPrice FROM STOCK WHERE ItemNo=5006;
(iii) SELECT Item, Dname FROM STOCK S DEALERS D WHERE
S.Dcode=D.Dcode AND ItemNo=5004;
(iv) (iv) SELECT MIN(StockDate) FROM STOCK;
PAGE:79
5 Customer E Michael Lee Germany
Orders
OrderID CustomerID OrderDate TotalAmount
101 1 2023-01-15 500.00
102 2 2023-02-20 750.00
103 1 2023-03-10 300.00
104 3 2023-04-05 900.00
105 4 2023-05-15 600.00
(A) Write an SQL query to retrieve the names of customers (CustomerName) who have
placed orders.
(B) Write an SQL query to calculate the total amount of orders placed by each customer.
Display the customer's name (CustomerName) and the total order amount.
(C) Write an SQL query to find the customer (CustomerName) who placed the highest total
order amount and the corresponding total amount.
(D) Write an SQL query to retrieve the CustomerName and OrderDate for orders placed in
the year 2023.
Ans (A) SELECT DISTINCT c.CustomerName
FROM Customers c
INNER JOIN Orders o ON c.CustomerID = o.CustomerID;
PAGE:80
average salary.
(d) Write an SQL query to increase the salary of employees by 10% if their salary is less than
60000.
Ans (a) SELECT
E.FirstName, E.LastName, S.Salary
FROM
Employees E
JOIN Salaries S ON E.EmployeeID = S.EmployeeID;
(b) SELECT
AVG(Salary) AS AverageSalary
FROM
Salaries;
(c) SELECT
FirstName
FROM
Employees
WHERE
Salary > (SELECT AVG(Salary) FROM Salaries);
(d) UPDATE
Salaries
SET
Salary = Salary * 1.10
WHERE
Salary < 60000;
07 Case Based Questions (5 Marks)
Q1. A library uses database management system(DBMS) to store the details of the books that it
stocks, its registered members and the book-loan that the library has made. These details are
stored in a database using the following three relations. Name of the Database : KV Library
• Book (BookID : Char(5), Title : Varchar(25), Author :Varchar(25), Publisher : Varchar(100))
•Member(MemberID:Char(5), LastName:Varchar(25), FirstName:Varchar(25),
Correspondence-Address : Varchar(100), Pincode : Char(6), DateofBirth : Date, EmailID :
Varchar(50))
•Loan(MemberID: Char(5), BookID:Char(5), LastDate:Date, DueBackDate:Date, Returned
:Boolean)
Note : The Library does not stock more than one copy of the same book
(a) Identify following types of keys from all the relations of the given database Foreign
keys along with parent relations. 2
(b) Can a relation have multiple foreign keys? Give example. 1
(c) Can a foreign key be part of a primary key? Give example 1
(d) Write a SQL query to retrieve the names and email addresses of the 1members
belonging to KVS (they have email ids as _____@kvs.in) and have not returned their
books
Ans (a) (iii) Loan Table
(b) I. (i) Book : Title (ii) Member: EmailID
II. No, the Loan relation cannot have alternate key as its primary key is a composite key
having foreign key.
(c) INSERT INTO Loan Values(‘M1255’, ‘B3100’, ‘02/02/2020’, ‘09/02/2020’, False)
(d) Select FirstName, LastName, EmailID
PAGE:81
From Member, Loan
Where Member.MemberID=Loan.MemberID
AND Returned = ‘False’;
Q2. Rachana Mittal runs a beauty parlor. She uses a database management system(DBMS) to
store the information that she needs to manage her business. This information includes
customer contact details, staff names, the treatments that the parlor offer (for example, ‘’Hair
Massage’) and appointment that customers have made for treatments. A separate appointment
must be made for each treatment.
The details are stored in a database using the following four relations:
Customer: (CustomerID, FirstName, LastName, TelephoneNumber, EmailAddress)
Staff: (StaffID, FirstName,LastName, IsQualified) Treatment:
(TreatmentName,Price,TimeTaken,NeedsQualification) Appointment :
(CustomerID,TreatmentName,ApDate,ApTime)
• The IsQualified attribute for a member of staff stores one of the value True or False, to
indicate if the member of staff is fully qualified or not.
•The NeedsQualifiction attribute for a treatment stores True or False to indicate if the
treatment can only be given by a qualified member of staff.
•The TimeTaken attribute for a treatment is the number of minutes (a whole number) that the
treatment takes.
(a) Write a SQL statement to create the table staff.
(b) Write a query to Insert a record in the table Staff with following data ; (2009, ‘Sheril’,
‘Mark’, ‘True’)
(c) Which table’s records can be deleted without affecting any other table?
(i) Customer (ii) Staff (iii) Treatment (iv) Appointment
(d) Write a query to Modify table Appointment to add a new column StaffID, which should
hold a legal StaffID value from the staff table.
(e) Rachana wants to send e-mail advertisement to all the customers who had a ‘RF Facial’
treatment in 2020. To send the email, the customer’s email address, firstname and lastname
are needed.
Write a SQL query to retrieve the email address, firstname and lastname of each customer to
whom email should be sent.
Ans (a) Create Table Staff ( StaffID Number(4,0) NOT NULL PRIMARY KEY, FirstName
Varchar(20) NOT NULL, LastNameVarchar(20), ISQualifiedChar(4) Check (IsQualified
IN(‘True’, ‘False’)));
(b) INSERT INTO Staff Values(2009, ‘Sheril’, ‘Mark’, ‘True’);
(c) (ii) Staff table’s records can be deleted without affecting any other table as of now,
because this table is not linked with any other table yet.
(d) Alter Table Appointment Add StaffIDNumber(4,0) NOT NULL Reference Staff(StaffID);
(e) Select EmailAddress, FirstName,LastName From Customer C, Appointment A Where
C.CustomerID=A.CustomerID AND TreatmentName= ‘RF Facial’;
Q3. Online Store: You are managing an online store database with two tables: "Products" and
"Orders."
Products Orders
ProductID ProductName UnitPrice OrderID ProductID Quantity
1 Laptop 800 101 1 2
2 Smartphone 500 102 2 3
3 Tablet 350 103 1 1
PAGE:82
Question: Write SQL queries to perform the following tasks:
(a) Retrieve the total sales revenue for each product (sales = quantity * unit price).
(b) Find the product total sales revenue in highest to lowest order.
(c) Retrieve the product names that have not been ordered.
(d) Increase the unit price of all products by 10%. e. Delete the order with OrderID 102.
Performance
Month Rating
EmployeeID
1 Jan 4
2 Jan 5
1 Feb 5
2 Feb 4
PAGE:83
FROM Performance
WHERE Month IN ('Jan', 'Feb')
GROUP BY EmployeeID
HAVING MIN(Rating) >= 4;
Students Courses
StudentID FirstName LastName CourseID CourseName
1 Alice Smith 101 Math
2 Bob Johnson 102 History
3 Carol Davis 103 Science
PAGE:84
(e) DELETE FROM StudentsEnrollments
WHERE StudentID = 3 AND CourseID = 103;
Books Authors
BookID Title AuthorID Price AuthorID AuthorName
1 To Kill a Mockingbird 1 15.99 1 Harper Lee
2 1984 2 12.49 2 George Orwell
3 The Great Gatsby 3 10.99 3 F. Scott Fitzgerald
PAGE:85
Ans (a) SELECT Title, Price
FROM Books;
PAGE:86
Name of the chapter : Introduction to Emerging Trends
Topics Covered
• Artificial Intelligence, Machine Learning, Natural Language Processing,
Immersive experience(AR,VR),Robotics,Big data and its characteristics
• Internet of Things(IoT),Sensors,Smartcities,Cloud Computing and Cloud
Services(SaaS, IaaS,PaaS);Grid Computing,Block chain technology.
Key Points
Machine Learning
Machine learning is a branch of artificial intelligence that enables computers to learn from
data using statistical methods without explicit human programming. It includes algorithms
that use information to learn on their own and anticipate the future.
Sensors
Sensors are frequently used as monitoring and observing components. The development of
IoT is being greatly aided by the evolution of smart electronic sensors. It will result in the
development of fresh, intelligent systems with sensors.
smart city use the information and communication technologies (ICT), for creating,
implementing, and promoting sustainable development methods to handle the issues of
PAGE:87
expanding urbanization
Cloud Computing
Cloud computing is a new trend where computer-based services are supplied via the Internet
or the cloud and are accessible to the user from any location using any device. C
Grid Computing
Grid computing refers to a network of computers from various administrative domains
cooperating to complete a task. Grid computing enables simple completion of complicated
tasks that may be intractable for a single computer machine.
PAGE:88
D. Cloud Data
Ans B. Cloud Computing
Q6. What is the main goal of machine learning?
A. To enable computers to make decisions without human intervention
B. To replace human intelligence with artificial intelligence
C. To eliminate the need for data in computer systems
D. To make computers faster and more powerful
Ans A. Augmented Reality adds digital elements to the real world, while Virtual
Reality creates a fully simulated environment.
Q9. What is Artificial Intelligence (AI)?
A. A type of computer program
B. The ability of machines to perform tasks that typically require human
intelligence
C. A branch of computer hardware engineering
D. A form of virtual reality technology
Ans B. The ability of machines to perform tasks that typically require human
intelligence
Q10. Which of the following best defines the Internet of Things (IoT)?
A. A network of physical devices connected to the internet, capable of
collecting and exchanging data.
B. A virtual reality system for gaming and simulations.
C. A system of interconnected computer servers used for data storage.
D. A type of advanced computer programming language.
PAGE:89
• D. Limited accessibility to data and information
Ans B. Increased energy efficiency and resource conservation
(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: Cloud computing reduces the need for physical infrastructure and on-
premises hardware.
Reasoning: In cloud computing, resources are hosted and managed by cloud service
providers, eliminating the need for organizations to maintain their own physical
servers and hardware.
Ans (a) Both A and R are true and R is the correct explanation for A
Q2. Assertion: IoT devices are interconnected physical objects capable of collecting and
exchanging data over a network.
Reasoning: IoT enables devices to communicate and share information, leading to
increased automation and efficiency in various domains.
PAGE:90
Ans (a) Both A and R are true and R is the correct explanation for A .
Ans (a) Both A and R are true and R is the correct explanation for A
This statement is true. NLP is a field within AI that focuses on enabling computers to
process and understand human language, including tasks like language translation,
sentiment analysis, and chatbots.
Q4. Assertion: Public blockchains allow anyone to participate in the network and
validate transactions.
Reasoning: In public blockchains, nodes compete to validate transactions through a
process called mining.
Ans (a) Both A and R are true and R is the correct explanation for A
This statement is true. Public blockchains are open and permission less, allowing
anyone to join the network, validate transactions, and participate in consensus
mechanisms like Proof of Work (mining) to secure the network.
Q5. Assertion: Software as a Service (SaaS) delivers electricity over the internet on a
subscription basis.
Reasoning: SaaS applications are hosted and maintained by a service provider,
eliminating the need for users to install or manage the software locally.
PAGE:91
in manufacturing processes for tasks like welding, assembly, painting, and
packaging.
Q5. How does Grid Computing differ from other computing paradigms like Cluster
Computing or Cloud Computing?
Ans Cloud Computing: Cloud computing involves accessing computing resources (like
servers, storage, databases, networking, etc.) over the internet through a service
provider's infrastructure. It is highly scalable and provides on-demand access to
resources, while grid computing often involves a network of resources contributed by
multiple organizations or entities.
05 Short Knowledge/Understanding/Application Based Questions (3 Marks)
Q1. What are the three primary service models in cloud computing? Provide
examples for each.
Ans 1. Infrastructure as a Service (IaaS):
• Definition: IaaS provides virtualized computing resources over the
internet. Users can rent virtual machines, storage, and networking
resources on a pay-as-you-go basis.
• Example: Amazon Web Services (AWS) Elastic Compute Cloud
(EC2) provides virtual servers (instances) that users can rent to run
applications or host websites. Users have control over the operating
system, software, and network configuration.
2. Platform as a Service (PaaS):
• Definition: PaaS offers a platform that allows developers to build,
deploy, and manage applications without having to worry about the
underlying infrastructure. It provides a framework and environment
for application development.
• Example: Google App Engine allows developers to build, deploy, and
scale applications without managing the underlying infrastructure. It
supports various programming languages like Python, Java, and Go.
3. Software as a Service (SaaS):
• Definition: SaaS delivers software applications over the internet on a
subscription basis. Users can access these applications through a web
browser, without needing to install or maintain them on their local
devices.
• Example: Salesforce is a customer relationship management (CRM)
PAGE:92
platform delivered as a SaaS. Users can access Salesforce through a
web browser to manage customer relationships, sales pipelines, and
more.
Q2. Provide three real-world applications where AI is currently being utilized and
briefly describe how it benefits those applications.
Ans Any three valid examples.
Q3. What is Augmented Reality (AR) and how does it differ from Virtual Reality
(VR)?
Ans • Augmented Reality (AR): AR is a technology that overlays digital
information, such as images, sounds, or text, onto the real world. This can be
done through devices like smartphones, tablets, or AR headsets. AR enhances
the user's perception of the real world by adding virtual elements.
• Virtual Reality (VR): VR immerses users in a completely virtual
environment. It typically involves the use of a VR headset that completely
covers the user's field of vision, replacing the real world with a computer-
generated environment. VR aims to create a sense of presence, making the
user feel like they are physically present in a different world.
Q4. What is Cloud Computing and how does it differ from traditional computing?
Ans Cloud Computing: Cloud computing refers to the delivery of computing services
(such as storage, processing, networking, databases, etc.) over the internet. It allows
users to access and use resources hosted on remote servers, which are maintained and
managed by a cloud service provider.
Difference from Traditional Computing: In traditional computing, applications and
data are stored and processed on local computers or on-premises servers. In contrast,
cloud computing offloads these tasks to remote servers, providing scalability,
accessibility, and cost-efficiency benefits.
PAGE:93
and prevent unauthorized alterations.
Q2. Discuss one potential challenge or limitation in the field of AI and propose a
possible solution to address it.
Ans One potential challenge in the field of AI is the issue of bias and fairness. When these
biases are not addressed, AI models can perpetuate and even amplify existing social,
cultural, or economic inequalities. This can result in discriminatory outcomes,
particularly in sensitive areas like hiring, lending, or criminal justice.
Proposed Solution:
1. Diverse and Representative Training Data:
2. Bias Detection and Mitigation:
3. Transparent and Explainable Models:
4. Diverse Development Teams:
5. Ongoing Monitoring and Evaluation:
6. User Feedback and Accountability:
7. Regulations and Standards:
PAGE:94
Q5. What is a blockchain and how does it ensure security and transparency in transactions?
Provide an example scenario.
Ans Blockchain Definition:
Security and Transparency:
1. Cryptography: Transactions are secured using cryptographic techniques. Each
transaction is verified and recorded in a way that makes it extremely difficult to alter
or forge.
2. Decentralization: The ledger is maintained by a network of nodes (computers)
rather than a central authority. This decentralization reduces the risk of a single point
of failure or malicious attack.
3. Consensus Mechanisms: Blockchain networks use consensus algorithms (e.g.,
Proof of Work, Proof of Stake) to validate and agree on the state of the ledger. This
ensures that all nodes agree on the validity of transactions.
Example Scenario: Consider a scenario where Alice wants to send 5 Bitcoins to Bob using a
blockchain-based cryptocurrency. When Alice initiates the transaction, it is broadcasted to
the network. Miners validate the transaction using cryptographic algorithms, and once
verified, the transaction is grouped with others into a block.
This block is then added to the blockchain, creating a permanent record of the transaction.
The ledger is updated across all nodes in the network, providing transparency. If anyone
attempts to alter the transaction, it would require the consensus of a majority of nodes,
making it computationally infeasible.
Q1. ABC Corporation implemented an AI-powered chatbot to enhance their customer service
experience. The chatbot uses Natural Language Processing (NLP) to understand customer
queries and provide relevant responses. It is designed to handle common inquiries, such as
order status, product information, and troubleshooting.
Question 1: What technology does the chatbot in this case study primarily rely on?
A) Machine Learning
B) Natural Language Processing (NLP)
C) Computer Vision
D) Neural Networks
Question 2: What is the main purpose of implementing the chatbot?
A) Enhance customer service
B) Streamline internal communication
C) Monitor employee performance
D) Improve product development
Question 3: What type of inquiries is the chatbot designed to handle?
A) Technical support only
B) Common inquiries
C) Legal inquiries
D) Marketing inquiries
Question 4: How does the chatbot understand and respond to customer queries?
A) Through complex algorithms
B) By analyzing facial expressions
C) Using Natural Language Processing (NLP)
D) By accessing external databases
Question 5: What is one potential benefit of using a chatbot in customer service?
A) Decreased customer satisfaction
B) Reduced response time
PAGE:95
C) Limited scalability
D) Increased manual workload
Q2. ABC Web Services, a web hosting company, transitioned their hosting infrastructure
to the cloud. They chose a cloud provider known for its reliability and scalability.
This allows ABC Web Services to easily handle fluctuations in website traffic and
provide a seamless experience for their clients.
MCQ Questions:
Question 1: Why did ABC Web Services transition their hosting infrastructure to the
cloud?
A) To reduce website traffic
B) To handle fluctuations in website traffic and provide scalability
C) To limit their hosting options
D) To decrease reliability
Question 2: What is one benefit of using a reliable cloud provider for web hosting?
A) Limited scalability options
B) Reduced accessibility
C) Ability to handle fluctuations in website traffic
D) Decreased security
Question 3: How does cloud hosting help ABC Web Services with scalability?
A) It restricts website traffic
B) It allows for easy adjustment of resources based on demand
C) It limits the number of websites hosted
D) It does not affect scalability
Question 4: What is one potential benefit of using cloud hosting for web services?
A) Limited control over resources
B) Inability to handle fluctuations in traffic
C) Improved website performance and reliability
D) Higher costs compared to traditional hosting
Question 5: What is one consideration ABC Web Services should have regarding
data security when using cloud hosting?
A) No need to worry about data security
B) Ensuring proper security measures and encryption are in place
C) Ignoring data security concerns
D) Reliance solely on the cloud provider for security
Ans Solution 1: B) To handle fluctuations in website traffic and provide scalability
Solution 2: C) Ability to handle fluctuations in website traffic
Solution 3: B) It allows for easy adjustment of resources based on demand
Solution 4: C) Improved website performance and reliability
Solution 5: B) Ensuring proper security measures and encryption are in place
Q3. ABC Corporation, a global food distributor, implemented a blockchain-based supply chain
solution. The system tracks the journey of food products from the farm to the consumer's
table. Each step of the process, including harvesting, processing, packaging, and
transportation, is recorded on the blockchain. This provides consumers with transparent and
verifiable information about the origin and handling of the food they consume.
PAGE:96
MCQ Questions:
PAGE:97
C) Reduced interaction with store staff
D) Decreased product variety
Question 4: What is one potential advantage for ABC Retail in implementing AR?
A) Decreased customer engagement
B) Enhanced customer experience and increased conversion rates
C) Reduced use of technology
D) Limited customer interaction
Question 5: What type of technology is primarily used in this case study?
A) Virtual Reality (VR)
B) Augmented Reality (AR)
C) Mixed Reality (MR)
D) Artificial Intelligence (AI)
Ans Solution 1: B) Virtual try-on of clothes
Solution 2: B) By superimposing virtual clothing onto the customer's live video feed
Solution 3: B) Ability to virtually try on clothes before purchasing
Solution 4: B) Enhanced customer experience and increased conversion rates
Solution 5: B) Augmented Reality (AR)
Q5. XYZ Consulting, a small business, decided to migrate their data storage to the cloud. They
opted for a popular cloud storage service that offers secure, scalable, and cost-effective
storage solutions. The cloud storage allows XYZ Consulting to access their files from
anywhere with an internet connection and enables easy collaboration among team members.
MCQ Questions:
Question 1: What is one benefit of using cloud storage for XYZ Consulting?
A) Limited access to files
B) Scalable and cost-effective storage
C) Restricted collaboration options
D) Dependence on physical hardware
Question 2: Why did XYZ Consulting choose to migrate their data storage to the cloud?
A) To decrease accessibility
B) To limit collaboration
C) To access files from anywhere with an internet connection
D) To increase dependence on physical hardware
Question 3: What is a key advantage of using a cloud storage service?
A) Decreased security
B) Limited storage capacity
C) Easy collaboration among team members
D) Higher costs compared to physical storage
Question 4: How does cloud storage benefit XYZ Consulting in terms of scalability?
A) It provides limited storage options
B) It allows for easy expansion of storage capacity as needed
C) It restricts access to files
D) It does not affect storage capacity
Question 5: What is one potential risk of relying solely on cloud storage?
A) Limited accessibility to files
B) Dependency on physical hardware
C) Data security concerns
D) Difficulty in collaboration
Ans Solution 1: B) Scalable and cost-effective storage
Solution 2: C) To access files from anywhere with an internet connection
Solution 3: C) Easy collaboration among team members
Solution 4: B) It allows for easy expansion of storage capacity as needed
Solution 5: C) Data security concerns
PAGE:98