0% found this document useful (0 votes)
700 views146 pages

c11 Ip SSM Final 2025 - 26

The document outlines the objectives and framework for achieving excellence in school education through the Central Board of Secondary Education, emphasizing the integration of skill development and innovative teaching methods. It introduces student support materials for Informatics Practices for Class XI, detailing the syllabus, learning outcomes, and practical exercises to enhance students' understanding of computer systems and programming. The materials aim to assist students in achieving their academic goals while adhering to national educational standards.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
700 views146 pages

c11 Ip SSM Final 2025 - 26

The document outlines the objectives and framework for achieving excellence in school education through the Central Board of Secondary Education, emphasizing the integration of skill development and innovative teaching methods. It introduces student support materials for Informatics Practices for Class XI, detailing the syllabus, learning outcomes, and practical exercises to enhance students' understanding of computer systems and programming. The materials aim to assist students in achieving their academic goals while adhering to national educational standards.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 146

संदेश

विद्यालयी वशक्षा में शैवक्षक उत्कृष्टता प्राप्त करना एिं निाचार द्वारा उच्च – निीन मानक
स्थावित करना केन्द्रीय विद्यालय सं गठन की वनयवमत कायय प्रणाली का अविभाज्य अंग है ।
राष्टरीय वशक्षा नीवत 2020 एिं िी. एम. श्री विद्यालय ं के वनदे श ं का िालन करते हुए
गवतविवि आिाररत िठन-िाठन, अनुभिजन्य वशक्षण एिं कौशल विकास क समावहत कर,
अिने विद्यालय ं क हमने ज्ञान एिं ख ज की अद् भुत प्रय गशाला बना वदया है । माध्यवमक
स्तर तक िहुुँ च कर हमारे विद्याथी सैद्ां वतक समझ के साथ-साथ, रचनात्मक – विशे षणात्मक
एिं आल चनात्मक वचंतन भी विकवसत कर ले ते हैं । यही कारण है वक िह ब र्य कक्षाओं के
दौरान विवभन्न प्रकार के मूल्ां कन ं के वलए सहजता से तैयार रहते हैं । उनकी इस यात्रा में
हमारा सतत य गदान एिं सहय ग आिश्यक है - केन्द्रीय विद्यालय सं गठन के िां च ं आं चवलक
वशक्षा एिं प्रवशक्षण संस्थान द्वारा सं कवलत यह विद्याथी सहायक- सामग्री इसी वदशा में एक
आिश्यक कदम है । यह सहायक सामाग्री कक्षा 9 से 12 के विद्यावथयय ं के वलए सभी
महत्विूणय विषय ं िर तैयार की गयी है । केन्द्रीय विद्यालय सं गठन की विद्याथी सहायक-
सामग्री अिनी गु णित्ता एिं िरीक्षा संबंिी - सामग्री संकलन की विशेषज्ञता के वलए जानी जाती
है और वशक्षा से जुड़े विवभन्न मंच ं िर इसकी सराहना ह ती रही है। मुझे विश्वास है वक यह
सहायक सामग्री विद्यावथय य ं की सहय गी बनकर वनरं तर मागयदशयन करते हुए उन्हें सफलता के
लक्ष्य तक िहुुँ चाएगी।

शुभाकां क्षा सवहत ।

निनि प ांडे

आयुक्त, केन्द्रीय निद्य लय सांगठि


STUDENT SUPPORT MATERIAL, INFORMATICS PRACTICES CLASS XI

PATRON

Smt. Nidhi Pandey, Commissioner, KVS


CO-PATRON

Dr. P. Devakumar, Additional Commissioner (Acad.), KVS (HQ)


CO-ORDINATOR

Ms. Chandana Mandal, Joint Commissioner (Training), KVS (HQ)


COVER DESION

KVS Publication Section

EDITORS:

1. Ms. Shahida Parveen, Director, ZIET Mumbai


2. Mr. B L Morodia, Director, ZIET Gwalior
3. Ms. Menaxi Jain, Director, ZIET Mysuru
4. Ms. Preeti Saxena, In-charge Director, ZIET Chandigarh
5. Mr. Birbal Dhinwa, In-charge Director, ZIET Bhubaneswar

MRS. SHAHIDA PARVEEN, DIRECTOR, ZIET MUMBAI


MRS. SONIA JAIN, PRINCIPAL, PM SHRI KV NO. 1 DEVLALI (MUMBAI REGION)
CONTENT DEVELOPMENT TEAM
SL NAME OF TEACHER NAME OF KV REGION

1 MS DEEPIKA SHENDE PM SHRI KV NO 3 COLABA MUMBAI

2 MR NITIN KUMAR JAIN PM SHRI KV AURANGABAD MUMBAI

3 MRS SAVITA SHARMA PM SHRI KV INS HAMLA MUMBAI

4 MRS REKHA CHAUDHARY PM SHRI KV KANNUR ERNAKULAM

5 MRS ASWATHI V PM SHRI KV THRISSUR ERNAKULAM

6 MRS ROSHNI M PM SHRI KV MANKHURD MUMBAI

7 MRS SHRUTI SRIVASTAVA KV ONGC PANVEL MUMBAI

8 MRS POOJA AGARWAL PM SHRI KV NO 1 NRC NASIK MUMBAI

9 MR JIMMY JOHN PM SHRI KV OTTAPALAM ERNAKULAM

MRS MANJU N PM SHRI KV SAP


10 ERNAKULAM
THIRUVANANTHAPURAM

CO-ORDINATOR CONTENT VETTING TEAM

1 MRS. SHIKHA SHAMBHARKAR PM SHRI KV AJNI NAGPUR MUMBAI

CONTENT VETTING TEAM

1 MR. GULSHAN KUMAR HANS PM SHRI KV SCR NANDED MUMBAI

2 MRS. SHREELEKHA PATTAYAT PM SHRI KV AFS THANE MUMBAI


INFORMATICS PRACTICES
Subject Code - 065 Class XI (2025-26)
CONTENTS

S NO TOPIC
1 SYLLABUS
2 Unit -1 Introduction to Computer System
• Introduction to Computer and computing
• Computer Memory
• Software and types of software
3 Unit-2 Introduction to Python
➢ Basics of Python programming
➢ Statements, Control Statements
➢ Lists
➢ Dictionary
➢ Introduction to NumPy
4 Unit 3: Database concepts and the Structured Query Language
➢ Database Concept and types of SQL Command
➢ Data Query Language
5 Unit 4: Introduction to the Emerging Trends
6 Solved Question Papers (Two)
7 Unsolved Questions Papers (Three)

1. Prerequisite. None
2. Learning Outcomes At the end of this course, students will be able to:
● Identify the components of computer system.
● Create Python programs using different data types, lists and dictionaries.
● Understand database concepts and Relational Database Management Systems.
● Retrieve and manipulate data in RDBMS using Structured Query Language
● Identify the Emerging trends in the fields of Information Technology.
3. Distribution of Marks:
Unit No. Unit Name Marks
1 Introduction to Computer System 10
2 Introduction to Python 25
3 Database Concepts and the Structured Query 30
Language
4 Introduction to Emerging Trends 5
Practical 30
Total 100

1|Page
Unit Wise syllabus:
Unit 1: Introduction to Computer System
Introduction to computer and computing: evolution of computing devices, components of a
computer system and their interconnections, Input/output devices.
Computer Memory: Units of memory, types of memory – primary and secondary, data
deletion, its recovery and related security concerns.
Software: purpose and types – system and application software, generic and specific purpose
software.

Unit 2: Introduction to Python


Basics of Python programming, execution modes: - interactive and script mode, the
structure of a program, indentation, identifiers, keywords, constants, variables, types of
operator, precedence of operators, data types, mutable and immutable data types, statements:
expression evaluation, comments, input and output statements, data type conversion,
debugging.
Control Statements: if-else, if-elif-else, while loop, for loop
Lists: list operations - creating, initializing, traversing and manipulating lists, list methods and
built-in functions – len(), list(), append(), insert(), count(), index(), remove(), pop(), reverse(),
sort(), min(), max(), sum()
Dictionary: concept of key-value pair, creating, initializing, traversing, updating and deleting
elements, dictionary methods and built-in functions – dict(), len(), keys(), values(), items(),
update(), del(), clear()
Introduction to NumPy: Introduction, Creation of NumPy Arrays from List

Unit 3: Database concepts and the Structured Query Language


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 database using
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

Unit 4: Introduction to the Emerging Trends


Artificial Intelligence, Machine Learning, Natural Language Processing, Immersive experience
(AR, VR), Robotics, Big data and its characteristics, Internet of Things (IoT), Sensors, Smart
cities, Cloud Computing and Cloud Services (SaaS, IaaS, PaaS); Grid Computing, Block chain
technology.

2|Page
Practical Marks Distribution

Sr. No. Unit Name Marks


1 Problem solving using Python programming 11
language
2 Creating database using MySQL and performing 7
Queries
3 Practical file (minimum of 14 python programs, 7
and 14 SQL queries)
4 Viva-Voce 5
Total 30

5. Suggested Practical List


5.1 Programming in Python
1. To find average and grade for given marks.
2. To find sale price of an item with given cost and discount (%).
3. To calculate perimeter/circumference and area of shapes such as triangle, rectangle,
square and circle.
4. To calculate Simple and Compound interest.
5. To calculate profit-loss for given Cost and Sell Price.
6. To calculate EMI for Amount, Period and Interest.
7. To calculate tax - GST / Income Tax.
8. To find the largest and smallest numbers in a list.
9. To find the third largest/smallest number in a list.
10. To find the sum of squares of the first 100 natural numbers.
11. To print the first ‘n’ multiples of given number.
12. To count the number of vowels in user entered string.
13. To print the words starting with an alphabet in a user entered string.
14. To print number of occurrences of a given alphabet in each string.
15. Create a dictionary to store names of states and their capitals.
16. Create a dictionary of students to store names and marks obtained in 5 subjects.
17. To print the highest and lowest values in the dictionary.

5.2 Data Management: SQL Commands


1. To create a database
2. To create student table with the student id, class, section, gender, name, dob, and
marks as attributes where the student id is the primary key.
3. To insert the details of at least 10 students in the above table.
4. To display the entire content of table.
5. To display Rno, Name and Marks of those students who are scoring marks more than
50.
6. To display Rno, Name, DOB of those students who are born between ‘2005- 01-01’
and ‘2005-12-31’.

Suggested material
NCERT Informatics Practices - Text book for class - XI (ISBN- 978-93-5292-148-5)

3|Page
Unit 1: Introduction to Computer System

Mind Map

1. Introduction to Computers & Computing


● Definition: A computer is an electronic device that processes input data and provides
the output based on the input data.
2. Evolution of Computing Devices
Generations Technology used Memory Type and Programming I/O Devices
of computer Storage Language
First Generation Vacuum Tubes Magnetic Drums Machine Language Punch Card
Magnetic tape
Second Generation Transistors Magnetic Tape Machine Language Typewriters
and Assembly attach to control
Language panel, punch
cards
Third Generation Integrated Circuits Hard Disk, Floppy High Level Language Keyboard,
Disk, Magnetic developed Printer
Core, RAM
Fourth Generation Microprocessors and Hard Disk, Floppy High Level Language Keyboard,
Very Large-Scale Disk, CD, DVD mouse, Printers,
Integrated circuits Plotter, Speaker
Fifth Generation Parallel Processing Hard Disk, DVD, High Level Language, Keyboard,
and Super Flash Memory, Cloud Based mouse, Printers,
Conductors Cloud Storage Programming Plotter, Speaker

4|Page
3. Components of a computer system:
● Components: The hardware includes the CPU, memory, input/output devices, and
storage.

● CPU: The "brain" of the computer, consisting of:


o ALU (Arithmetic and Logical Unit): Performs arithmetic & logical operations.
o Control Unit: Manages instruction execution.
o Registers: Used to access data and instructions from memory during of the
execution of instructions.
● Input Devices: An input device or hardware that allow the user to input data,
instructions to the computer. Some common input devices are keyboard, mouse,
scanner, webcam, barcode reader etc.
● Output Devices: An output device or hardware that retrieves and presents the
result/information on the basis of input data in human understandable language. Some
Common output devices are Monitor, printer, speakers, plotter etc.
4. Computer Memory
It is used to store data / information temporarily or permanently.
● Units: From bit (smallest) to Yottabyte (largest).
bit->Nibble(4 bit)->Byte(8 bit)->KB->MB->GB->TB->PB-> EB->ZB->YB

● Types of memory:
Primary Memory:
RAM (Volatile) – Random Access Memory stores data temporarily.
▪ It is a volatile memory that means it lose the data when power is turned off.
▪ A computer can't operate/run without primary memory.
▪ It is faster than secondary storage memory.
▪ Types of RAM (SRAM, DRAM)

ROM (Non-volatile) – it retains its information even when the power is turned
off. It stores the boot-up instructions and it is primarily used for a computer to

5|Page
start. Instructions in the ROM written by the Programmer and it is called as
firmware and BIOS.
Firmware is software that provides basic machine instructions
Types of ROM:
• PROM Programmable Read Only Memory
• EPROM Erasable Programmable Read Only Memory
• EEPROM Electronic Erasable Read Only Memory

Cache Memory:
Cache memory is a high-speed memory located inside or very close to the CPU. It
stores the most frequently used data and instructions, allowing the CPU to access
them more quickly than if it had to fetch them from RAM.
→Cache is much faster than RAM but also more expensive and has a smaller storage
capacity.
→It helps in reducing the time taken to access data, thereby improving the overall
performance of the computer.
o High-speed temporary storage between CPU & RAM.

Secondary Memory:
Secondary memory is used for the permanent storage of data, files, software, and the
operating system. it is non-volatile Memory meaning data is not lost when the computer
is turned off.
➤ Characteristics of Secondary Memory:
• It is not directly accessible by the CPU; data must be loaded into primary memory
(RAM) before processing.
• It has large storage capacity compared to primary memory.
• It is slower than primary memory, but suitable for long-term data retention.
➤ Examples of Secondary Storage Devices:
Hard Disk Drive (HDD), Solid State Drive (SSD), Optical Disks (CD/DVD), Flash Drives
(Pen Drive, Memory Cards/SD Cards)

5. Data deletion, its recovery and related security concerns


Data deletion is related to the loss of data, removal of data from a storage device either
intentionally or accidentally. Data is also lost due to virus/ bad sectors/ by hackers.
Data recovery is related to the recovery of lost data with the help of data recovery
software.
Data Security: It is very important for the user to implement the Data security
concerns before working on computer because it helps a user to prevent unauthorized
access and loss of data.
Some Security measures are (1) install antivirus software (2) Don’t allow
unauthorized access of data (3) Try not to use public network. (4) apply strong login
password

6|Page
6. Software:
Software is a collection of programs that enables hardware to function. It governs the
operations of a computer system and is used for various purposes.
There are three types of software:
A. System Software: It act as an interface between user and hardware. System software is
a type of software that controls and manages the hardware components of a computer
and helps to install or run application software.
a) Operating System (OS):
• Acts as an interface between user and hardware.
• Manages files, memory, processes, and devices.
• Examples: Windows, Linux, macOS, Android
b) System Utilities:
• Programs that perform maintenance and support tasks.
• Examples: Antivirus, Disk Cleanup, File Compression Tools (WinZip)
c) Device Drivers:
• Specialized software that allows the OS to communicate with hardware devices.
• Each device (printer, keyboard, etc.) needs its own driver.
• Example: Printer Driver, Graphics Driver

B. Programming Tools and Language Translators


Used by programmers to write, convert, and debug programs written in high- level or
low-level programming languages.
a) Assembler b) Compiler c) Interpreter
Translates assembly Converts the entire source Translates code into
language into machine code (high-level language) machine language one line
code. into machine code at once. at a time and execute it.
One-to-one conversion. Fast execution after Slower than a compiler.
compilation.
Used in low-level Language Used in High-level Language Used in High-level
programming. Programming Language Programming
Example: Assembly Example: C, C++ compilers Example: Python,
Language JavaScript interpreter
C. Application Software
Application software is designed to help users to perform specific tasks or activities.
Types:
• General-purpose software – used by most users.
o Examples: MS Office, databases, email clients.
• Special-purpose software – Custom-built for organizations and developed for a
specific task.
o Examples: Billing Software, Library Management System, Railway reservation
software.
Multiple Choice Questions
1 You are explaining computers to someone from a non-technical background. How would
you classify a computer based on its functioning?
a) Mechanical b) Electrical c) Electronic d) Telecommunication
2 The physical components of the computer are known as:

7|Page
a) Software b) Program c) Hardware d) Both a) and c
3 Which of the following is not a component of computer system?
a) Processor b) MS Office c) Motherboard d) Keyboard
4 The full form of ALU is:
a) Abacus Logarithmic Unit b) Arithmetic and Logical Unit
c) Abacus Language Unit d) Arithmetic and Language Unit
5 While troubleshooting a computer system, a technician explains that both logical
decisions and arithmetic operations are being handled simultaneously. Which component
is responsible for this task?
a) Control Unit b) Memory Unit c) Arithmetic Logic Unit d) Input Unit
6 Arrange the following in increasing order of the number of transistors on a single chip:
i) SLSI , ii) IC , iii) VLSI , iv) LSI
a) ii) IC → iv) LSI → iii) VLSI → i) SLSI
b) ii) IC → iii) VLSI → iv) LSI → i) SLSI
c) iv) LSI → ii) IC → iii) VLSI → i) SLSI
d) i) SLSI → ii) IC → iii) VLSI → iv) LSI
7 Which of the following is the fastest memory?
a) RAM b) Cache c) ROM d) Hard Disk
8 Which two digits does the binary number system consist of?
a) 1, 2 b) 0, 1 c) a, b d) i, ii
9 Which of the following is a volatile memory?
a) RAM b) CD c) ROM d) Hard Disk
10 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 → iii) MB → i) KB
b) ii) GB → iv) TB → i) KB → iii) MB
c) iv) TB → iii) MB → i) KB → ii) GB
d) iv) TB → ii) GB → i) KB → iii) MB

11 Which of the following is NOT an input device?


a) Scanner b) Speakers c) Webcam d) Joystick
12 A ______ is an electronic pathway composed of cables that connects the major parts of a
computer system.
a) Motherboard b) Processor c) Bus d) Cache

Answer (Multiple Choice Questions)


1 (c) Electronic
2 (c) Hardware
3 (b) MS Office
4 (b) Arithmetic Logic Unit

8|Page
5 (c) Arithmetic Logic Unit
6 (a) ii) IC → iv) LSI → iii) VLSI → i) SLSI
7 (b) Cache
8 (b) 0, 1
9 (a) RAM
10 (a) iv) TB → ii) GB → iii) MB → i) KB
11 (b) Speakers
12 (c) Bus

Assertion and Reasoning Questions


Choose correct option for given Assertion (A) and Reasoning (R)
a) Both A and R are true, and R is the correct explanation of A.
b) Both A and R are true, but R is NOT the correct explanation of A.
c) A is true, but R is false. d) A is false, but R is true.
1 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.
2 Assertion (A): Main/Primary memory is volatile.
Reason (R): ROM, which is a part of main memory, is non-volatile
3 Assertion (A): It is always good to keep passwords encrypted while storing.
Reason (R): Encrypted data cannot be easily stolen by hackers.
4 Assertion (A): RAM (Random Access Memory) is volatile memory.
Reason (R): RAM retains its data even when the computer is powered off.
5 Assertion (A): Software designed for a school will work only for the school admin.
Reason (R): Customized software is tailor-made according to user requirements
6 Assertion (A): Cache memory is faster than RAM.
Reason (R): Cache memory is placed between the processor and RAM to reduce the
access time.
7 Assertion (A): A hard disk is a type of volatile memory.
Reason (R): Hard disks store data permanently even when the power is turned off.
8 Assertion (A): ROM (Read-Only Memory) is used to store data that does not change
frequently.
Reason (R): ROM is volatile memory and loses data when the power is turned off.
9 Assertion (A): An operating system is an example of system software.
Reason (R): An operating system provides an interface between hardware and software
applications.
10 Assertion (A): A scanner is an example of an output device.
Reason (R): A scanner converts physical documents into a digital format, which is then
displayed on the computer

9|Page
Answer (Assertion and Reasoning Questions)

1 (a) Both A and R are true, and R is the correct explanation of A


2 (b) Both A and R are true, but R is NOT the correct explanation of A.
3 (a) Both A and R are true, and R is the correct explanation of A
4 (c) A is true, but R is false.
5 (d) A is false, but R is true.
6 (a) Both A and R are true, and R is the correct explanation of A.
7 (d) A is false, but R is true.
8 (c) A is true, but R is false.
9 (a) Both A and R are true, and R is the correct explanation of A.
10 (d) A is false, but R is true.

Very Short Questions with Answers


1 Explain the role of an ALU in processing operations within a CPU.
Answer: The ALU (Arithmetic Logic Unit) performs arithmetic operations like addition
and subtraction, and logical operations such as comparisons, essential for processing
instructions.
2 Identify the type of memory that loses data when power is turned off and justify its use.
Answer: RAM (Random Access Memory) is volatile; it temporarily holds data and
instructions that the CPU is actively using for faster access.
3 Explain the use of utility software by naming one and describing its function.
1. Answer: Antivirus software like Windows Defender scans and removes malware,
ensuring system security and performance.
4 Earlier the computer size is used to be very big, but now it is very compact. What do you
think the reason behind its change?
Answer: Earlier the Computers were made with Vacuum Tubes, so the size of computers
were very big. But now a days VLSI (Very Large-Scale Integration) circuit chips are used
in computer, due to this invention computers are very compact in size.
Vacuum Tubes-> Transistors-> ICs -> LSI->VLSI

Remember:
ICs : Integrated Circuit Chips
LSI: Large Scale Integrated Circuit Chips
VLSI: Very Large Scale Integrated Circuit Chips
5 Relate any early computing machine to today’s computer systems in terms of design
similarity.
Answer: EDVAC is considered similar to modern computers as it used the stored-
program concept, influencing current CPU architecture.

10 | P a g e
6 Write the use of printer based on its function in a computer system.
Answer: A printer is an output device because it produces hard copies of digital
documents.
72. Differentiate between an operating system used in mobile devices and one used in
computers.
Answer: Android is a mobile OS designed for touchscreen interfaces, while Windows is a
computer OS supporting multitasking on desktops and laptops.
8 Explain the impact of John von Neumann's concept on modern computing.
Answer: He introduced the stored-program concept, enabling programs to be stored in
memory, forming the foundation of modern computer architecture.
9 Discuss how the Control Unit contributes to the execution of instructions within the CPU.
Answer: The Control Unit (CU) directs the operation of the processor by fetching,
decoding, and coordinating instruction execution.
10 Justify the importance of USB in modern computing environments.
Answer: USB (Universal Serial Bus) standardizes connections for data transfer and
peripheral communication, enhancing device compatibility and ease of use.
11 Provide an example of an optical storage medium and explain its use.
Answer: A CD (Compact Disc)/DVD is a Secondary Storage device that is used to store
data like music, videos, or software and is read by an optical drive(CD/DVD Drive)
12 Explain why a bit is considered the smallest unit of memory in a computer system
Answer: A bit (binary digit) represents the most basic unit of data, holding a value of
either 0 or 1, forming the basis for all computing processes.
13 Demonstrate how an operating system facilitates interaction between hardware and
users.
Answer: The operating system manages hardware resources like CPU and memory, and
provides a user interface for interaction with applications.

Short Questions with Answer


1 Define cache memory and its importance.
Answer:
Cache memory is a small, high-speed memory that stores frequently accessed data to
speed up processing. It reduces access time to the main memory.
2 Give any two approaches to recover accidental file deletion.
Answer:
● Enable the Recycle Bin feature to temporarily store deleted files.
● Maintain regular backups of important data.
3 Differentiate between primary memory and secondary memory.
Answer:
● Primary memory (RAM, ROM): Fast, volatile, used for immediate data processing.
● Secondary memory (HDD, SSD): Slower, non-volatile, used for long-term storage.

11 | P a g e
4 List out four differences between RAM and a Hard Disk.
Answer:
● RAM is volatile; a Hard Disk is non-volatile.
● RAM is faster; Hard Disks are slower.
● RAM stores data temporarily, while the Hard Disk stores data permanently.
● RAM has less storage capacity, while Hard Disks have a large storage capacity
5 Give two reasons for data deletion. How can data deletion by unauthorized persons be
prevented?
Answer:
● Reasons: Accidental deletion, malware attacks
● Prevention: Use strong passwords and allow authorized user to work on the
computer or digital device.
6 Give two differences between a compiler and an interpreter.
Answer:
● A compiler translates the whole program at once; an interpreter translates line by
line.
● A compiler is faster for execution; an interpreter is slower.

7 What is a language translator?


Answer:
● A language translator is software that converts high-level programming language
code into machine language (binary). Examples: Compiler, Interpreter, Assembler.
8 Name and explain any two types of software.
Answer:
● System Software: Manages hardware and system operations (e.g., Operating
System).
● Application Software: Designed for user tasks (e.g., Microsoft Word).

9 What is firmware? Give an example.


Answer:
● Firmware is a type of software embedded into hardware devices to control their
functions. Example: BIOS (Basic Input Output System).
10 What do you mean by customized software?
Answer:
● Customized software is tailor-made software designed for a specific user or
organization to meet their unique requirements.

Long Questions with Answer


Q1. Draw the block diagram of a computer system and explain each part briefly.

12 | P a g e
Answer:
Explanation of Each Component:
● Input Unit:
Devices like a keyboard, mouse, scanner, and microphone are used to provide
o
data and instructions to the computer.
● Central Processing Unit (CPU):

Also called the brain of the computer, it processes instructions and controls
o
system operations.
o Control Unit (CU): Directs the operations of the processor.
o Arithmetic Logic Unit (ALU): Performs mathematical calculations and logical
operations.
● Memory Unit:

o RAM (Random Access Memory): Volatile memory that stores data and
instructions temporarily.
o ROM (Read-Only Memory): Non-volatile memory that stores firmware and
essential booting instructions.

● Output Unit:
Devices like a monitor, printer, and speakers that display or present the
o
processed data.
● Storage Unit (Secondary Storage):

o Includes Hard Disk Drives (HDD), Solid State Drives (SSD), CDs, DVDs, and USB
drives to store data permanently.

Q2. What is hardware? What type of software is required to run hardware devices? Give one
example.
Answer:
● Hardware:
o Hardware refers to the physical components of a computer system, including
input devices, output devices, memory, and the processor.

13 | P a g e
Examples: Keyboard, Mouse, Monitor, Hard Disk, Printer.
o
● Software Required to Run Hardware Devices:
o Device Drivers: These are specialized programs that allow the operating system
to communicate with hardware components.
o Example: A printer driver is required to make the printer function correctly with
a computer.

Q3. Name the memory that is fastest in a computer system. What is the role of such memory,
and where is it placed?
Answer:
● Fastest Memory: Cache Memory
● Role of Cache Memory:
o Cache memory stores frequently used data and instructions close to the CPU.
o It reduces the time taken to access data from the main memory (RAM), thereby
improving system speed and efficiency.
● Placement of Cache Memory:
o It is located between the CPU and RAM or integrated directly inside the CPU
chip

Q4. What is the purpose of using secondary memory? Give some examples of secondary
memory devices. What is the storage capacity of a CD?
Answer:
● Purpose of Secondary Memory:
o Secondary memory is used to store data permanently and retrieve it when
required.
o it supports long-term data storage and retains data even when the power is
turned off
● Examples of Secondary Memory Devices:
o Hard Disk Drive (HDD)
o Solid State Drive (SSD)
o Compact Disc (CD)
o Digital Versatile Disc (DVD)
o Pen Drive (USB Flash Drive)
● Storage Capacity of a CD:
o A CD-ROM (Compact Disc Read-Only Memory) typically has a storage capacity of
700 MB (Megabytes).

Case-Based Questions with Answer


Q1. Rohit bought a computer but noticed it runs very slowly when multiple applications are
opened. He asked a technician for advice on upgrading his system.
Answer the following:
a) Which component is most likely responsible for multitasking performance?

● RAM
● Hard Disk
● Processor
● Motherboard

b) What is the role of RAM in a computer’s performance?

14 | P a g e
c) If upgrading RAM is not an option, suggest one other way to improve the system’s speed.
d) Rohit also wants to increase storage capacity. Which type of storage device should he
choose for faster performance: HDD or SSD? Why?
e) What utility software can help optimize system performance?

Answer:
a) The component most responsible for multitasking performance is: RAM
b) Role of RAM in a computer’s performance:
RAM (Random Access Memory) temporarily stores data that the CPU needs while running
applications. More RAM allows smoother multitasking and faster performance.
c) Alternative way to improve system speed if upgrading RAM is not an option:
Use an SSD (Solid State Drive) instead of an HDD to speed up data access and system
performance.

d) Best storage device for faster performance:


SSD (Solid State Drive) is better than HDD because it has faster read/write speeds, reducing
loading times and improving overall system responsiveness.

e) Utility software for optimizing system performance:


Disk Cleanup (removes unnecessary files)
Disk Defragmenter (for HDDs)
Task Manager (to manage background processes)
Antivirus software (to remove malware that slows down the system)

Q2. Computers have transformed our lives, bringing both advantages and challenges. Analyze
the following aspects and state whether they have a positive or negative impact:

Answer the following:


a) Automation of jobs – Does it create employment opportunities or reduce them?
b) Health concerns – How does prolonged computer usage affect health?
c) Social networking – Has it improved communication or caused social isolation?
d) Accuracy of calculations – Does using computers in financial transactions reduce errors?
e) Cybersecurity issues – How has increased digitization affected data security?

Answer:
Impact of Computers on Society

a) Automation of jobs: Negative impact: It reduces employment in traditional sectors by


replacing manual labor with machines. However, it creates new jobs in tech-related fields.

b) Health concerns: Negative impact: Prolonged computer usage can cause eye strain, back
pain, and carpal tunnel syndrome.

c) Social networking: Both positive and negative: It improves communication but can also
lead to social isolation if people spend too much time online instead of engaging in face-to-face
interactions.

d) Accuracy of calculations: Positive impact: Computers reduce human errors in financial


transactions, ensuring higher accuracy and reliability.

15 | P a g e
e) Cybersecurity issues: Negative impact: Increased digitization has led to cyber threats like
hacking, phishing, and data breaches.

Q3. Neha was working on an important project but forgot to save her work. Unfortunately, her
system crashed due to power failure.
Give suitable Answer of the following:
a) Will she be able to recover the unsaved data? Why or why not?
b) Which type of memory is responsible for temporary storage, and why is it lost after
shutdown?
c) Suggest one precaution Neha can take in the future to avoid data loss.
d) Name a hardware device that can help prevent unexpected shutdowns.
e) Between an external hard disk and a USB pen drive, which is better for long-term data
storage, and why?

Answer:
Neha’s Data Loss Due to Power Failure

a) She can recover unsaved data it depends on some software (like MS Word) has an auto-
recovery feature. But if the data wasn’t auto-saved, it is lost.
b) Memory is responsible for temporary storage:
RAM stores temporary data, but it is volatile, meaning data is lost after shutdown.
c) Precautions to avoid data loss in the future:
Enable AutoSave in applications or manually save work frequently.
d) Hardware device to prevent unexpected shutdowns:
UPS (Uninterruptible Power Supply) provides backup power during outages.
e) Better long-term storage device:
External Hard Disks are better for long-term storage because they offer more capacity and
durability than a USB pen drive.
Q4. Arjun is an architect who wants to create digital blueprints for his clients.
Answer the following:
a) Should he use traditional paper-based drawing or digital design software? Which one is
more efficient?
b) If he prefers digital drawing, which input device is best suited for sketching?
c) What type of display device (monitor) would be best for detailed architectural designs?
d) Which software should he use for designing professional architectural blueprints?
e) What kind of printer should he use for high-quality, large-scale prints of his designs?

Answer:
Arjun’s Architectural Design Needs
a) More efficient method for blueprints:
Digital design software is more efficient as it allows easy modifications, scaling, and 3D
modeling.
b) Best input device for digital sketching:
Graphics tablet (e.g., Wacom tablet) for precise sketching.
c) Best monitor for detailed designs:
16 | P a g e
4K Ultra HD monitor with high color accuracy and large screen size.
d) Best software for architectural blueprints:
AutoCAD, Revit, and SketchUp are widely used in architecture.
e) Best printer for large-scale prints:
Plotter printer (suitable for high-quality, large-scale architectural prints).

Q5. Graphics cards play an important role in computer performance.


Answer the following:
a) What is the primary function of a graphics card?
b) Do all computers require a dedicated graphics card? Why or why not?
c) For which type of applications is a high-performance graphics card necessary?
d) How does a dedicated graphics card differ from an integrated graphics card?
e) If someone is a casual user (watching movies, browsing the web), would they need a
dedicated
GPU? Why or why not?

Answer:
Graphics Card and Performance
a) Primary function of a graphics card:
It processes and renders graphics for gaming, video editing, and visual applications.
b) Do all computers need a dedicated GPU?
No, basic tasks (browsing, office work) can be handled by integrated graphics.
c) Applications that require a high-performance GPU:
Gaming, 3D rendering, video editing, and AI-based applications.
d) Difference between dedicated and integrated graphics cards:
Dedicated GPU: Has its own memory (VRAM) for better performance.
Integrated GPU: Uses system RAM and shares CPU resources.
e) Do casual users need a dedicated GPU?
No, integrated graphics are sufficient for watching movies and browsing.

Q6. Mr. Sharma wants to buy a laptop but is confused between two models: one with DOS and
the other with pre-installed Windows.
Answer the following:
1. Why is the laptop with Windows more expensive than the one with DOS?
o a) DOS version is not user-friendly.
o b) DOS version does not support installing other software.
o c) Windows comes pre-installed, and its cost is included in the laptop price.
o d) None of the above.
2. If Mr. Sharma buys the DOS version, what additional software does he need to install
first?
o a) Utility software b) Application software
o c) Operating system d) None of the above
3. Mr. Sharma wants to create spreadsheets. Which software should he install?
o a) MS Excel b) MS Word
o c) MS PowerPoint d) All of the above
4. What software should he install to protect his laptop from viruses?
o a) Windows Media Player b) Windows Defender (Antivirus)
o c) MS Office d) None of the above

17 | P a g e
5. Which software should he install to browse the internet?
o a) Internet Explorer b) Mozilla Firefox
o c) Google Chrome d) All of the above

Answer:
Mr. Sharma’s Laptop Purchase Decision
1.(c) Windows comes pre-installed, and its cost is included in the laptop price.
2.(c) Operating system (like Windows or Linux).
3.(a) MS Excel
4.(b) Windows Defender (Antivirus)
5 (d) All of the above (Internet Explorer, Mozilla Firefox, Google Chrome).

Q7. Rahul frequently uses his personal computer for online banking, shopping, and
work-related activities. Recently, he noticed some unusual transactions in his bank
account, which made him suspect a security breach.
Answer the following:
a) What could be the most likely cause of Rahul’s security breach?
• Weak Passwords
• Malware or Keyloggers
• Phishing Attacks
• All of the above
b) What precaution should Rahul take to create a strong password? Name two key
characteristics of a strong password.
c) Which type of software should Rahul install to protect his computer from viruses and
malicious attacks?
d) Rahul frequently connects to public Wi-Fi. What security risk does this pose, and how can he
protect himself?
e) Name two online safety practices Rahul should follow to avoid phishing attacks and
unauthorized access to his accounts.

Answers:
a) All of the above (Weak passwords, malware, and phishing attacks can all lead to security
breaches).

b) Precautions for a strong password:


• Use a combination of uppercase, lowercase, numbers, and special characters
• Avoid using common words or personal information
c) Antivirus and Anti-Malware Software (e.g., Windows Defender, McAfee, or Norton)
d) Public Wi-Fi risks: Hackers can intercept data using man-in-the-middle attacks.
Rahul should use a VPN (Virtual Private Network) to encrypt his data.

e) Online safety practices:


• Avoid clicking on suspicious links or emails from unknown senders
• Enable two-factor authentication (2FA) for online accounts

Q8. Aman is starting his own e-commerce business. He needs various types of software
to manage inventory, process online orders, and secure customer data.

18 | P a g e
Answer the following:
a) Which category of software should Aman use to manage customer data and transactions
efficiently?
• System Software
• Application Software
• Utility Software
• Firmware

b) Aman needs to track inventory and sales. Should he use general-purpose software or
customized software? Justify your answer.

c) To secure customer data, which type of utility software should Aman install?
d) Aman is using an open-source e-commerce platform. What is the main advantage of open-
source software?
e) Name one programming language that Aman can use to develop a customized website for
his business.

Answers:
a) Application Software (It helps manage business operations like customer data and
transactions).
b) Customized software is better because it can be tailored to Aman's business needs and
offer specific features for inventory management.
c) Antivirus and Encryption Software (to protect sensitive customer data from cyber
threats).
d) Advantage of Open-Source Software: It is free to use, customizable, and has community
support.
e) Programming language: Python, JavaScript, PHP, or Java (commonly used for web
development).

19 | P a g e
Unit 2: Introduction to Python
BASICS OF PYTHON
Mind Map

1. Basics of Python Programming & Execution Modes (Interactive and


Script Mode)
Python Basics:
Python is a high-level, interpreted, and general-purpose programming language. It
emphasizes readability and ease of use, making it a great choice for beginners. It supports
multiple programming paradigms, including procedural, object-oriented, and functional
programming.

20 | P a g e
2. Execution Modes:
Python can be run in two primary execution modes:
• Interactive Mode:
○ You enter individual Python commands or expressions, and the interpreter
immediately executes and displays the result.
○ This mode is great for quick testing and exploring code snippets.
○ Example: Open the Python shell and type print("Hello, World!") to
immediately get the result.
In Interactive mode, commands are given in front of Python command prompt
>>>
Example
>>> 10+ 15
25
>>> print (‘Hello, World’)
Hello, World
Interactive Mode is helpful for testing statement/code, you type the
commands, commands are executed one by one and get the result or error one
by one.

• Script Mode:
○ Python program is written in a file(.py), which are then executed as a whole by
the Python interpreter.

○ This mode is suited for developing larger programs or when you want to run a
sequence of Python commands that are stored in a file.

Steps for writing in Script mode –


1. Open Python IDLE
2. From File Menu Choose – New File
3. Type the codes on File named Untitled
4. Click on Save from file menu

Interactive Mode Vs Script Mode


In Interactive Mode, the commands or statements entered by the user are not saved.
However, in Script Mode, the program code or statements are first saved in a .py file,
and then the code is executed.

21 | P a g e
3. The Structure of a Program
The structure of a Python program typically consists of the following elements:
• Modules: Python code is often organized into modules, which are files containing
Python definitions and statements.
• Functions: Functions are defined using the def keyword and are used to encapsulate
code that performs specific tasks.
• Statements and Expressions: A statement in Python represents an action (e.g., print
()), while an expression computes a value (e.g., x + y).
• Control Flow: Conditional statements (if, else, elif) and loops (for, while) direct the
flow of execution.

A basic simple program structure might be look like this:


print (“hello”)

A basic program structure using function might look like this:


def my_function(): #defining of function
# Function code here
print(“hello”)

# Main program execution


my_function() #calling of function

4. Indentation
In Python, indentation is critical and is used to define the structure of code blocks. Unlike
many other programming languages, Python does not use braces {} to define blocks of code
(like loops or functions). Instead, it uses whitespace indentation.

• Consistent Indentation: Python requires consistent indentation throughout a block


of code. A common convention is using 4 spaces for each level of indentation.

• Error if Inconsistent: If you mix spaces and tabs, or if the indentation is inconsistent,
Python will throw an IndentationError.

Example:
if a==0:
print("Hello, World!") # print statement part of if condition
print(“Hello, World!”) # print statement not a part of if condition

5. Identifiers
Identifiers in Python are names used to identify variables, functions, classes, and other
objects.
• Rules for Identifiers:
○ Must begin with a letter (A-Z or a-z) or an underscore (_).
○ Can be followed by letters, digits (0-9), or underscores.
○ Case-sensitive: Schoolname, SchoolName, and SCHOOLNAME all three are
different identifiers in python.

22 | P a g e
○ Cannot be a keyword (e.g., if, else, def, etc.).

Example: my_variable = 10

Valid Identifiers: Rollno, ROLLNO, ROLL_NO, RNO92A, _RNO, RFILE


Invalid Identifiers: DATA_REC, break(keyword), Roll.No, 19Rno, Roll No

6. Keywords
Keywords are reserved words in Python that have special meaning and cannot be used as
identifiers.
Example: if, else, elif, for, while, def, class, import

7. Constants
Values that do not change during execution of program are called constants. In Python, there
are no built-in constants (values that cannot be changed once set). However, it’s a common
convention to use uppercase letters for constant-like values, signaling that they should not
be changed.
○ Example: PI = 3.14159 MAX_USERS = 1000

8. Variables
A variable in Python is an identifier whose value can be changed. Python is a dynamically
typed language, meaning the type of a variable is determined at runtime, based on the value
it holds.
• Declaring Variables: You don't need to specify the type of the variable; Python
automatically assigns the appropriate type based on the value.
o Example:
▪ age = 25 # This assigns an integer value to 'age'
▪ name = "John" # This assigns a string value to 'name'
• Reassigning Variables: Python allows the reassignment of variables to different data
types.
age = 25 # ‘age’ contains value of integer type
age = "twenty-five" # now 'age' contains value of string type
9. Types of Operators
Python supports various types of operators to perform operations on variables and values:
• Arithmetic Operators (+, -, *, /, //, %, **): Used for mathematical calculations.
Operator Description Example
X=10, y=20
+ Addition To adds values on either side of the operator. >>>X + y
>>>30
- Subtraction Subtracts right hand operand from left hand >>>X – y
operand. >>>-10
* Multiplication Multiplies values on either side of the operator >>>X * y
>>>200
/ Division Divides left hand operand by right hand operand >>>X / y

23 | P a g e
>>>2
// Floor The division of operands where the result is the >>>9//2
quotient in which the digits after the decimal
Division >>>4
point are removed. But if one of the operands is
negative, the result is floored, i.e., rounded away ------------------
from zero (towards negative infinity) −
>>>9.0//2
>>>4.0

% Modulus Divides left hand operand by right hand operand >>>X % y


and returns remainder
>>>0
** Exponent Performs exponential (power) calculation on >>>X**2
operators
>>>100
X variable in Capital letter and y variable in small letter
Note: Python is case sensitive This means that uppercase and lowercase letters
are treated differently
Note: + and * operators are also used in String Manipulation
for e.g. X= ‘Welcome’ Y=2025
>>>X+Y
>>>Welcome2025

X=’Welcome’ Y=2
>>>X*Y
>>>WelcomeWelcome

• Comparison Operators (==, !=, >, <, >=, <=): Used to compare two values.
It either returns True or False according to the given condition.

Operator Description Example


X=20, y=10
== If values of two operands are equal, then the condition >>>(X == y)
becomes true.
>>>False
!= If values of two operands are not equal, then condition >>>(X != y)
becomes true.
>>>> True
> If the value of left operand is greater than the value of >>>(X> y)
right operand, then condition becomes true.
>>>True
< If the value of left operand is less than the value of right >>>(X < y)
operand, then condition becomes true.
>>>False
>= If the value of left operand is greater than or equal to >>>(X >= y)
the value of right operand, then condition becomes
>>>True
true.

24 | P a g e
<= If the value of left operand is less than or equal to the >>>(X <= y)
value of right operand, then condition becomes true.
>>>False

Note: These operators can also be used for comparing string values, through the
use of ASCII value of a String. ASCII value of A=65, Z=90, a=97, z=122

e.g. X= ‘ABc’ Y= ‘Abc’


>>>X>Y # output will be False

• Assignment Operators (=, +=, -=, *=, /=,%=,**=,//=): Used to assign values to
variables. It assigns values from right side operands to left side operand
Operator Description Example

= Assigns values from right side operands to left Z = X + Y assigns


side operand
value of X + Y into Z
+= It adds right operand to the left operand and X += Y is equivalent
assign the result to left operand
to X = X + Y
-= It subtracts right operand from the left operand X -= Y is equivalent
and assign the result to left operand
to X = X – Y
*= It multiplies right operand with the left operand X *= Y is equivalent
and assign the result to left operand
to X = X * Y

/= It divides left operand with the right operand and Y /= Z is equivalent


assign the result to left operand
to Y = Y / Z

%= It takes modulus using two operands and assign m %=n is equivalent


the result to left operand
to m = m % n
**= Performs exponential (power) calculation on C **= a is equivalent
operators and assign value to the left operand
to C = C ** a

//= It performs floor division on operators and assign c //= A is equivalent


value to the left operand
to c = c // A

• Logical Operators (and, or, not): Used to combine conditional statements.

Operator Description Example


X=20, Y=10
Z=5
and Logical AND: True if both the operands are true X>Y and Y>Z
otherwise False True

25 | P a g e
or Logical OR: True if either of the operands is true X>Y or Y<Z
otherwise False
True
not Logical NOT: True if operand is False and vice not (X>Y)
versa False
not(X>Y and Y>Z)
False

• Membership Operators (in, not in): Used to test membership in a sequence such as
strings, lists, or tuples. There are two membership operators as explained below –

str= ‘KVS 2025 Class IP’


Val=‘IP’ in str
print(Val)
#output : True

Operator Description Example

in Evaluates to true if it finds a variable in x in y,


the specified sequence and false
here in results, statement will
otherwise.
be True only if x is a member
of sequence y.
not in Evaluates to true if it does not find a x not in y,
variable in the specified sequence and
here in results, statement will
false otherwise.
be True if x is not a member
of sequence y.

• Identity Operators (is, is not): Used to compare the memory location of two
objects.
is, is not are the identity operators both are used to check if two values are located on
the same part of the memory. Two variables that are equal does not imply that they are
identical.

Operator Description Example

is Evaluates to true if the variables on x is y,


either side of the operator point to the
here it checks, if id(x) equals
same object and false otherwise.
to id(y) then result is True
is not Evaluates to false if the variables on x is not y,
either side of the operator point to the
here it checks if id(x) is not
same object and true otherwise.
equal to id(y) then result is
True

26 | P a g e
• Bitwise Operators(&, |, ^, ~, <<, >>): Used for bit-level operations.

10. Precedence of Operators


The precedence of operators determines the order in which operations are performed in an
expression. Operators with higher precedence are evaluated before operators with lower
precedence.

It is in descending order (upper group has higher precedence than the lower ones.)

Sr.No. Operator Description Associativity


1 () Highest Parentheses Left to Right
Precedence
2 ** Exponentiation (raise to the power) Right to left

3 ~,+,- Complement, unary plus and minus Left to Right


(method names for the last two are +@
and -@)
4 * , /, % , // Multiply, divide, modulo and floor Left to Right
division
5 + ,- Addition and subtraction Left to Right
6 >>, << Right and left bitwise shift Left to Right
7 & Bitwise 'AND' Left to Right
8 ^,| Bitwise exclusive `OR' and regular `OR' Left to Right

9 <= < > >= Comparison operators Left to Right


10 <> == != Equality operators Left to Right
11 = %= /= //= -= += Assignment operators Right to Left
*= **=
12 not , or , and Logical operators Left to Right
Example:
result = 3 + 5 * 2 # Multiplication happens first
print(result) # Output: 13
To change the order of evaluation, use parentheses.
Operator precedence and associativity of operators that decide the order in which parts
of an expression are calculated. Precedence tells us which operators should be evaluated
first, while associativity determines the direction (left to right or right to left) in which
operators with the same precedence are evaluated.

11. Data Types


Data type identifies the type of data which a variable can hold and the operations that can be
performed on those data.
Python supports a variety of built-in data types that can store values:

27 | P a g e
• Numeric Types:
○ int: Integer numbers (e.g., 5, -3).
○ float: Floating-point numbers (e.g., 3.14, -0.001).
• Sequence Types:
○ str: Strings (e.g., "Hello", 'Python').
○ list: Ordered, mutable collections (e.g., [1, 2, 3]).
○ tuple: Ordered, immutable collections (e.g., (1, 2, 3)).
• Mapping Type:
○ dict: Key-value pairs (e.g., {"name": "John", "age": 25}).
• Boolean Type:
○ bool: True or False.
12. Mutable and Immutable Data Types
• Mutable Types: These are data types/objects whose content or values can be
changed after they are created.
○ Examples: list, dict.
○ These objects can be modified in place, so changes to a mutable object will
affect all references to that object.
• Immutable Types: These are data types whose content or values cannot be changed
after they are created.
○ Examples: int, str, tuple.
○ When an immutable object is modified, a new object is created, leaving the
original object unchanged.
Example of Mutability:
a = [1, 2, 3]
b=a
a.append(4) # Modifies the original list
print(b) # Output: [1, 2, 3, 4]
print(a) #Output: [1, 2, 3, 4]
print(id(a)) # gives memory location of object
print(id(a)) # gives memory location of object
both a and b variable having same location in memory

Immutable object (string)


x = "hello"
y=x
x = "world" # Creates a new string object
print(y) # Output: hello (y is unaffected)
print(x) # Output: world(x value changed)
print(id(x)) # gives memory location of object
print(id(y)) # gives memory location of object
both x and y variable having different location in memory
Multiple Choice Questions
1 Which function is used to display output in Python?
A) show() B) print() C) display() D) output()
2 Identify the valid relational operator among the following.
A) = B) += C) == D) and
3 Which of these is a valid Python identifier?
A) 1var B) _var C) var-name D) var name

28 | P a g e
4 What is the correct way to assign a value to a variable in Python?
A) x == 5 B) 5 = x C) x = 5 D) x := 5
5 Which operator is used for exponentiation in Python?
A) ^ B) ** C) exp() D) %
6 Predict the output of the following code:
print(3**2+55/11*-(-3+3))
A) -39.0 B) 27.0 C) -14.0 D) 9.0

Answer (Multiple Choice Questions)


1 B) print()
2 C) ==
3 B) _var
4 C) x = 5
5 B) **
6 D) 9.0

Assertion and Reasoning Questions


Choose correct option for given Assertion (A) and Reasoning (R)
A. Both A and R are true and R is the correct explanation of A.
B. Both A and R are true but R is not the correct explanation of A.
C. A is true but R is false.
D. A is false but R is true.

1 Assertion (A) : List is mutable data type.


Reasoning (R): In-place change is not possible in list elements.
2 Assertion (A) : 1ABC is correct Identifier.
Reasoning (R): Identifier can’t start with digits.
3 Assertion(A): Variable names whether in capital or small letters are
treated as different python.
Reasoning(R): Python is a case sensitive language.

Answer (Assertion and Reasoning Questions)

1 C) A is true but R is false


2 D) A is false but R is true
3 A) Both A and R are true and R is the correct explanation of A.

Very Short Questions with Answer

1 What is the None keyword in Python, and what does it represent?


Ans. None is a special keyword in Python representing the absence of a value

29 | P a g e
or a null value. It is often used to signify that a variable does not have any value
assigned to it yet.
2 What is a variable in Python, and how is it different from a constant?
Ans. A variable is a name that refers to a value that can be changed during the
execution of the program, while a constant represents a value that remains
unchanged throughout the program.
3 Differentiate between Keywords and Literals (Constants).
Ans. Python Keywords are some predefined reserved words in Python that
have special meaning.
Identifier is a user-defined name given to a variable, function, class, module,
etc. The identifier is a combination of character digits and an underscore. They
are case-sensitive i.e., 'num' and 'Num' and 'NUM' are three different identifiers
in python. It is a good programming practice to give meaningful names to
identifiers to make the code understandable.
4 Arrange the precedence of operators from highest to lowest
+ , ** , // , ==
Ans. precedence of operators from highest to lowest
**, //, +, ==

Short Questions with Answer


1 Nitin is trying to find out answers of these questions while finding output
of a program. Help him to find out correct answers with reason.

(i) What will be output of print(14%4)?


(ii) Identify the data type of [3, 10]
(iii) What will be output of print(‘5’ + ‘5’) ?
(iv) What will be output of print(2**3**2) ?
Ans. (i) Output will be 2 Because % operator performs floor division and
provides remainder after division.
(ii) List as it is enclosed with [ ].
(iii) Output will be ‘55’ Because + operator concatenates both the strings.
(iv) Output will be 512, because multiple ** follows right associativity
2 Write a program to calculate simple interest.
Ans:

3 Write a Python program to find the average of three numbers where value of
a is 10, b is 20 and c is 30.

30 | P a g e
Ans:

4 Predict Output –
a, b, c = 2, 3, 4
a, b, c = a*a, a*b, a*c
print(a, b, c)
Ans. 4 6 8
5 Predict the Output –
a, b, c = 10, 20, 30
p, q, r = c-5, a+3, b-4
print('a, b, c : ', a, b, c, end = '### ')
print('p, q, r : ', p, q, r, sep = '$$ ')
Ans: a, b, c : 10 20 30###p, q, r : $$25$$13$$16
6 Payal is working in a firm and given a task to find the average of two numbers
x=7
y=5
print(x+y/2)
she is not getting the correct average, give your suitable answer and rectify the
code
Ans:
x=7
y=5
print((x+y)/2)

both x and y should be in parenthesis and both divided by 2 then she will
be able to find correct average
13. Statements
• Instructions executed by the Python interpreter.

31 | P a g e
• Types of statements:
o Empty statement: – Statement which does nothing. It is as follows:

o Simple statement: Any single executable statement is a simple statement.

o Compound statement: A group of statements executed as a unit is a


compound statement.
A compound statement has:
(i) a header line which begins with a keyword and ends with a colon.
(ii) a body consisting of one or more Python statements, each indented inside the
header line. All the statements are at the same level of indentation.

14.Expressions and Evaluation


• Combinations of variables, operators, and values that yield a result.
• Examples:
o Arithmetic expressions: e.g. a=2 + 3
o Logical expressions: e.g. a and b , a or b
o String expressions: e.g. "Computer" + "Science"

• Can be part of a larger statement.


Evaluation
• The process of computing the result of an expression.
• Python evaluates expressions using the rules of precedence and associativity.

15. Comments
• Used to annotate code and make it more understandable.
• Single-line comments: Begin with # symbol
e.g., #This is a comment.

• Multi-line comments: Enclosed in triple quotes


e.g. """ Multi-line comment
To give more description of code """
If the comment is more than one line then multi-line comment will be used
16. Input and Output Statements
• Input:

32 | P a g e
o input (): Reads a line of text input from the user (e.g., name = input ("Enter your name: ")).
o Always returns a string.
• Output:
o print (): Outputs text or variables to the console (e.g., print ("Hello, World!")).
o Can accept multiple arguments separated by commas (e.g., print ("Name:", name)).
o Optional arguments like sep and end to customize the output
e.g., print ("Hello", "World", sep="-")

17. Data Type Conversion


• Converting one data type to another.
• Common functions:
o int(): Converts a value to an integer (e.g., int("42") result is 42)
o float(): Converts a value to a float (e.g., float("3") result is 3.0)
o str(): Converts a value to a string (e.g., str(42) result is “42”)
o list(): Converts a value to a list (e.g., list("abc") result is ['a', 'b', 'c'])
o tuple(): Converts a value to a tuple (e.g., tuple([1, 2, 3]) result is (1,2,3))
o dict(): Converts a value to a dictionary (when applicable, e.g., dict([('a', 1), ('b', 2)])
result is {‘a’:1 , ‘b’:2} )

18. Debugging in Python


• Definition:
o The process of finding and fixing errors or bugs in program code.

• Common Debugging Techniques:


o print Statements: Insert print () statements in your code to check values of variables and
program flow
e.g. print ("Checkpoint reached") #output Checkpoint reached

x=15
print ("Value of x:", x) #output Value of x: 15

19. Control Statements in Python


• Sequence: Sequence construct means statement are executed Sequentially:
• Selection: The Selection construct means the execution of statement(s) depending
upon a condition-test.
• Iterative: Iteration construct means repetition of set of statements depending upon a
condition test till the time of condition is true.
Understand concept of sequence, selection, iterative statement using real life example:
A child wants to celebrate his birthday. His mother gives him 3 options to decorate the house
with less cost. She said decorate the house either with balloon or flower or pictures. If child
wants to decorate his house with balloons, then he has to inflates all the balloons one by one
until 50 balloons are inflated with the help of the pump.
Real life steps as per the above the example:

33 | P a g e
1. Child seated with mother to discuss about decoration of house for celebrating his birthday
2. They discuss all 3 options to decorate the house with balloon or flower or pictures
(sequentially child think about every option with its cost)

3. child think about all options and choose one option (he selects decoration of house with
ballons) due to less cost. Selection statement→use of [if/ elif /else]

4. Child start inflating balloons one by one until 50 balloons are inflated with the help of
pump. (Repetition of task; inflation of balloon -> iteration statement → use of [for/
while]
Note: student use this real-life example and make python program after learning python
control statements

Selection Statements
• if statement:
• Executes a block of code if a condition is true.
• Example:

• if-else statement:
• Executes one block of code if a condition is true, and another block if it is false.
• Example:

• if-elif-else Statement:
• Checks multiple conditions in sequence, executing the first block of code where the
condition is true.
• Example:

Iterative Statements
While Loop:
• Repeats a block of code as long as a condition is true.
Example:

34 | P a g e
For Loop
• Iterates over a sequence (e.g., list, tuple, string) or range of numbers.
Syntax: for <variable> in <sequence>
statements_ to_repeat

• Example:

Jump statements
Python offers two types of jump statements to be used within loops to jump out of loop
iterations.

• break
Break statement is a jump statement which terminates the very loop it lies
within and skips over a part of the code(i.e. rest of the loop) and jumps over to the
statement following the loop.
• continue
Continue is a jump statement which forces the next iteration of the loop to take
place and skip the rest of the loop statements.

Looping with ‘break’ and ‘continue’:


-> break: Exit the loop when the ‘break’ statement will encounter.
-> continue: Skip the rest of the code after ‘continue’ and move to the next iteration.

• Examples:

→Example of break: In this case value will not be printed after 2 ,


→ Example of continue: in this case all the values will be printed as per the condition except 3
Same concept is applicable on ‘while’ loop.

Loop with ‘else’ statement


The else statement of a Python loop executes when the loop terminates normally, i.e., when test
condition results into false for a while loop or for loop has executed for the last value in the
sequence; and not when the break statement terminates the loop.
Example:

Multiple Choice Questions

1. What will be the output of the following code?


print (type (3.0))
a) <class 'int'> b) <class 'float'> c) <class 'double'> d) <class 'decimal'>

35 | P a g e
2. What is the primary purpose of the if statement in Python?
a) To execute a block of code based on a condition
b) To perform mathematical operations
c) To repeat a block of code
d) To define a function
3. Ravi is a student of class xi computer sci and he is not able to understand the
concept of if statement of Python and you as a programmer help him to find out the
correct output of the following code snippet?
x = 10
if x > 5:
print("x is greater than 5")
a) x is greater than 5 b) x is less than 5
c) x is equal to 5 d) No output
4. Which keyword is used to execute a block of code if the condition in the if statement
is false?
a) while b) elif c) else d) for
5. What is the purpose of the elif statement in Python?
a) To define a loop b) To perform arithmetic operations
c) To exit from a loop d) To execute a block of code if the previous conditions are false

6. Sunita is a student of class xi computer sci and he is not able to understand the
concept of if-elif statement of Python and you as a programmer help him to find out
the correct output of the following code snippet?
x=5
if x < 3:
print ("x is less than 3")
elif x == 3:
print ("x is equal to 3")
else:
print ("x is greater than 3")
a) x is less than 3 b) x is equal to 3 c) x is greater than 3 d) No output
7. How can you execute multiple statements under a single if block in Python?
a) Separate statements with a semicolon
b) Indent the statements to the same level
c) Use the and keyword between statements
d) Use the elif keyword
8. You as a programmer of python in a company, Find out the correct output
of the following code
x = 10
if x < 5:
print ("x is less than 5")
elif x > 15:
print ("x is greater than 15")
else:

36 | P a g e
print ("x is between 5 and 15")
a) x is less than 5 b) x is greater than 15
c) x is between 5 and 15 d) No output
9. What is the purpose of the while loop in Python?
a) To execute a block of code repeatedly until a condition is false
b) To execute a block of code a fixed number of times
c) To define a function
d) To iterate over items in a sequence
10. What is the syntax of while loop in Python?
a) while condition (): b) while condition:
c) while condition loop: d) while loop condition:
11. How can you exit a loop prematurely in Python?
a) Using the break statement b) Using the continue statement
c) Using the pass statement d) Using the exit function
12 Meera created a List named fruits in python and he want to access each element
of a List. She writes below code but she is not sure whether below code is correct
or not. Help her to find the correct output from the given options
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print (fruit, end=’ ’)
a) No Output b) [“apple”, “banana”, “cherry”]
c) 0 1 2 d) apple banana cherry
13. What will the following code snippet print?
for i in range (2,-1,-1):
print (i, end=' ')

a) 0 1 2 b) 1 2 3 c) 2 1 0 d) 3 2 1 0
14. What is the purpose of the pass statement in Python?
a) To exit from a loop prematurely
b) To skip the current iteration of a loop
c) To execute a block of code if a condition is false
d) To do nothing and act as a placeholder
15. What is the purpose of the else block in a loop in Python?
a) To execute if the loop encounters an error
b) To execute if the loop completes without encountering a break statement
c) To execute if the loop encounters a continue statement
d) To execute if the loop encounters a pass statement
16. An empty/null statement in Python is
a) go b) pass c) over d) ;
17. What is the output of the following code?
x = 10
if x > 5:
print("Hello")
elif x > 8:

37 | P a g e
print("Hi")
else:
print("Hey")
a) Hey b) Hi c) Hello d) Hello, Hi

Answer (Multiple Choice Questions)


1 (b)<class 'float'>
2 (a) To execute a block of code based on a condition
3 (a) x is greater than 5
4 (c) else
5 (d)To execute a block of code if the previous conditions are false
6 (c) x is greater than 3
7 (b) Indent the statements to the same level
8 (c) x is between 5 and 15
9 (a) To execute a block of code repeatedly until a condition is false
10 (b) while condition:
11 (a) Using the break statement
12 (d) apple banana cherry
13 (c) 2 1 0
14 (d) To do nothing and act as a placeholder
15 (b) To execute if the loop completes without encountering a break statement
16 (b) pass
17 (c) Hello

Assertion and Reasoning Questions

Choose correct option for given Assertion (A) and Reasoning (R)
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
1 Assertion (A): The conditional flow of control can be defined with the help of if
statement.
Reasoning (R): if statement executes one or more statements based on the given
condition. If the condition evaluates to true, the statement block following the
indentation gets executed, otherwise nothing gets executed.
2 Assertion (A): break and continue are termed as Jump statements.

38 | P a g e
Reasoning (R): Jump statements can only be used with looping constructs but not
with conditional constructs.
3 Assertion (A): In an if-else statement, the if block checks the true part whereas else
checks for the false part.
Reasoning (R): In a conditional construct, else block is mandatory.
4 Assertion (A): The data type of a variable is taken according to the type of value assigned
to it.
Reasoning (R): Data types do not require initialization at the time of declaration.
This process is described as Dynamic Typing.
Answer (Assertion and Reasoning Questions)

1 a) Both A and R are true and R is the correct explanation of A.


2 a) Both A and R are true and R is the correct explanation of A.
3 c) A is true but R is false.
4 a) Both A and R are true and R is the correct explanation of A.
Short Questions with Answer

1 What will be the output of the following code? Also give short explanation about
execution of loop with continue statement
for i in range (1, 6):
if i == 3:
continue
print (i , end=’’)
Ans. 1245
Explanation: The continue statement skips the rest of the loop and moves to the
next iteration. So, when i equals 3, it skips printing that value.
2 What will be the output of the following code? with explanation, how the code will
be executed?
for i in range(3):
for j in range(3):
print(i + j, end=' ')
print()
Ans.

Explanation: The outer loop iterates three times, and for each iteration of the outer
loop, the inner loop also iterates three times. The values of i and j are added together
and printed. Each iteration of the outer loop starts a new line.
3 What will be printed by the following code?
num = 5
while num > 0:
print(num)
num -= 1
if num == 3:
39 | P a g e
break
else:
print("Done")

Ans. 5
4
4 What is the output of the following code?
x = 10
if x < 5:
print("A")
elif x > 7:
print("B")
else:
print("C")

Ans. B
5 What will be the output of the following code?
x=5
while x > 0:
print (x, end=" ")
x-=2
if x == 1:
break
else:
print("Done")

Ans. 5 3
6 What do you mean by continue and break keywords

Ans. The break statement terminates the loop containing it. Control of the
program flows to the statement immediately after the body of the loop.

The continue statement is used to skip the rest of the code inside a loop for the
current iteration only. Loop does not terminate but continues with the next
iteration.

7 What is the use of While loop? With suitable example.

Ans. The while loop in Python is used to repeatedly execute a block of code as
long as a given condition remains true.
Example:
c=0
while c < 5:
print("C:", c)
c += 1
8 Find out the Error in the following Code Snippet. Rewrite the code after removing
all the errors and underline.

40 | P a g e
Ans.

Long Questions with Answer


1 Write a program to test whether given number is prime or not.

Ans:

2 Write a program to compute the result when two numbers and one arithmetic
operator is given by user.
Ans:

4 Write a program to find the sum of first n natural numbers


Ans:

3 Write a program to input a digit from 0 to 9 and print it in words.


Ans:

41 | P a g e
5 Write a program to find the sum of first n odd numbers.
Ans:

6 Write a program to print the following pattern

Ans:

7 Write a program to calculate the roots of a given quadratic equation. If quotients


42 | P a g e
will be entered by the user.
Ans:

Case Based Questions with Answer


1 Krishna is looking for his dream job but has some restrictions. He loves Delhi and
would take a job there if he is paid over Rs.40,000 a month. He hates Chennai and
demands at least Rs. 1,00,000 to work there. In any another location he is willing
to work for Rs. 60,000 a month. The following code shows his basic strategy for
evaluating a job offer.

On the basis of the above code, choose the right statement which will be
executed when different inputs for pay and location are given.

(A) Input value: location = "Chennai”, pay = 50000


a) Statement 1 b) Statement 2 c) Statement 3 d) Statement 4
Answer: (b) Statement 2
(B) Input value: location = "Surat", pay = 50000
a) Statement 2 b) Statement 4 c) Statement 5 d) Statement 6
Answer: (d) Statement 6
(C) Input value: location = "Any Other City", pay = 1
a) Statement 1 b) Statement 2 c) Statement 6 d) Statement 4
Answer: (c) Statement 6

43 | P a g e
(D) Input value: location = "Delhi", pay = 500000
a) Statement 6 b) Statement 5 c) Statement 4 d) Statement 3
Answer: (c) Statement 4

(E) Input value: location = "Lucknow", pay = 65000


a) Statement 2 b) Statement 3 c) Statement 4 d) Statement 5
Answer: (d) Statement 5

2 Sanjeev is, a Python Programmer he is trying to write a program of finding leap


year if the value of year is given by user
(A year is a leap year if it is divisible by 4, except that years divisible by 100 are not
leap years unless they are also divisible by 400. )
Ans:

OUTPUT:
Enter year: 1800
1800 is not a Leap Year
3 Read the following case and answer the questions:
A school is organizing a mock election. The eligibility to vote is based on the age of
the student. The program checks the student's age and prints if the student is
eligible to vote or not.

Questions:
a) What will be the output if the user inputs 20?
b) What is the purpose of the int() function in this code?
c) Modify the code to also print "Please wait until you are 18." if not eligible.
d) What will happen if the user enters a non-numeric input?
e) If a student is eligible to vote another message must be displayed on the
screen that “choose a right person” , after which print statement, would you
add this line of code.
Answer: (a) Eligible to vote.
a) It converts the input string to an integer.

44 | P a g e
b)

c) It will raise a ValueError since int() cannot convert non-numeric input.


d) “choose a right person” line of code will be added in if block statement

4 A school uses the following grading system:


Marks >= 90 → Grade A
Marks >= 75 and < 90 → Grade B
Marks >= 50 and < 75 → Grade C
Marks < 50 → Grade D

Questions:
a) What grade will be displayed for 88 marks?
b) What is the output if the marks entered are 45?
c) Modify the code to also check if the marks are within 0 to 100.
d) What will happen if the user enters -10 in the above mentioned code.
Answers:
a) Grade B
b) Grade D
c)
d) The original code will still run and give Grade D, but it should be considered

invalid input.
45 | P a g e
5 A school wants to help students in revise multiplication tables. The following code
print the multiplication table of a number:
Hint- range(start, stop, step))
start position: default 0 if not specify, stop position: at which position to stop,
step position: increment /decrement, its optional, default is 1

Questions:
a) What will be the output for input 5?
b) How many times will the loop run?
c) Modify the code to print the table in reverse order (from 10 to 1).
d) What is the role of range (1, 11)?

Answers:
a) 5 x 1 = 5
5 x 2 = 10

5 x 10 = 50
b) 10 times.

c) for i in range (10, 0, -1):


print (num, "x", i, "=", num * i)
d) It generates numbers from 1 to 10.

List in Python
Mind Map:

List is an ordered sequence which is mutable and made up of one or more elements. A list can
have elements of different data types such as integer, float, string, tuple or even another list.

46 | P a g e
Elements of a list are enclosed in square brackets and are separated by comma. It is a mutable
data type.

Creating List
● We can create a list by placing elements inside square brackets [], separated by
commas.
Example : Number=['One', 'Two', 'Three']
● We can create list using list() method
data=list() Creates empty list
data=list([3,4,5])
Accessing Elements in a List: Each element in the list is accessed using a value called
index. The first index value is 0 and second index value is 1 and so on, if its move from left to
write.
If accessing of element start from right to left then the index value start from -1 to -n
Traversing a List: We can access each element of the list or traverse a list using a loop.
Example:
L=[1,2,3,4]
for item in L:
print(item)
Nested List: When a list appears as elements of another list, it is called a nested list.
Example: L=[1,2,[3,4],5]

List Methods and Built-in Functions


There is a key difference between functions and methods in Python. Functions take objects as
inputs/parameter. Methods in contrast act on objects.
Function Method
A= [25,36,37,12,25] A= [25,36,37,12,25]
M=len(A) M=A.count(25)
print(M) print(M)
#output 5 #output 2

list named A passed as count() method acts on


parameter object A (list)
Function Syntax Description
list() list() If no argument is passed, it will create an empty list.
list() list(sequence) It returns a list created from the passed arguments, which
should be a sequence type (string, list, tuple etc.). if no
argument is passed, it will create an empty list.
len() len (list) Returns the length of the list i.e. number of elements in a
list
max() max(list) Returns the element with the maximum value from the list
min() min(list) Returns the element with the minimum value from the list
sum() sum(list) It returns sum of elements of the list.
sorted () sorted It returns a newly created sorted list; it does not change the
(sequence, passed sequence. By default in sorted() reverse is False
reverse=False)

47 | P a g e
Method Syntax Description
append() list.append (items) It adds a single item to the end of the list.
insert() list.insert (index_no, It adds an element at a specified index
value)
reverse() list.reverse () It reverses the order of the elements in a list
index() list.index (item) It returns the index of first matched item from the
list.
sort() list.sort () This function sorts the items of the list
count() list.count (element) It counts how many times an element has occurred
in a list and returns it.
pop() list.pop (index)/ It removes the element from the specified index
list.pop() and also returns the element which was removed.
Default index is -1.
remove() list.remove (value) It is used when we know the element to be deleted,
not the index of the element.
clear() list.clear () .It removes all the elements from the list.
List Methods and Built-in Functions with Examples
The values that make a list are called its elements, or its items. We will use the term element or
item means same.
Functions Examples with output
list() X=list()
print(X)
Output: [ ] #emply list created
list(sequence) Lst=list ("hi")
print (Lst)
Output:
['h', 'i']
#sequence(String) converted in to list
len (list) L= [2, 3, [4,5]]
print(len(L))
Output:
3 # Explanation: In above example 3rd element is list and
it is considered as single element
max(list) L=[1,-2,4,-4]
print(max(L))
output: 4
Try it!!!
lst=[[2,3],[4,6],[6,4]]
print(max(lst))
min(list) L=[1,-2,4, -4]
print(min(L))
output: - 4
sum(list) L=[1, -2,4, -4]
print(sum(L))
output: -1

48 | P a g e
sorted(list,reverse=False) L=[15,16,17,2,3,9]
print(sorted(L)) #by default reverse False
output:
[2,3,9,15,16,17]
--------------------------------------------------------
L=[15,16,17,2,3,9]
print (sorted (L, reverse=True))
output:
[17,16,15,9,3,2]

Methods Examples with output


list.append(items/ elements) lst=[3,6,0]
lst.append(9)
print(lst)
output :
[3,6,0,9]
list.insert (index_no, value) Odd=[1,5,7,9]
Odd.insert(1,3)
print(Odd)
Output:
[1,3,5,7,9]
# value 3 inserted at index position 1
list.reverse () Even=[2,4,6,8]
Even.reverse()
print(Even)
output:
[8,6,4,2]
list.index (item/element) Even=[2,4,6,8]
print(Even.index(4))
Output:
1 #element 4 at index position 1
list.sort () Num=[2,4,-6,-8,0]
Num.sort() #by default reverse is False
print(Num)
Output:
[-8, -6, 0, 2, 4]
Num= [2,4, -6, -8,0]
Num.sort(reverse= True)
print (Num)
Output:
[4, 2, 0, -6, -8]
Use the “reverse” argument to sort in descending order

49 | P a g e
list.count (element) data= [10,30,20,30,90,30]
print(data.count(200))
output:
0 # element /value 200 not in the list data
data=[10,30,20,30,90,30]
print(data.count(30))
Output:
3 # element /value 30 three times in the list data
list.pop (index) data=[10,30,20,40,50]
print(data.pop()) # pop() without index position
print(data)
Output:
50 # pop () returns the popped value
[10,30,20,40]
# data list printed after popped its last element
data= [10,30,20,40,50]
print(data.pop(2)) #pop() function with index position
print(data)
Output:
20 # pop () returns the popped value
[10,30,40,50]
# data list printed after popped its element of particular
index position.
list.remove (item/element) data=[10,30,20,25,30,40]
data.remove(30) #element 30 at index position 1, 4
print(data)
output:
[10, 20, 25, 30, 40]
# remove the first occurrence of a specified value from the
list
list.clear () data=[10,30]
data.clear()
print(data)
output:
[]
# empty list will be displayed after implanting clear method
Multiple Choice Questions

Suppose
1. list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after execution of list1.pop
(1)?
1.
a) [3, 4, 5, 20, 5, 25, 1, 3] b) [1, 3, 3, 4, 5, 5, 20, 25]
c) [3, 5, 20, 5, 25, 1, 3] d) [1, 3, 4, 5, 20, 5, 25]

50 | P a g e
2. Suppose a list mylist is [10,23,45,3,34,50], what is mylist after execution of
mylist.remove(3)
a) [10, 23, 3, 34, 50] b) [10, 23, 45, 34, 50]
c) [10, 23, 3, 34, 50] d) No output
3. Consider the following code and predict the output
mylist = [2,3,8,9,3]
mylist.append([2,4])
print(mylist)
a) [2, 3, 8, 9, 3, 2, 4, [2, 4]] b) [[2, 4], 2, 3, 8, 9, 3, 2, 4]
c) [2, 3, 8, 9, 3, ,2, 4, 2, 4] d) [2, 3, 8, 9, 3, [2, 4]]
4. Consider a list mylist with n elements, in mylist.pop() what is the default index
a) 1 b) 0
c) -1 d) 4
5. What is the output when we execute?
print(list(“hello”))
a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] b) [‘hello’]
c) will not create a list d) [‘h,e,l,l,o’]
6. Which of the following commands will create a list?
a) listl = list( ) b) listl = [ ]
c) listl = list([1, 2, 3]) d) all of these
Answer (Multiple Choice Questions)
1. c) [3, 5, 20, 5, 25, 1, 3]
2. b) [10, 23, 45, 34, 50]
3. d) [2, 3, 8, 9, 3, [2, 4]]
4. c) -1
5. a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
6. d) all of these
Assertion and Reasoning Questions

Choose correct option for given Assertion (A) and Reasoning (R)
a) Both A and R are true, and R is the correct explanation of A.
b) Both A and R are true, but R is not the correct explanation of A.
c) A is true, but R is false.
d) A is false, but R is true.
1. Assertion (A): Lists in Python are mutable.
Reason (R): We can modify, add, or remove elements from a list after its creation.
2. Assertion (A): A list in Python can contain another list as its element.
Reason (R): Python does not allow different data types inside a list.

Answer(Assertion and Reasoning Questions)

1 Answer: a) Both A and R are true, and R is the correct explanation of A.

51 | P a g e
2 Answer: c) A is true, but R is false.

Short Questions with Answer

1. Write a python code to read a list of numbers and print all even numbers from the
list.
Answer:
xlist=eval(input("enter elements"))
for i in xlist:
if i%2==0:
print(i)

Output :
enter elements [1,2,3,8,9]
2
8
2. Write a python code to read a list and replace all even elements with 0 and odd with 1
Answer:
xlist=eval(input("enter elements"))
for i in range(len(xlist)):
if xlist[i]%2==0:
xlist[i]=0
else:
xlist[i]=1
print(xlist)
output:
enter elements[2,5,7,98,0,7]
[0, 1, 1, 0, 0, 1]
3. Predict the output of the following code: -
Moves=[11, 22, 33, 44]
Queen=Moves
Moves[2]+=22
L=len(Moves)
for i in range (L):
print (“Now@”, Queen[L-i-1], “#”, Moves [i])
Answer:
Now@ 44 # 11
Now@ 55 # 22
Now@ 22 # 55
Now@ 11 # 44

4. Consider the following list myList. What will be the output of the code after executing of
below code:
myList = [10,20,30,40]
myList.append([50,60])
d=myList.pop(2)

52 | P a g e
print(d)
print(myList)
Answer:
30
[10, 20, 40, [50, 60]]

Unsolved Questions (Test your understanding)


1. Read a list and display all elements ends with 5.
2. Read a list and count the occurrence of 5 in the list.
3. Read list and remove last element.
4. Read a list and print all positive numbers from the list
5. Read a list and display elements along with index
6. Write python code to read a list lst and copy all the negative numbers from the list
lst to another list lst_neg
7. Read a list and add 2 to all even elements in the list and display the updated list.
8. Write the output of the following code:
xylist=[2,3,5,4,56,0,-1]
xylist.pop()
xylist.pop(-1)
xylist.insert(2,4)
print(len(xylist))
print(xylist)
9. What will be the output of the following code:

list1 = [12,32,65,26,80,10]
list1.sort()
print(list1)
10. What will be the output of following code
myList = [1,2,3,4,5,6,7,8,9,10]
newlist=[]
for i in range(len(myList)):
if i%2 == 0:
newlist.insert(i,myList[i])
print(newlist)

Dictionary in Python
Mind Map:

53 | P a g e
The data type dictionary falls under mapping. It is a mapping between a set of keys and a set of
values. The key-value pair is called an item. A key is separated from its value by a colon (:) and
consecutive items are separated by commas. Items in dictionaries are unordered,
A dictionary is an unordered sequence of key-value pairs.
Key and value in a key-value pair in a dictionary are separated by a colon. Further, the key:
value pairs in a dictionary are separated by commas and are enclosed between curly
parentheses.
● The keys of the dictionaries are immutable types such as Integers or Strings etc.
● Indices in a dictionary can be of any immutable type and are called keys.
● The values of a dictionary in Python are mutable.

Creating Dictionaries
A Dictionary can be created in three different ways:

1. Empty Dictionary using empty { }


D = { } # Empty Dictionary

2. Dictionary using literal notation


D = {"Name": "Mohan", "Class": "XI", "City": "Gurdaspur"}
print(D)

3. Dictionary using dict() function


Dict() function is used to create a new dictionary with no items. For example,
Months = dict() # Creates an empty dictionary
print(Month) # Prints an empty dictionary

We can use Square Brackets [ ] with keys for accessing and initializing dictionary values.
For Example:
Months[0] = ‘January’
Months[1] = ‘February’
Months[2] = ‘March’
print(Months)
output: {0 : 'January', 1: 'February' , 2 : 'March'}

Months = dict(Jan = 31, Feb = 28, March = 31)


# Creating dictionary by giving values in dict() function
print(Months)
output: {'Jan': 31, 'Feb': 28, 'March': 31}

Accessing Elements of a Dictionary


Elements of Dictionary may be accessed by writing the Dictionary name and key within square
brackets ([ ] ) as given below:
D = {0 : "Sunday", 1 : "Monday", 2: "Tuesday"}
print(D[1])

output: Monday

***Attempting to access a key that does not exist, causes an error.

54 | P a g e
Traversing a Dictionary:
Dictionary items can be accessed using a for loop.

output:
Apple
Boy
Cat
Adding an Element in a Dictionary
We can add new element (key : value pair) to a dictionary using assignment, but the key being
added must not exist in dictionary and must be unique.

d["D"]="Dog" # if a new key is given, new item is added


print(d)

output: {'A': 'Apple', 'B': 'Boy', 'C': 'Cat', 'D': 'Dog'}

A new key ‘D’ added in to the dictionary d

Updating / Modifying an element in Dictionary


We can change the individual element of dictionary as given below:

d["A"]="Android" # Value of Key (“A”) is changed


print(d)

output: {'A': 'Android ', 'B': 'Boy', 'C': 'Cat', 'D': 'Dog'}

Dictionary Methods and Built-in Functions

Function Syntax Description


dict() dict() Creates a dictionary from a sequence of key-
value pairs
len() len (dictionary) function: It is used to find the length of the
dictionary, i.e., the count of the key : value pair.
keys() dictionary.keys() Returns a list of keys in the dictionary
values() dictionary.values() Returns a list of values in the dictionary
items() dictionary.items() Returns a list of tuples(key – value) pair
update() dictionary.update(iterable) appends the key-value pair of the dictionary
passed as the argument to the key-value pair of

55 | P a g e
the given dictionary
del del Dict_name Deletes the item with the given key or to delete
the dictionary from the memory.
del dictionary[key]
clear() dictionary.clear() Deletes or clear all the items of the dictionary

Dictionary functions with examples:


Function Examples output
dict() d=dict() {}
print(d)
dates=dict([['Jan',31], {'Jan': 31, 'Feb': 28, 'March': 31}
['Feb',28], ['March',31]])
print(dates)
len (dictionary) dates={'Jan': 31, 'Feb': 28, 3
'March': 31}
print(len(dates))

Method Examples output


dictionary.keys() dates={'Jan': 31, 'Feb': 28, dict_keys(['Jan', 'Feb', 'March'])
'March': 31} Returns a list containing the
print(dates.keys()) dictionary's keys
dictionary.values() dates={'Jan': 31, 'Feb': 28, dict_values([31, 28, 31])
'March': 31} Returns a list of all the values in
print(dates.values()) the dictionary
dictionary.items() dates={'Jan': 31, 'Feb': 28, dict_items([('Jan', 31), ('Feb', 28),
'March': 31} ('March', 31)])
print(dates.items()) returns a list containing a tuple
for each key value pair
dictionary.update dates={'Jan': 31, 'Feb': 28, {'Jan': 31, 'Feb': 29, 'March': 31}
(iterable) 'March': 31}
dates.update({'Feb':29})
print(dates)
dates={'Jan': 31, 'Feb': 28, {'Jan': 31, 'Feb': 28, 'March': 31,
'March': 31} 'April': 30}
dates.update({'April':30}) # ‘April’ Key not exist in dates so
print(dates) new key ‘April’ added in to the
dictionary
del Dict_name d={1:"One",2:"Two"} Removes entire dictionary
del d #print statement will cause an
print(d) error because ‘d’ dictionary no
longer exists.
del dates= {'Jan': 31, 'Feb': 28, Before removal
dictionary[key] 'March': 31} {'Jan': 31, 'Feb': 28, 'March': 31}
print ("Before removal") After removal
print(dates) {'Jan': 31, 'Feb': 28}
del dates["March"]
print ("After removal") #will delete particular key from

56 | P a g e
print(dates) a dictionary

dictionary. clear() d={"A":"An","Is":"Are"} {}


d.clear() Removes all the elements from
print(d) the dictionary

Note: if single key:value pair is to remove from a dictionary then pop() and popitem()
method of dictionary can be used

Checking existence of a key in a dictionary


To check if a key is present in the dictionary or not we can use the in operator – if the given
key is present in the dictionary, it returns True, otherwise it returns False.
e.g.: Consider the dictionary:
dates= {'Jan': 31, 'Feb': 28, 'March': 31}

'Feb' in dates # returns True


'FEB' in dates # returns False
'FEB' not in dates # returns True
Multiple Choice Questions

1 Dictionaries are...................... set of elements.


a) sorted b) Ordered c) unordered d) random
2 What would the following code print?
d= {"Banana": "Yellow", "Orange": "Orange", "Papaya": "Orange"}
print(d["Orange"])
a) Yellow b) Orange c) Papaya d) Banana
3 What would the following code print?
dates={'Jan': 31, 'Feb': 28, 'March': 31, ‘Feb’:29}
print(len(dates))
a) 1 b) 4 c) 3 d) 0
4 dates={'Jan': 31, 'Feb': 28, 'March': 31, 'feb':29}
print(len(dates))
a) 1 b) 4 c) 3 d) 0
5 Which of the following statements create a dictionary?
i) d = {}
ii) d1 = dict([["john",40],[ "peter",45]])
iii) d2 =dict(1,2,4,5)
a) Only i b) Only ii c) Both i and ii d) all (i, ii, iii)
6 Which of these about a dictionary is false?

57 | P a g e
a) The values of a dictionary can be accessed using keys
b) The keys of a dictionary can be accessed using values
c) Dictionaries store data as key : value pair
d) Dictionaries are mutable

7 Given the following dictionary


Day={1:"Monday", 2: "Tuesday", 3: "Wednesday"}
Which statement will be used to delete a value ‘Tuesday’
a) del Day b) del Day[1] c) del Day[2] d) del Day[‘Tuesday’]
8 Identify the invalid Python statement from the following:
a) d = dict() c) f =dict([('Name', 'Sahil')])
b) e = {} d) g= dict{}
9 State True or False :
“In Python, Dictionary is a mutable data type”.
Answer (Multiple Choice Questions)
1 c) unordered
2 b) Orange
3 c) 3
4 b)4
5 c) Both i and ii
6 b) The keys of a dictionary can be accessed using values
7 b) del Day[2]
8 d) g=dict{}
9 True
Assertion and Reasoning Questions
Choose correct option for given Assertion (A) and Reasoning (R)
a) Both A and R are true, and R is the correct explanation of A.
b) Both A and R are true, but R is not the correct explanation of A.
c) A is true, but R is false.
d) A is false, but R is true.
1. Assertion (A): Dictionaries in Python are mutable.
Reason (R): Items in a dictionary can be added, removed, or updated after creation.
2. Assertion (A): Dictionaries are enclosed within curly braces { }.
Reason (R): The key-value pairs are separated by commas (,).
Answer(Assertion and Reasoning Questions)

1 a) Both A and R are true, and R is the correct explanation of A


2 b) Both A and R are true but R is not the correct explanation of A

Short Questions with Answer

58 | P a g e
1. Rita is a student of class XI. Help her to create a dictionary to store details of 10
employees given by the user. Each element consists of empcode as key, name
and salary as values.

Answer:
emp={}
for i in range(10):
l=[]
empcode=int(input("enter emplyee code"))
name=input("enter name")
salary=int(input("enter salary"))
l.append(name)
l.append(salary)
emp[empcode]=l
print(emp)

2. Consider the following dictionary and print the name and salary of employees in
“computer” department.
{ "anil":["computer",10000],
"anju":["History",5000],
"somu":["computer",11000],
"sam":["English",8000] }

Answer:
data={"anil":["computer",10000], "anju":["History",5000],
"somu":["computer",11000], "sam":["English",8000] }
for key, value in data.items():
if value[0]=="computer":
print(key , value[1])

Unsolved Questions (Test your understanding)


1. The dictionary empdat contains employee records with the following values
{1 :[ "Raj " ,85000], 2: ["Sathya ", 20000], 3: ["Meenu ",89000]}
Write a Python program to display only the records where the employee’s salary
exceeds 75000.
2. The dictionary students stores students name and their marks:

59 | P a g e
students = {
"A101": ["Ravi", 88],
"A102": ["Divya", 76],
"A103": ["Kiran", 95],
"A104": ["Neha", 65]}
Write a Python program to display the name and marks of students who scored
more than 80
3. Write python code to create dictionary to store the following details of 10
products
{Productno: [Product name, price, quantity]}
4. Write the Python statement for the following tasks using built-in
functions/methods only:
To remove the item whose key is "NISHA" from a dictionary named Students.
For example, if the dictionary Students contains
{ "ANITA":90, "NISHA":76, "ASHA":92)
After removal, the dictionary should contain {"ANITA":90, "ASHA":92}

60 | P a g e
Introduction to NumPy
Introduction, Creation of NumPy Arrays from List

NumPy (“Numerical Python” or Numeric Python”) is a package / module for data


analysis, specially used for scientific analysis of data with Python. NumPy provides different
functions for fast mathematical computation on arrays, matrices and on multi-dimensional
arrays.
To make array using NumPy in Python, need to install a NumPy. NumPy is an open-source
python library that can be installed using Python packages like pip.

To install NumPy in Python, use the pip package on command line and choose the
absolute path of location, where python is installed.
pip install numpy
NumPy is a library in Python which can be imported in a program by using import command
as
import numpy as np
Array: Group or collection of similar type of elements.
Eg. Scores of players in a cricket match, Marks of students in a class

NumPy Array: A grid contains value of same type (homogeneous elements) and uses Zero
based indexing, like lists in Python. NumPy Array also known as ndarray

Difference between List and Array:


• Arrays only hold data of same data type, while list can hold the data of mixed data types
(like int, float etc)
• Using of Arrays to store data is more memory efficient and help to perform fast
calculation and operations.
• List is a part of core python , Array/ndarray is a part of NumPy Library

Creation of NumPy Arrays from List:

NumPy Arrays are grid-like structures similar to lists in Python but optimized for numerical
operations. NumPy array can be created by converting a regular Python list into an array
using the np.array() function. This function returns ndarray object. Once the NumPy array
is defined, the space it occupies in memory is fixed and cannot be change.
Ndarray is one of the most important classes in the NumPy python library. It is basically a
multidimensional or n-dimensional array of fixed size with homogeneous elements (i.e., the
data type of all the elements in the array is the same). A multidimensional array looks
something like this:

61 | P a g e
Axes: Axes are defined for arrays with more than one dimension. A 2-dimensional array has
two corresponding axes: the first running vertically downwards across rows(axis 0), and the
second running horizontally across columns (axis 1). Many operations can take place along
one of these axes.
Rank: The no. of axes in a ndarray is called its rank.
Creation of NumPy array using List

Example: Python Code

Types of Arrays:
• 1-D Array: A single row of elements.
• 2-D Array: A matrix with rows and columns
1) 1D NumPy array creation -> Using List:

2) 2D NumPy Array creation -> Using list:


A list of lists i.e. nested list will create a 2D Numpy array, similarly, you can also create
N-dimensional arrays.

Attributes of Numpy array:


SNo. Attribute Syntax Example
1 Shape <ndarrayname>.shape
A tuple of integers giving
the size of the array along
each dimension. (no. of
element along each axis of
the array)

62 | P a g e
2 Size <ndarrayname>.size
Total no. of elements in the
array

3 Datatype <ndarrayname>.dtype
(dtype): Type of data stored in the
array

4 ItemSize: <ndarrayname>.itemsize
Size of each element of
ndarray in bytes

5 ndim <ndarrayname>.ndim
It returns an integer
representing the number
of dimensions.

Creating arrays with specific values:


method Description Example
numpy.zeros() This function creates an >>> a1=np.zeros((2,3))
array filled with zeros. It >>> a1
requires the shape of the array([[0., 0., 0.],
array as a parameter. [0., 0., 0.]])
>>> a2=np.zeros((4,))
>>> a2
array([0., 0., 0., 0.])
numpy.ones() This function creates an >>> a3=np.ones((2,3))
array filled with ones. It >>> a3
requires the shape of the array([[1., 1., 1.],
array as a parameter. [1., 1., 1.]])
>>> a4=np.ones((2,))
>>> a4
array([1., 1.])
numpy.arange() It creates an array of evenly >>> ar=np.arange(5,10)
spaced values within a given >>> ar
interval. It is similar to array([5, 6, 7, 8, 9])
Python's built-in range() >>> ar2=np.arange(5)
function but returns a >>> ar2
NumPy array instead of a array([0, 1, 2, 3, 4])
list. >>>ar3=np.arange(5.5,
numpy.arange([start, 10.5,2,dtype='float64')
]stop, [step,] dtype = None) >>> ar3
array([5.5, 7.5, 9.5])
numpy.full() Return a new array with the >>>ar1=np.full((2,2),5,dtype='int')
same shape and type as a >>> ar1
given array filled with a array([[5, 5],
fill_value. Parameters [5, 5]])

63 | P a g e
numpy.full(shape, fill_value, >>>ar2=np.full((4,),1.5, dtype='float')
dtype = None) >>> ar2
array([1.5, 1.5, 1.5, 1.5])

Multiple Choice Question and Fill in the Blanks


1 What does NumPy stand for?
(a) Number Platform (b) Numerical Python
(c) Numeric Python (d) Number Picture
2 Array object in NumPy called ____________
(a) number array (b) Narray (c)numpy Array (d)ndarray
3 NumPy is open source in python (true/ false)
4 Follow the below code :
arr = np.array([[1, 2, 3,4], [4, 5, 6,7]])
Find out the dimensions it has.
(a) 1 (b) 2 (c) 3 (d) 4
5 Fill the blanks in the below python code and underline it.
import numpy as _______
Array=np.____________([1,2,3,5,6])
print(Array)
6 Which attribute of NumPy array is used to find out the number of dimensions?
(a) ndimn (b) ndim (c) ndimensions (d)ndarray
7 When this python code will execute, then which output will come?
import numpy as np
L1=[1,2]
L2=[3,4]
arr = np.array([L1, L2])
print(arr[1, 0])

(a) 1 (b) 2 (c) 3 (d) 4


8 from the below python code display the value of first element of array and
display number 35 from an array
import numpy as np
Array=np.array([3,6,9,12,15,18,36,35,38])
print(Array[ ],Array[ ])

(a) [1],[7] (b) [1],[8] (c) [0],[8] (d)[0],[7]


9 Find the output of the below code:
import numpy as np
Array=np.array([3,6,3,3,15,18,36,35,38])
print (Array [ :4])

64 | P a g e
(a) [3 6 3 3] (b) [3,6,3,3,15] (c) [3,6,3,3] (d)[3,15,18,36,35,38]
10 Which of the following is correct way to import the Numpy module in your
program?
(a) import numpy (b) import numpy as np
(c) from numpy import * (d) All of the above
11 What will be the output of following code?
import numpy as np
A=np.array([24,46,57,14,68,34,89,92])
print(A[7:3:-1])
print(A[2:6])
a) [92 89 34 68] b) [92 34 89 68]
[57 14 68 34] [14 57 68 34]

c) [92 68 34 89] d) [92 34 68 89]


[14 68 57 34] [34 14 68 57]
12 Find out the Correct Statement:
(a) Python List occupy less space than a NumPy array.
(b) NumPy array can contain elements of non-homogenous type.
(c) We cannot change the size of NumPy array after the store in memory
(d) All of the above.
Answer (Multiple Choice Question and Fill in the Blanks)
1 (b) Numerical Python
2 (d) ndarray
3 True
4 (b) 2
5

6 (b)ndim
7 (c) 3 Explanation: arr value will be

print(arr[1,0]) To access elements from 2-D arrays we can use comma separated
integers representing the dimension and the index of the element.
8 (d) [0],[7]
9 (a) [3 6 3 3]
Explanation: print (Array [ :4]) This statement starts printing element from index
position 0 and will print upto index position 4-1=3 as its increment by 1 (default
increment).
10 (d) All of the above
11 (a)

Explanation: print (A [7:3: -1]) This statement starts printing element from index

65 | P a g e
position 7 and display upto index position (3-(-1))=4 as its decrement by -1
12 (c) We cannot change the size of NumPy array after the store in memory.

Assertion and Reasoning Questions:


Choose correct option for given Assertion (A) and Reasoning (R)
a) Both A and R are true, and R is the correct explanation of A.
b) Both A and R are true, but R is not the correct explanation of A.
c) A is true, but R is false.
d) A is false, but R is true.

1 Assertion(A): NumPy is an open-source numerical python library. NumPy


contain a multi-dimensional array and matrix data structure
Reason(R): Array contain set of homogeneous values stored under one name.
Array can be one dimensional, 2 D or multi-dimensional
2 Assertion(A): in python list values are separated by comma but in NumPy array
value are separated by space at the time of display of value. It only used for
distinguish purpose.
Reason(R): both consume same size of memory
3 Assertion(A): for creating a list import of NumPy is required and for creating
ndarray import NumPy library is not required
Reason(R): ndarray cannot be created without importing NumPy but list can be
creating without importing NumPy library
Answer(Assertion and Reasoning Questions)
1 (a) Both A and R are true, and R is the correct explanation of A.
2 (b) Both A and R are true, but R is not the correct explanation of A.
3 (d) A is false, but R is true.

Short Questions with Answer

1 What is the difference between Array and List


Answer:
Difference between List and Array:
• Arrays only hold data of same data type, while list can hold the data of
mixed data types (like int, float etc)
• Using of Arrays to store data is more memory efficient and help to perform
fast calculation and operations.
• List is a part of core python, Array/ndarray is a part of NumPy Library
• List take more space and more time of memory to store the elements
because of different data types but Array takes less time and less space of
memory to store elements because of same data type of elements of Array
2 How to create an Array of list in python using NumPy? Explain with suitable
example.

66 | P a g e
Answer:
NumPy Arrays are grid-like structures similar to lists in Python. NumPy array
can be created by converting a regular Python list into an array using the
np.array() function.
import numpy as np
List1= [10,50,90,130]
Arr1=np.array(List1)
print (List1) # will display list [10,50,90,130]
print (Arr1) # will display array of list [10 50 90 130]
3 What is an ndarray. What is use of Array in python code.
Answer:
Ndarray is one of the most important classes in the NumPy python library. It is
basically a multidimensional or n-dimensional array of fixed size with
homogeneous elements (i.e., the data type of all the elements in the array is the
same)
Example

in this example 1-D array shape size is


(1,4) and 2-D array shape size is (2,3)

4 Write a program to make 1-D array and 2-D array list

Answer:

5 What are some of the advantages of using NumPy arrays over Python lists?
Answer:
NumPy arrays offer several advantages, including: faster performance for
numerical operations due to vectorization, more efficient memory usage, and a
wide range of mathematical functions and operations. Array also helpful in
Optimize the data that help CPU to perform operation accurately and effectively.
NumPy is designed for data analysis and manipulation, offering a wide range of
functions for sorting, searching, and statistical analysis.
6 Given a list L=[1,2,3,4] and an ndarray N having elements [1 2 3 4] . What will be
the result produced by the following statements?
(a) L*2 (b) N*3 (c) L+L (d) N+N
Ans:
(a) [1,2,3,4,1,2,3,4]
(b) [3 6 9 12]

67 | P a g e
(c) [1,2,3,4,1,2,3,4]
(d) [2 4 6 8]

Case Based Question with Answer


1 store the following data:
2.5 19 0
3.4 18 7
10.5 19.2 5
(a) Use nested Python lists to create a 2-D array called array1 having 3 rows
and 3 columns and
(b) Write python code and find the size of the array1
(c) Write python code to find the datatype that store the elements in to the
memory
(d) Write python code to find out the shape of the nested list as per the list
elements in array 1
Answer: (a)
Python code Output
(a) import numpy as np [[ 2.5 19. 0. ]
array1=np.array([[2.5,19,0],[3.4,18,7],[10.5,19.2,5]]) [ 3.4 18. 7. ]
print(array1) [10.5 19.2 5. ]]
(b) print(array1.size) 9
(c) print(array1.dtype) float64
(d) print(array1.shape) (3, 3)

68 | P a g e
UNIT 3: DATABASE CONCEPTS
Mind Map

Database
A database is an organized collection of data that can be easily accessed, managed, and
updated.
A database helps us to store our data in the permanent memory

DBMS
A database management system (DBMS) or database system in short, is a software that can be
used to create and manage databases.
DBMS lets users to create a database, store, manage, update/modify and retrieve data from
that database by users.
Some examples of DBMS are MySQL, Oracle, PostgreSQL, SQL Server, Microsoft Access,
MongoDB.

RDBMS
RDBMS stands for Relational DBMS
Different types of DBMS are available and their classification is done based on the underlying
data model.
There are three Data Models : Hierarchical, Network, and Relational.
A data model describes the structure of the database, including types of data, relationship
between the data and rules(constraints) on data.

69 | P a g e
The most commonly used data model is Relational Data Model.

Advantages of a database

1. Reduced Data Redundancy


Data is stored in one place and it is shared and thus avoids duplication.
2. Data Consistency
Centralized data updates ensure all users see the same, up-to-date information.
3. Data Integrity
Rules (otherwise known as constraints) ensure valid and accurate data (e.g., age of a
person is non-negative).
4. Improved Data Security
User access can be controlled (e.g., some users can only read, others can update).
5. Data Sharing
Multiple users and applications can access the data simultaneously without conflict.
6. Backup and Recovery
Automatic tools help recover data in case of failure or crashes.

TERMINOLOGY
DOMAIN It is a set of values from which an attribute can take a value in each
row. Usually, a data type is used to specify domain for an attribute.
TUPLE Each row of data in a relation (table) is called a tuple.
ATTRIBUTES Each column of a relation (table) is called an attribute
CARDINALITY The number of tuples in a relation is called the Cardinality of the
relation.
DEGREE The number of attributes in a relation is called the Degree of the
relation.
DATABASE Database Schema is the design of a database. It is the skeleton of the
SCHEMA database that represents the structure (table names and their
fields/columns), the type of data each column can hold, constraints
on the data to be stored (if any), and the relationships among the
tables.
Database schema is also called the visual or logical architecture as it
tells us how the data are organised in a database.
DATA Sometimes we put certain restrictions or limitations on the type of
CONSTRAINT data that can be inserted in one or more columns of a table. This is
done by specifying one or more constraints on that column(s) while
creating the tables.
META DATA The database schema along with various constraints on the data is
stored by DBMS in a database catalog or dictionary, called meta-data.
A meta-data is data about the data.
QUERY A query is a request to a database for obtaining information in a

70 | P a g e
desired way. Query can be made to get data from one table or from a
combination of tables.
DATABASE ENGINE Database engine is the underlying component or set of programs used
by a DBMS to create database and handle various queries for data
retrieval and manipulation.

Example :
Consider the student table given below:
StudentID Name Age Grade Mobile
101 Aman 14 A 9921245689
102 Ajay 15 B 9567231212
Name of relation: Student
Domain: In the above relation, the attribute StudentID takes integer values and hence its
domain is a set of integer values.
Degree: Degree of this table is 5 as it has 5 attributes (columns)
Name of attributes: StudentID, Name, Age, Grade, Mobile
Cardinality: Cardinality of this table is 2 as this table contains 2 tuples(rows/records) of data
Keys of a relation
Candidate A relation can have one or more attributes that takes distinct values.
Keys Any of these attributes can be used to uniquely identify the tuples in
the relation. Such attributes are called candidate keys
Primary Key Out of one or more candidate keys, the attribute chosen by the
database designer to uniquely identify the tuples in a relation is called
the primary key of that relation.
If no single attribute in a relation is able to uniquely distinguish the
tuples, then more than one attribute are taken together as primary
key. Such primary key consisting of more than one attribute is called
Composite Primary key
Alternate Key From the candidate keys, the attributes which are not chosen as
primary key are called Alternate key
Foreign Key A foreign key is used to represent the relationship between two
relations. A foreign key is an attribute whose value is derived from
the primary key of another relation.

For example- in below table following attributes(columns) RNO, UID, REGNO are candidate
keys, suppose we have chosen RNO as primary Key. Then the other two attributes (column)
UID, REGNO will become alternate key

Let’s understand the above-mentioned terms with the help of a Table

71 | P a g e
In the above table
1. There are 5 tuples (rows/ records), hence the CARDINALITY is 5
2. There are 6 Attributes and hence DEGREE is 6
3. RNO, UID AND REGNO are unique for each student and hence are eligible to become
Primary Key. They are CANDIDATE KEYS.
4. RNO is chosen as PRIMARY KEY
5. So UID & REGNO becomes ALTERNATE KEYS.

Example of Foreign Key: -


→It is a column or a set of columns in one table that refers to the primary key in another
table.
→It establishes and enforces a link between the data in two tables

In Patient table, the primary key of Doctor table is present, which helps us to link these two
tables. Hence DID in patient table is the Foreign Key.
Note:
The table whose primary key is present in another table, is known as parent table. Here in
the above example DOCTOR table is the parent table

The table in which, foreign key is present is known as the Child table. In the above example
PATIENT is the child table.

PID is the primary key of patient table.

72 | P a g e
Three Important Properties of a Relation
In relational data model, following three properties are observed with respect to a relation
which makes a relation different from a data file or a simple table.
Property 1: imposes following rules on an attribute of the relation :
⮚ Each attribute in a relation has a unique name.
⮚ Sequence of attributes in a relation is immaterial.
Property 2: governs following rules on a tuple of a relation.
⮚ Each tuple in a relation is distinct.
⮚ Sequence of tuples in a relation is immaterial.

Property 3: imposes following rules on the state of a relation.


⮚ All data values in an attribute must be of same data type
⮚ Each data value associated with an attribute must be atomic
⮚ No attribute can have many data values in one tuple.
⮚ A special value “NULL” is used to represent values that are unavailable or
not applicable or not known at the moment.
Structured Query Language
Database management systems there are special kind of programming languages called query
language that can be used to access data from the database.
The Structured Query Language (SQL) is the most popular query language used by major
relational database management systems such as MySQL, ORACLE, SQL Server, etc.

Features and Advantages of SQL


⮚ SQL (Structured Query Language) was invented by Donald D. Chamberlin and
Raymond F. Boyce in the early 1970s at IBM.
⮚ SQL uses simple, English-like syntax
⮚ SQL is supported by all major RDBMS platforms, making it portable across systems with
little to no change.
⮚ SQL is not case sensitive
⮚ SQL statements ends with semi colon ( ; )

Categories of SQL commands


The SQL commands can be classified mainly into 3 categories:
• Data Definition Language
• Data Manipulation Language
• Data Query Language

73 | P a g e
Data Definition Language (DDL):
The structure of a relation consists of the number of attributes, their data types, keys and
constraints that we keep on the values of attributes.

The commands used for creating, modifying or deleting the structure of a relation are called
DDL commands

Example: CREATE TABLE, ALTER TABLE, DROP TABLE

Data Manipulation Language (DML):


The data of a relation(table) is contained in the rows/records.
The commands used to create, modify or delete rows/records in a relation are called DML
commands.
Example: INSERT INTO, UPDATE, DELETE FROM
Data Query Language (DQL):
Data Query Language (DQL) is a subset of SQL used only for querying data from a database.
It focuses on retrieving information without changing the data.
Example: SELECT

DATATYPES IN MYSQL
The various datatypes of MySQL are
1. INT OR INTEGER :
A medium integer. Signed range is from -2147483648 to 2147483647. Unsigned
range is from 0 to 4294967295.
2. FLOAT:
A floating-point number.
Syntax: FLOAT (SIZE, D)
The total number of digits is specified in size. The number of digits after the
decimal point is specified in the d parameter.
Example: FLOAT (10,2) means total size 10 out of that 2 digits are in the decimal
part.
3. DATE:
Takes date in the form of ‘YYYY-MM-DD’.
The size of DATE datatype is fixed(10bytes).
4. CHAR:
It is FIXED length string (can contain letters, numbers, and special characters).
The size can be from 0 to 255. Default is 1
5. VARCHAR:
It is Variable length Character (can contain letters, numbers, and special
characters). The size can be from 0 to 65535
Note:

74 | P a g e
1. MySQL commands are case insensitive.
2. All the commands in MySQL should be terminated by ; (semicolon)

CREATE COMMAND
This command is used to create a database/table /view.
Syntax:
Create database <databasename>;
Note:
Once a database is created, we have to use it. To use a database the command is
USE <databasename>;
Example:
mysql> create database SCHOOL;

mysql>use SCHOOL;

CREATING A TABLE:
SYNTAX:
CREATE TABLE <TABLENAME> (FIELD1 DATATYPE(SIZE), FIELD2 DATATYPE
(SIZE)……………..);
Example:
CREATE TABLE STUDENT (RNO INT (5), NAME VARCHAR (20), CLASS CHAR (3), MARKS INT
(3));

DESC command
To see the structure of a table we use the command DESC (describe)
DESC <tablename>;
DESC STUDENT;

Multiple Choice Questions

1 A relation has 10 rows and 5 columns. What will be its degree and cardinality?
(a) Degree: 10, Cardinality: 5 (b) Degree: 15, Cardinality 10

75 | P a g e
(c) Degree: 5, Cardinality: 10 (d) Degree: 5 , Cardinality: 15
2 There are 5 candidate keys and one primary key in a table. How many alternate
keys are there in that table?
a) 3 b) 4 c) 5 d) 6
3 A non-key attribute, whose values are derived from primary key of some other
table.
a) Alternate key b) Foreign key c) Primary key d) Super Key
4 Pick the odd one out.
a) Update b) Delete c) Create d) Insert
5 Which of the following is not an example of DBMS?
a) MySQL b) Microsoft Access c) IBM DB2 d) Google
6 The default date format in MySQL is:
a) DD/MM/YYYY b) YYYY-MM-DD
c) MM-DD-YYYY d) YYYY/MM/DD
7 SQL stands for
a) Standard Query Language b) Structured Query Language
c) Standard Question Language d) Simplified Query Language
8 The attributes of a relation which are unique in their values and which are
eligible to become primary key are called
a) Alternate Key b) Foreign Key c) Candidate Key d) Eligible Key
9 Which of the following best describes a primary key?
a) A key that can accept null values
b) A key that uniquely identifies each record in a table
c) A duplicate value identifier d) A key used to join two tables
10 How many candidate keys can a table have?
a) Only one b) Zero c) One or more d) Exactly two
11 A foreign key in one table refers to:
a) A primary key in the same table b) A duplicate value in another table
c) A primary key in another table d) A unique constraint in any table
12 Which of the following is a DDL command?
a) SELECT b) UPDATE c) CREATE d) INSERT
13 Which statement is used to modify the structure of an existing table?
a) CHANGE b) ALTER c) UPDATE d) MODIFY
14 Which of the following is a DML command?
a) CREATE b) SELECT c) DROP d) DELETE
15 The SELECT statement in SQL is classified under:
a) DML b) DDL c) DCL d) DQL
16 What is the purpose of DQL in SQL?
a) Query and retrieve data b) Control access to data
c) Define data structure d) Delete data
17 DBMS stands for
a) Data Borrowing and Movement Software b) Database Management System
c) Digital Base Mapping System d) Database Manipulation Software

76 | P a g e
Answer (Multiple Choice Questions)

1 (c) Degree: 5, Cardinality: 10

2 (b) 4 Alternate Keys


3 (b) Foreign key
4 (c) Create
5 (d) Google
6 (b) ‘YYYY-MM-DD’
7 (b) Structured Query Language
8 (c)Candidate Key
9 (b)A key that uniquely identifies each record in a table
10 (c)One or more
11 (c) A primary key in another table
12 (c) CREATE
13 (b)ALTER
14 (d) DELETE
15 (d)DQL
16 (a) Query and retrieve data
17 b) Database Management System
Fill in the Blanks (Questions)
1 ______________ is a collection of data arranged in the form of rows and columns.
2 A row in a relation(table) is known as ______________
3 A Column in a relation(table) is known as __________
4 The number of Tuples in a relation(table) is known as _____________
5 The number of attributes in a relation(table) is known as __________
6 Columns which are eligible to become a primary key are known as ____ keys.
7 The column value that uniquely identifies a row in a relation(table) is known as
______key.
8 The command that can be used to start working on an already existing database
is _______
9 Collection of logically related records is called ______
10 The file that contains description about the data stored in database is called _____
Answer (Fill in the Blanks -Questions)
1 Relation /Table
2 Tuple

77 | P a g e
3 Attribute
4 Cardinality
5 Degree
6 Candidate Keys
7 Primary Key
8 use
9 Database
10 Metadata

Assertion and Reasoning Questions


Choose correct option for given Assertion (A) and Reasoning (R)
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false. d) A is false but R is true.
1 Assertion (A): Each table must have one primary key.
Reason (R): Primary key is a set of one or more attributes that uniquely
identifies a tuple in a relation.
2 Assertion (A): The number of columns in a relation is called the degree of the
relation.
Reason (R): The number of tuples in a relation is called the cardinality of the
relation
3 Assertion (A): Database management system is an application software which
arranges data in a well-organized manner in the form of tables.
Reason (R): DBMS acts as an interface between the database stored in the
computer memory and the user.
4 Assertion (A): SQL has efficient mechanisms to retrieve data stored in multiple
tables in a MySQL database.
Reason (R): The SQL statement CREATE is used to retrieve data from the tables
in a database and is also called query statement.
5 Assertion (A): Data redundancy may lead to data inconsistency.
Reason (R): When redundant data or the multiple copies of data mismatch, it
makes the data inconsistent.
6 Assertion (A): A DBMS helps in maintaining data integrity and reduces
redundancy.
Reason (R): A DBMS stores data in multiple independent files without any
relationships.
7 Assertion (A): An RDBMS organizes data into tables with rows and columns.
Reason (R): Tables in RDBMS use relationships through keys to ensure data is
logically connected.
8 Assertion (A): A table can have multiple candidate keys.
Reason (R): There may be many attributes in a table which contain unique
values.
9 Assertion (A): The SELECT statement is used to modify data in a table.
Reason (R): SELECT is part of the Data Query Language (DQL).

78 | P a g e
10 Assertion(A): A foreign key can have duplicate values.
Reason (R) : A foreign key establishes a relationship between two tables and
does not require uniqueness.

Answer (Assertion and Reasoning Questions)


1 (a) Both A and R are true and R is the correct explanation of A.
2 (b) Both A and R are true but R is not the correct explanation of A.
3 (a) Both A and R are true and R is the correct explanation of A.
4 (c) A is true but R is false
5 (a) Both A and R are true and R is the correct explanation of A.
6 (c) A is true but R is false
7 (a) Both A and R are true and R is the correct explanation of A.
8 (a) Both A and R are true and R is the correct explanation of A.
9 (d) A is false but R is true.
10 (a) Both A and R are true and R is the correct explanation of A.

Short Questions with Answer

1 Sayuj wants to save data permanently in his system for data manipulation purposes. He
wants this data to be shared with his friends in a secure manner. Suggest him how a
database can be used for this purpose?
Answer: A database is an organized collection of data that can be easily accessed,
managed, and updated. A database helps us to store our data in the permanent memory.
A database management system helps many users to access the data and manipulate
data. So Sayuj can take the help of a DBMS software for this purpose.
2 Mention any two advantages of using a DBMS.
Answer: DBMS lets users create a database, store, manage, update/modify and retrieve
data from that database by users or application programs.
It reduces data redundancy and inconsistency. It ensures data integrity and maintains
standardization of data formats. It facilitates sharing of data
3 Ms Preetha, a teacher has written the details about students of 12A class in her register.
Similarly all the teachers teaching in Class 12A maintains separate registers having the
same data. Can you identify the problem in storing same data in multiple locations like
this ? Define the term 'data redundancy'. How does DBMS help to reduce it?
Answer: When the same data is stored in multiple locations like this, the data may
become inconsistent due to lack of proper updation of data. Storing the same data at
multiple locations causes duplication of data. This is called data redundancy. DBMS
facilitate sharing of data. So multiple users can work on the same data. This avoids data
redundancy and the problems caused due to data redundancy
4 Rohan wants to collect the date of birth of students of his class. He distributes a form to
all students for writing their date of birth. After observing the collected data, Rohan finds
that the students have written the date of birth in different formats. What is the problem

79 | P a g e
faced by Rohan Now? How can he overcome this problem?
Answer: Rohan finds it difficult to differentiate between date and month because some
of them have used DD-MM-YYYY format and others have used MM-DD-YYYY format.
Even the number of digits used for writing the year is different in different data. If Rohan
saves the data like this, he will find it difficult to manipulate it later. Rohan must have
used a standard format for collecting data.
DBMS can provide rules and constraints on data so that the data follows the same format
everywhere. Also the same data is shared with multiple users. Maintaining the
correctness of data is called Data Integrity
5 Explain what is a primary key?
Answer: The attribute chosen by the database designer to uniquely identify the tuples in
a relation is called the primary key of that relation. For example, in a student table,
admission number may be chosen as primary key as this data will not be repeated in the
column
6 Ramya is working with 2 tables in a database. She wants to retrieve data from both these
tables which are related with each other. How can she achieve this?
Answer: She must identify a common column which is present in both the tables. She
must set one of them as the foreign key. Foreign key is used to establish a connection
between 2 relations

7 Explain what is candidate key


Answer: All the attributes that are eligible to become primary key are called candidate
keys
8 Explain what is alternate key.
Answer: The candidate keys which are not selected as primary key are called alternate
keys
9 What is SQL?
Answer: SQL stands for Structured Query Language. All Database management
systems use a special kind of programming language called query language that can
be used to access data from the database. SQL is the most popular query language
10 Name any two DML commands in SQL
Answer: Insert and Update
11 Name any two DDL commands in SQL. Write the Syntax of Create Command.
Answer: Create table and Alter table

CREATE TABLE <TABLENAME> (FIELD1 DATATYPE(SIZE), FIELD2 DATATYPE


(SIZE)……………..);

12 Differentiate DDL and DML commands


Answer: Difference of DDL and DML
DDL DML

DDL stands for Data Definition DML stands for Data Manipulation
Language Language

80 | P a g e
DDL commands are used to modify DML commands are used to modify the
the structure of a relation data inside a relation
Eg: Create Table, Alter table, Drop Eg: Insert into, Update, Delete
table
13 What do you mean by cardinality and degree of a relation?

Answer: The number of tuple of a relation is called cardinality and the number of
attributes of a relation is called degree of the relation
14 Explain what is metadata?

Answer: Data about data is called metadata. It contains the structure (table names
and their fields/columns), the type of data each column can hold, constraints on the
data to be stored (if any), and the relationships among the tables.
15 Give any 2 features of MySQL.
Answer: MySQL is an RDBMS and is easy to use and Manage
It is an open-source software which is secure, reliable and can handle large volume
of data.
16 A database has two tables:
Students (StudentID, Name, ClassID) and Classes (ClassID, ClassName)
You need to relate students to their respective classes.
Which key should you use in the Students table to refer to the Classes table?
Answer: ClassID

Case Based Question:

Consider the following table Student:


Admnno Name Class Age Email
101 Anjali Gupta 10 15 [email protected]
102 Rohan Singh 10 14 [email protected]
103 Neha Sharma 11 16 [email protected]
104 Aman Verma 10 15 [email protected]
a. Which column in the STUDENT table is most suitable to be chosen as the Primary Key?
Why?
b. Which among the attributes have least chance to become a candidate key
c. While trying to add a new row: 102, “Rekha Gupta”, 11, 16, [email protected] the
DBMS is giving an error “duplicate entry”. What may be the reason?
d. Swayam wants to add details of new students but value of admission no (Admnno) is not
available, he has studied that if value is not available for an attribute NULL can be inserted.
But when he tried to insert new row with NULL value of Admnno, he gets an error. What
would be the reason for that.
Answer:
a. Admnno as it will not have duplicate values
b. Class and Age attribute cannot become candidate keys as both are having duplicate values
c. A tuple with Admnno 102 already exist in the table. And Admnno must have been chosen
as the Primary Key
d. Primary key applied on Admnno Column. No new record can be inserted in any table, if
value of Primary Key column is not given.

81 | P a g e
Data Query Language (DQL)
Mind Map:

Data Manipulation Language (DML)


Mind Map:

82 | P a g e
● Data Query Language (DQL) :
Data Query Language (DQL) is an element of SQL, which is used for retrieving data from
the database using the query supplied to it.
The main example of DQL is SELECT statement, which is used to get the data from one or more
database tables.
● SELECT is the primary command used to query and access the data without
altering it. The result of a SELECT against a table or tables is compiled into a separate
temporary table that the application, or perhaps a front-end, displays.
● 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

Table: sportsclub

GCode GameName Noofclubs Fees StartingDate


101 Carom 2 5000 2004-01-23
102 Badminton 2 12000 2003-12-12
103 Table Tennis 4 8000 2004-02-14
104 Chess 2 9000 2004-01-01
105 Lawn Tennis 4 25000 2004-03-19

▪ Selecting Columns: SELECT statement can be used in various ways and combinations to
retrieve subset of columns from one or more tables.

Purpose Syntax Command Output

1 Selecting SELECT * SELECT *


all FROM FROM
columns <table_name>; sportsclub;

83 | P a g e
2 Selecting SELECT SELECT
columns <column1, GameName,
column2,…> Fees FROM
FROM sportsclub;
<table_name>;

3 Reordering SELECT SELECT


columns in <column2, GameName,
Query column5, StartingDate,
result column4> Fees FROM
FROM sportsclub;
<table_name>;

▪ Selecting specific rows using SELECT command -Where clause:


● WHERE clause in SELECT statement is used to filter the data. It selects the specific rows
from a table based on the given condition.
* Syntax:

SELECT <column1, column2, …>


FROM <table_name>
WHERE <condition>;
⮚ Text Fields vs. Numeric Fields

SQL requires single quotes or double quotes around text values. However, numeric fields
should not be enclosed in quotes.

Purpose Query Command Output


1 Selecting Display all SELECT *
rows details from a FROM
based on table sportsclub sportsclub
numeric with GCode 101. WHERE
fields. GCode=101;

2 Selecting Display all the SELECT * FROM


rows details of chess sportsclub
based on from a table WHERE
text of a sportsclub. GameName=
fields ‘Chess’;
(column)

84 | P a g e
3 Selecting Show the SELECT
specific gamename and GameName,
columns fees from a table Fees FROM
of rows sportsclub with sportsclub
based on two noofclubs. WHERE
condition Noofclubs=2;
Use of Operators in WHERE Clause
⮚ Comparison Operators:
In the above example, we have used equal to (=) operator in the WHERE clause for exact match
conditions. We can also use other relational/comparison operators (<, <=, >, >=, ! =, < >) to
specify conditions other than exact match.
Operator Query Command Output

> display the name SELECT


(Greater of game, fees, GameName,
than ) noofclubs of Fees, Noofclubs
sportsclubs FROM
have charged fee sportsclub
more than WHERE
10000. Fees >10000;
<= display the game SELECT GCode,
(Less code, name of GameName,
than or game, starting startingDate
equal to) date from a table FROM
sportsclub, who sportsclub
have started on or WHERE
before 1st Jan startingDate <=
2004. ’2004-01-01’;
<> display all rows SELECT * FROM
(Not from the sportsclub
Equal to) sportsclub table WHERE
except those GameName <>
where the 'Chess';
GameName is
'Chess':

⮚ Logical operators:

In a WHERE clause, logical operators like AND, OR, and NOT are used to combine multiple
conditions and create more complex filters for data retrieval. These operators helps to define
the criteria for which rows are included in the result set.

Operator Query Command Output

85 | P a g e
AND display details of all SELECT * FROM
Rows are games that have sportsclub
selected exactly 2 clubs and WHERE
only if both fees charge is less noofclubs =2 AND
(or all)
than 10,000 from a Fees < 10000;
conditions
table sports club
are true.
OR Display details of SELECT * FROM
Rows are games that either sportsclub
selected if have fees more WHERE
any one or than 20,000 or Fees > 20000 OR
all
have more than 3 noofclubs >3;
condition
clubs from a table
is true.
sportsclub
NOT display GCode, SELECT GCode,
Negate a Game Name and GameName,
condition. Starting Date of all StartingDate
It returns games except Chess FROM sportsclub
rows
from a table WHERE NOT
where the
sportsclub GameName=
condition
is false. ‘Chess’;

➢ Between operator:

This clause facilitates us to give a range of values. So, if you want to impose a condition in
which you wish to include a range of values, we use the Between clause.

Note: both values are inclusive in the range you give in the "Between" clause

Operator Query Command Output


Between Display details SELECT *
– Range of all games FROM
Condition where the fees sportsclub
are between WHERE fees
8000 and between 8000
20000 from a and 20000;
table sports
club

➢ IN -Membership Operator:
The IN operator is used to filter data for a specified set of values. It can also be used to
replace multiple OR conditions.
Operator Query Command Output

86 | P a g e
IN – List Show Gcode and SELECT *
condition Fees of all the FROM
games where the Sportsclub WHERE
Game Name is GameName IN
either 'Carom', (‘Carom’, Chess’,
'Chess', or 'Lawn ‘Lawn Tennis’);
Tennis' from a
table sports club

➢ IS operator- Handling NULL Values :


SQL Supports a special value called NULL to represent a missing or unknown value. For
example, the village column in a table called address will have no value for cities. Hence, NULL
is used to represent such unknown values. It is important to note that NULL is different from 0
(zero). Also, any arithmetic operation performed with NULL value gives NULL. For example: 5
+ NULL = NULL because NULL is unknown hence the result is also unknown. In order to check
for NULL value in a column, we use IS NULL.

Operator Query Command Output


IS (i) Displays all (i) SELECT * (i)
Operator- games where FROM
Handling StartingDate is sportsclub WHERE
NULL not yet assigned startingDate IS
Values (ii) Displays NULL;
(ii)
GameName
where (ii)
StartingDate is
SELECT *
assigned FROM
sportsclub WHERE
from a table startingDate IS
sports club NOT NULL;

➢ Like operator- Substring pattern matching:


Many a times we come across situations where we don't want to query by matching exact text
or value. Rather, we are interested to find matching of only a few characters or values in
column values. For example, to find out names starting with ‘T' or to find out pin codes
starting with ‘60'. This is called substring pattern matching. We cannot match such patterns
using = operator as we are not looking for exact match. SQL provides LIKE operator that can
be used with WHERE clause to search for a specified pattern in a column.

The LIKE operator makes use of the following two wild card characters:

(i) % (percentage) (ii) _ (underscore)

87 | P a g e
Operator Query Command Output
Like (i) Display (i) (i)
operator- game code and Select Gcode,
Substring name of games Gamename from
pattern whose game Sportsclub where
matching name starts Gamename like
with ‘C’ and ‘C%s’;
ends with ‘s’.
(ii)
(ii) Displays Select * from
(ii)
details of all sportsclub where
those games Gamename like
whose game ‘__r__’;
name consists
of exactly 5
letters and 3rd
character is ‘r’
from a table
sports club
Example: Combination of both % (multi character pattern matching operator) and _ (single
character pattern matching operator)
Query: Displays names of all employees containing 'a' as the second character.
mysql> SELECT EName FROM EMPLOYEE WHERE Ename LIKE '_a%';
Data Manipulation Language (DML) :
The SQL commands that deals with the manipulation of data present in the database belong to
DML or Data Manipulation Language and this includes most of the SQL statements. It is the
component of the SQL statement that controls access to data and to the database.
List of DML commands:
● INSERT: It is used to insert data into a RELATION(TABLE).
● UPDATE: It is used to update existing data in a RELATION (TABLE)
● DELETE: It is used to delete records from a database RELATION(TABLE).

Command Query Command/syntax Output


name
Insert- Insert a new record in INSERT INTO
Inserting Data to sportsclub table <TABLE_NAME>
into the table (106,'Cricket',6, VALUES
30000, '2023-03-03'); (<val1>, <val2>…);

Inserting data Add a new record INSERT INTO


by specifying in sportsclub table <TABLE_NAME>
column names (107,'Judo',2, (<col_name>,
in INSERT 15000, '2024-01-01'); <col_name>,…)
INTO VALUES
command (<val1>, <val2>…);

88 | P a g e
Update- Data (i) Increase fees of all (i) UPDATE all
Updation – games by Rs. 500 rows-
to make UPDATE
changes in the <TABLE_NAME>
value(s) of SET <columnname
one or more = value>;
columns of (ii) Change the name (ii) UPDATE
existing of Judo club to ‘Judo specific rows-
records in a and Taekwondo’. UPDATE
table. <TABLE_NAME>
SET<columnname
= value> WHERE
<condition>;
DELETE - The (i) Delete all the rows (i) Syntax to
DELETE from sportsclub. DELETE all rows:
statement is
used to delete DELETE FROM
one or more <TABLE_NAME>;
* Data of sportsclub tables gets
record(s)
deleted
from a table
(ii) Delete all games (ii) DELETE
having noofclubs <4 specific rows:

DELETE FROM
<TABLE_NAME>
WHERE
<Condition>;

89 | P a g e
Multiple Choice Questions (DQL)

1. Which of the following is a DQL command?


a) INSERT b) UPDATE c) SELECT d) DELETE
2. The SELECT statement is used to:
a) Insert new records b) Delete records
c) Modify existing records d) Retrieve data from one or more tables
3. Which clause is used with SELECT to filter rows based on a condition?
a) WHERE b) GROUP BY c) ORDER BY d) HAVING
4. What is the main use of the WHERE clause in SQL?
a) To define a new table b) To sort records
c) To filter records based on a condition d) To group records
5. Which operator is used with the WHERE clause to check for a range?
a) BETWEEN b) IN c) LIKE d) AS
6. Which SQL statement will return all customers with names starting second character
with 'M’ and last character is M?
a) SELECT * FROM Customers WHERE CustomerName LIKE 'M%M';
b) SELECT * FROM Customers WHERE CustomerName LIKE '_M';
c) SELECT * FROM Customers WHERE CustomerName LIKE '__M%M';
d) SELECT * FROM Customers WHERE CustomerName LIKE 'M__%M';
7. What does the LIKE operator do in the WHERE clause?
a) To insert values b) Matches values using patterns
c) Checks for NULL values d) Compares numeric ranges
8. What is the result of this query?
SELECT * FROM customers WHERE city = 'Delhi' OR city = 'Mumbai';
a) Customers from any city b) Only customers from Delhi
c) Customers from Delhi or Mumbai d) No result
9. What will the following SQL query return?
SELECT * FROM orders WHERE status IS NULL;
a) All orders with status set to 'null' b) All orders where status is undefined
c) All orders where status is empty string d) Syntax error
10. Which SQL statement finds employees whose age is between 25 and 35 (inclusive)?
a) SELECT * FROM employees WHERE age = 25 AND 35;
b) SELECT * FROM employees WHERE age BETWEEN 25 AND 35;
c) SELECT * FROM employees WHERE age > 25 AND < 35;
d) SELECT * FROM employees WHERE age IN RANGE (25, 35);
Answer (Multiple Choice Questions) DQL
1. c) SELECT

90 | P a g e
2. d) Retrieve data from one or more tables
3. a) WHERE
4. c) To filter records based on a condition
5. a) BETWEEN
6. c) SELECT * FROM Customers WHERE CustomerName LIKE '__M%M';
7. b) Matches values using patterns
8. c) Customers from Delhi or Mumbai
9. b) All orders where status is undefined
10. b) SELECT * FROM employees WHERE age BETWEEN 25 AND 35;
Multiple Choice Questions (DML)
1. Which of the following is NOT a DML command?
a) INSERT b) SELECT c) UPDATE d) DELETE
2. Which SQL command is used to add new rows to a table?
a) ADD b) INSERT c) APPEND d) INCLUDE
3. The UPDATE statement is used to:
a) Add new data b) Delete existing data
c) Modify existing data d) Retrieve data
4. Which keyword is used in UPDATE statement to specify which records should be
updated?
a) SET b) WHERE c) FROM d) SELECT
5. To remove records from a table, which command is used?
a) ERASE b) REMOVE c) DROP d) DELETE
6. Which statement will update the salary of employees by 10% in an EMPLOYEE
table?
a) UPDATE EMPLOYEE SET salary = salary + 10;
b) UPDATE EMPLOYEE ADD salary = (Salary * 0.1) + Salary;
c) UPDATE EMPLOYEE SET salary = (Salary * 0.1) + Salary;
d) MODIFY EMPLOYEE SET salary = salary + 10;

7. What will happen if you execute DELETE FROM table_name; without a WHERE
clause?
a) Syntax error b) Deletes a random row
c) Deletes all rows d) Deletes only the first row
8. Which of the following statements is used to insert multiple rows in one query?
a) INSERT ALL INTO…. b) INSERT MULTIPLE INTO ...
c) INSERT INTO table_name VALUES (), (), (); d) MULTI INSERT INTO ...

9. Which of these statements is true about the DELETE statement?


a) It removes the entire table permanently.

91 | P a g e
b) It can be used with a WHERE clause to remove selected rows.
c) It requires the use of SET

d) It always deletes just one row.

10. What is the result of the following SQL query?

DELETE FROM students WHERE marks < 40;

a) Deletes students with exactly 40 marks


b) Deletes students with more than 40 marks
c) Deletes students with less than 40 marks

d) Syntax error

Answer (Multiple Choice Questions) DQL

1. b) SELECT
2. b) INSERT
3. c) Modify existing data
4. b) WHERE
5. d) DELETE
6. c)UPDATE EMPLOYEE SET salary = salary * 1.10;
7. c) Deletes all rows
8. c) INSERT INTO table_name VALUES (), (), ();
9. b) It can be used with a WHERE clause to remove selected rows.
10. c) Deletes students with less than 40 marks
Assertion and Reasoning Questions
Choose correct option for given Assertion (A) and Reasoning (R)
a) Both A and R are true, and R is the correct explanation of A.
b) Both A and R are true, but R is not the correct explanation of A.
c) A is true, but R is false.
d) A is false, but R is true.
1. Assertion (A): The SELECT statement can modify data in a table.
Reason (R): SELECT is a part of DQL and is used for retrieving data.
2. Assertion (A): In SQL, INSERT INTO is a Data Definition Language (DDL) Command.
Reason (R): DDL commands are used to create, modify, or remove database
structures, such as tables.
3. Assertion (A): The INSERT, UPDATE, and DELETE commands are part of DML.
Reason (R): These commands manipulate the data stored in database tables.
4. Assertion: The SQL WHERE clause is used for sorting the result set of a query.
Reason(R): The WHERE clause specifies conditions to filter rows in a query.
5. Assertion: The IS NULL operator in SQL checks if a column has a NULL value.

92 | P a g e
Reason(R): The IS NULL operator checks if a column contains a specific value.
6. Assertion (A): The DELETE command can be used to remove all rows from a table.
Reason (R): The DELETE statement requires a WHERE clause to execute.
7. Assertion (A): Both BETWEEN and IN operators can choose from a range of values.
Reason (R): The value ranges and a list of values are interpreted in different ways in
SQL.
8. Assertion (A): The UPDATE command in SQL can modify existing records in a table.
Reason (R): The INSERT command is used to add new rows to a table.
9. Assertion (A): The LIKE operator is used in SQL to filter records based on pattern
matching.
Reason (R): The LIKE operator supports wildcards such as % for multiple characters
and _ for a single character.
10. Assertion (A): DML commands can affect the structure of the database schema.
Reason (R): Commands like INSERT, UPDATE, and DELETE do not change the
database structure.
Answer (Assertion and Reasoning Questions)
1. D) A is false, but R is true.
Explanation: SELECT only retrieves data and does not modify it.
2. D) A is false, but R is true.
Explanation: INSERT INTO is a DML command.
3. a) Both A and R are true, and R is the correct explanation of A.
4. D) A is false, but R is true.
Explanation: Assertion is false because the WHERE clause is not used for sorting.
Reason is true - the WHERE clause is indeed used to filter rows based on a
condition
5. c) A is true and R is False
Explanation: Assertion is True: The IS NULL operator checks if a column does not
have a value, i.e., it’s null, meaning "unknown" or "missing".
Reason is false: IS NULL does not check for a specific value—it checks for the
absence of any value at all.
6. c) A is true and R is False
Explanation: Assertion is True: :You can delete all rows using DELETE FROM
table_name;
Reason is false: But a WHERE clause is optional — it’s used to delete specific
rows, not mandatory.
7. a) Both A and R are true, and R is the correct explanation of A.

8. b) Both A and R are true, but R is not the correct explanation of A.

9. a) Both A and R are true, and R is the correct explanation of A.

10. d) A is False, R is true

93 | P a g e
Short type Questions with Answer:
SNo. Questions
1. For finding the names of all the students who have enrolled for “Commerce” group in
class XI from the “Exam” table, Rishab has typed the following command, but he is
not getting the expected result. Kindly help him by rewriting the command to get the
expected output.
Select name from Exam where group like “Commerce”;
Ans: Corrected query is
Select name from Exam where group =“Commerce”;
As Equal to (=) operator is used for exact matching.
2. Sita has given following MySQL command to remove details of students who has not
paid the fees. But it is showing some error. Help Sita to correct it and justify your
answer.
DELETE * FROM STUDENT WHERE FEES=NULL;
Ans: Corrected query is
DELETE * FROM STUDENT WHERE FEES IS NULL;
NULL values are compared with IS operator only.
3. In SQL, how can you change ‘’Arnav’ into ‘Shivam’’ in the ‘FirstName’ column in the
Persons table?’ Write the SQL query to do the same.
Ans. Update Persons
Set FirstName=‘Shivam’’
Where FirstName=‘’Arnav’;
4. Correct the error in the following query.
Select * from RECORD where Rname = %math%;
Ans. Select * from RECORD where Rname like %math%;
LIKE operator is used for pattern matching.
5. Find the error in the following query and rewrite it:
DELETE * FROM STUDENT;
Ans. DELETE FROM STUDENT;
It is the correct query because * is not part of the syntax of
DELETE Command.
6. 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.
Ans. DELETE FROM Students WHERE Age < 18;
7. Write a query to display details of all those employees from EMPLOYEE table whose
name contains 7 characters, 3rd character is ‘M’ and 5th character is ‘K’.
Ans. Select * from EMPLOYEE where Ename LIKE ‘_ _M_K_ _’;
8. Match the following operators
Column A Column B
(a) range matching operator (i) <>
(b) multi character pattern matching operator (ii) NOT

94 | P a g e
(c) logical operator (iii)_(underscore)
(d) list matching operator (iv) %
(e) Single character pattern matching operator (v) Between
(f) relational operators (vi)IN
Ans.
Column A Column B
(a) range matching operator (v) Between
(b) multi character pattern matching operator (iv) %
(c) logical operator (ii) NOT
(d) list matching operator (vi)IN
(e) Single character pattern matching operator (iii)_(underscore)
(f) relational operators (i) <>
9. Explain the purpose of the SQL SELECT statement and provide an example of how it
is used to retrieve specific data from a database table.
Ans. The SQL SELECT statement is used to retrieve specific data from a database
table without altering it.
Example: SELECT FirstName, LastName FROM Employees;
10. Differentiate between Alter and Update command.
Ans.
Alter Command Update Command
(i) It is a DDL command. (i) It is a DML command
(ii) It is used to change the columns of the (ii) It is used to modify some or all
existing table such as: Adding a new records of the table specified by a
column, Deleting a column, Changing condition.
the data type of the column,
Renaming a column.
It is also used to add or delete the
constraints on an existing table.
Long type Questions with Answer:
SNo. Questions
1. Write output for (i) to (iv) MySQL queries on Customer table:
Table: CUSTOMER
ACCOUNTNO CNAME AGE GENDER BALANCE ACCOUNTCO
DE
101 S K YADAV 62 M 80000 7777
102 VIBA MISHRA 52 F 90000 9999
103 DIDAR SINGH 32 M 75000 7777
104 M SHARMA 35 M 79000 NULL
105 SIMI ARORA 30 F 97000 8888
106 DAYAL SONI 26 M 68000 9999
(i) SELECT ACCOUNTNO, CNAME, BALANCE
FROM CUSTOMER WHERE CNAME LIKE ‘%N%’;
(ii) SELECT * FROM CUSTOMER
WHERE AGE>50 AND BALANCE>80000;

95 | P a g e
(iii) SELECT ACCOUNTNO, CNAME FROM CUTOMER
WHERE ACCOUNTCODE NOT IN(7777,9999);
(iv) SELECT * FROM CUSTOMER WHERE ACCOUNTCODE IS NULL;
Answer:

2. Observe the following table Watches and answer the questions from (i) to (iv):
Table: Watches
Watchid Watch_Name Price Type Qty_Store
W001 High Time 10000 Unisex 100
W002 Life Time 15000 Ladies 150
W003 Wave 20000 Gents 200
W004 High Fashion 7000 Unisex 250
W005 Golden Time 25000 Gents 100
(i) Write SQL query to change the Qty_Store of Golden Time watches to 300.
(ii) To display all the details of those watches whose name ends with ‘Time‘
(iii) Write a query to add the following record in Watches table
(‘W006’,’Rolex’,25000,’Gents’,200)
(iv) Write the query to delete all the records from the table, but table
structure should remain in the database.
Answer:
(i) Update Watches Set Qty_Store=300 Where Watch_Name= “Golden Time”;
(ii) Select * from Watches where Watch_Name like “%Time”;
(iii) Insert into Watches values (‘W006’,’Rolex’,25000,’Gents’,200);
(iv) Delete from Watches;
3. Write queries for (i) to (iv) which are based on the following table TRAVEL.
Table: TRAVEL
CNO CNAME TRAVELDATE KM VCODE NOP
101 K. Niwal 2015-12-13 200 V01 32
103 Fredrick Sym 2016-03-21 120 V03 45
105 Hitesh Jain 2016-04-23 450 V02 42
102 Ravi Anish 2016-01-13 80 V02 40
107 John Malina 2015-02-10 65 V04 2
104 Sahanubhuti 2016-01-28 90 V05 4

96 | P a g e
(i) To display CNO, CNAME, TRAVELDATE from the table TRAVEL.
(ii) To display the CNAME of all customers from the table TRAVEL who are
travelling by vehicle with code V01 or V02
(iii) To display the CNO and CNAME of those customers from the table
TRAVEL who travelled between ‘2015-12-31‘and ‘2015-05-01‘.
(iv) To display all the details from table TRAVEL for the customers, who do
not have travel distance 120 KM.
Answer:
(i) Select CNO, CNAME, TRAVELDATE from TRAVEL;
(ii) Select CNAME from TRAVEL where VCODE= ‘V01’ or VCODE=’V02’;
(iii) Select CNO, CNAME from TRAVEL where TRAVELDATE between
‘2015-12-31‘and ‘2015-05-01‘;
(iv) Select * From TRAVEL where NOT KM=120;

4. Execute Query based on below Statements (i) to (iv) for table: SALES
Ecode Ename Address dojoin Amount Area
100 Amit Delhi 2017-09-29 5000.90 East
101 Sushant Gurgaon 2025-01-01 7000.75 East
102 Priya Noida 2024-04-25 3450.45 West
103 Mohit Delhi 2018-11-03 6000.50 North
104 Priyanshi Delhi 2019-12-15 8000.62 North

(i) Write a SQL query to display details of all salesmen whose date of joining is
after 31st March 2024.
(ii) Display details of all employees whose name starts with ‘S’ and ends
with ‘t’.
(iii) Display Area, Employee name and PFamount calculated as Amount *0.01
of East or West area employees.
(iv) Write a SQL query to delete the record of Ecode as 102.

Answer:
(i) Select * From Sales where dojoin > ‘2024-03-31’;
(ii) Select * From sales where Ename like ‘S%t’;
(iii) Select Area, Ename, Amount*0.01 as PFamount from Sales where Area IN
(‘East’, ‘West’);
(iv) Delete from Watches where Ecode=102;

5. Study the following table DOCTOR and answer the following questions: -
TABLE: DOCTOR
ID NAME DEPT GENDER EXPERIENCE
101 John ENT M 12
104 Smith ORTHOPEDIC M 5
107 George CARDIOLOGY M 10
114 Lara SKIN F 3
109 K George MEDICINE F 9
105 Johnson ORTHOPEDIC M 10
117 Lucy ENT F 3

97 | P a g e
(i) Write SQL Query to display the details of all those Doctors whose name
either starts with ‘J’ or starts with ‘S’.
(ii) Write SQL Query to display the details of all female doctors having
experience more than 5 years.
(iii) Write the SQL Query to delete the records of Male doctors of ENT dept.
(iv) Write the SQL Query to update the experience of all doctors by 1.

Answer:
(i) Select * From Doctor Where Name like ‘J%S’;
(ii) Select * from Doctor Where Gender=’F’ and Experience>5;
(iii) Delete From Doctor Where Gender=’M’ and department=’ENT’;
(iv) Update Doctor Set Experience=Experience+1;

98 | P a g e
Unit 4: Introduction to the Emerging Trends

99 | P a g e
1. Artificial Intelligence (AI)

What is it?
AI is a branch of computer science that enables machines to mimic human intelligence. This
means they can perform tasks like thinking, learning, problem-solving, and decision-making.
Key Features:
● Learns from experience
● Solves problems
● Makes decisions
Real-life Examples:
● Google Assistant answers your questions.
● Self-driving cars make driving decisions.
● Face recognition on smartphones.

2. Machine Learning (ML)

What is it?
ML is a subset of AI. It means teaching computers to learn from data and make predictions or
decisions without being explicitly told what to do every time.

How it works:
● Provide data → Computer analyzes it → Learns patterns → Makes predictions

Examples:
● YouTube recommends videos based on your watch history.
● Email filters move spam messages to the spam folder.

3. Natural Language Processing (NLP)

What is it?
NLP allows computers to understand, interpret, and respond to human language (like English,
Hindi, etc.).

Why it’s useful:


● It helps machines interact with humans using speech or text.

Examples:
● Google Translate
● Chatbots on websites
● Voice typing on smartphones

4. Immersive Experience (AR & VR)


Augmented Reality (AR):
What is it?
The literal meaning of augmentation is “the act of increasing the size, value or quality of
something by adding to it”. In AR adds digital elements (images, sounds, etc.) to the real world
using a smartphone or smart glasses.

100 | P a g e
Example:
You point your camera at a street, and it shows directions or restaurant reviews.

Virtual Reality (VR):


What is it?
VR creates a completely digital environment. You wear a headset and feel like you're inside a
different world.
Example:
Using a VR headset to walk through a virtual museum or play a 3D game.

5. Robotics

What is it?
Robotics is the field of designing and building robots—machines that can do tasks
automatically or with minimal human help.

Examples:
● Robot arms in factories
● Drones used for delivery or photography
● Cleaning robots at home

6. Big Data and Its Characteristics

What is Big Data?


Big data refers to extremely large sets of data that can be analysed to reveal patterns, trends,
and associations.

Characteristics (5 V’s):

1. Volume: Massive amount of data (e.g., social media posts)


2. Velocity: Speed at which new data is created and shared
3. Variety: Different formats – text, images, videos
4. Veracity: Accuracy and trustworthiness of the data
5. Value: How useful the data is for making decisions
7. Internet of Things (IoT)
What is it?
IoT connects everyday objects to the internet, allowing them to collect and exchange data.

Examples:
● Smartwatches that track your steps and heartbeat
● Smart lights that can be controlled via phone
● A fridge that tells you when you're out of milk
8. Sensors

101 | P a g e
What are they?
Sensors detect physical changes in the environment (like temperature, motion, light) and send
that information to a computer or device.

Examples:
● Temperature sensor in AC
● Motion sensor in security lights
● Fingerprint scanner on smartphones

9. Smart Cities

What is a Smart City?


A smart city uses technology to manage its resources efficiently and improve the quality of life
of its residents.

Features:
● Smart traffic management
● Smart energy use (like automatic street lights)
● Clean and efficient waste management
Examples:
● Cameras that monitor traffic and take decisions to reduce congestion
● Apps that tell you when your bus will arrive

10. Cloud Computing

What is it?
Cloud computing means storing and accessing data and applications over the internet instead
of your computer’s hard drive.

Benefits:
● Access from anywhere
● No need for expensive hardware
● Easy sharing and collaboration

Types of Cloud Services:

● SaaS (Software as a Service): Use software online (e.g., Google Docs, Zoom)
● IaaS (Infrastructure as a Service): Rent IT infrastructure like servers (e.g., Amazon
Web Services)
● PaaS (Platform as a Service): Tools for developers to create software (e.g., Microsoft
Azure)

11. Grid Computing

What is it?
Grid computing connects multiple computers over a network to work together on a single task,
sharing resources like a powerful virtual computer.

Why it's used:

102 | P a g e
● Solves complex problems
● Speeds up processing

Example:
Scientists use grid computing to analyse climate change models or DNA sequencing.

12. Blockchain Technology

What is it?
Blockchain is a digital ledger (record book) where information is stored in blocks and linked in
a secure and unchangeable way.

Key Features:
● Decentralized (no single owner)
● Secure and transparent
● Difficult to change once data is added
Uses:
● Cryptocurrency like Bitcoin
● Securely storing property or medical records

Multiple Choice Questions

1. AI is primarily designed to mimic which aspect of human beings?


a) Cognitive thinking b) Emotional intelligence
c) Physical strength d) Skeletal structure
2 Which of the following is an example of AI?
a) Automatic washing machine b) Automatic Entrance Gate
c) Self-driving car d) All of the above
3 Machine Learning is a part of which broader field?
a) Web Development b) Cybersecurity
c) Artificial Intelligence d) Database Management
4 What does Machine Learning use to make decisions?
a) Rules defined by humans b) Data and patterns
c) Hardware components d) Programming languages
5 Chatbots use NLP to:
a) Diagnose hardware issues b) Control robotic arms
c) Understand and respond to human text d) Store large datasets
6 Which of the following uses NLP?
a) Google Translate b) Paint software
c) File compression tools d) Spreadsheet applications
7 AR enhances the physical world by overlaying:
a) Musical compositions b) 3D holograms and digital information
c) Printed documents d) File systems
8 Which device is commonly used for experiencing Virtual Reality (VR)?
a) Smartphone b) Laptop
c) VR headset d) Printer
9 A robot equipped with sensors and actuators is capable of:
a) Playing video games b) Autonomously performing tasks

103 | P a g e
c) Sending emails d) Creating animations
10 Which of the following is an example of a robot?
a) Fan b) Washing machine
c) Self-driving vacuum cleaner d) Keyboard
11 Which of the following is not a characteristic of Big Data?
a) Volume b) Variety
c) Velocity d) Visibility
12 "Variety" in Big Data refer to?
a) Speed of data b) Number of users
c) Different types of data (text, images, etc.) d) Cost of data
13 What does IoT connect to the internet?
a) Physical devices like TVs, lights, and cars b) Only mobile phones
c) Website only d) Only computers
14 Smart homes use IoT for:
a) Traditional key-based locks b) Managing home appliances remotely
c) Manual water heating d) Paper documentation
15 Motion sensors are commonly used in:
a) Text editing software b) Social media platform
c) Food packaging d) Smart lighting systems
16 Which device commonly uses a fingerprint sensor?
a) Television b) Smartphone
c) Refrigerator d) Fan
17 Smart traffic lights use data to:
a) Change based on fixed time b) Operate manually by policemen
c) Optimize traffic flow dynamically d) Work only during the day
18 Which of the following is a feature of a smart city?
a) Smart traffic management b) Manual traffic lights
c) Paper maps d) Public payphones
19 What does Cloud Computing allow users to do?
a) Clean their computers b) Access computing services over the internet
c) Build physical servers d) Paint digital images
20 IaaS is used when organizations need:
a) Cloud-based software only b) Infrastructure like servers and networking
c) Web development platforms d) Voice-based control system
21 Grid Computing combines multiple computers to:
a) Share internet only b) Print documents faster
c) Work together on a task d) Reduce electricity use
22 Which of the following best describes Grid Computing?
a) One powerful computer b) Cloud-based storage
c) A software development tool
d)A network of computers solving problems together
23 Blockchain stores data in:
a) Boxes b) Sheets
c) Linked blocks d) File
24 Which of the following is built using Blockchain technology?
a) WhatsApp b) Bitcoin
104 | P a g e
c) Antivirus software d) MS Word
Answer (Multiple Choice Questions)

1 (a) Cognitive Thinking


2 (c) Self Driving Car
Explanation: vehicles use AI to navigate roads, recognize obstacles, and make
driving decisions
3 (a) Artificial Intelligence
4 (b) Data and patterns
5 (c) Understand and respond to human text
6 (a) Google Translate
7 (b) 3D holograms and digital information
8 (c) VR headset
9 (b) Autonomously performing tasks
10 (c) Self-driving vacuum cleaner
11 (d) Visibility
12 (c) Different types of data (text, images, etc.)
13 (a) Physical devices like TVs, lights, and cars
14 (b) Managing home appliances remotely
15 (d) Smart Lighting Systems
16 (b) Smartphone
17 (c) Optimize traffic flow dynamically
18 (a) Smart traffic management
19 (b) Access computing services over the internet
20 (b) Infrastructure like servers and networking
21 (c) Work together on a task
22 (d) A network of computers solving problems together
23 (c) Linked blocks
24 (b) Bitcoin

Assertion and Reasoning Questions


Choose correct option for given Assertion (A) and Reasoning (R)
a) Both Assertion (A) and Reason (R) are true, and Reason (R) is the correct
explanation of Assertion (A).

b) Both Assertion (A) and Reason (R) are true, and Reason (R) is not the correct
explanation of Assertion (A).

105 | P a g e
c) Assertion (A) is true, but Reason (R) is false.
d) Assertion (A) is false, but Reason (R) is true.

1 Assertion (A): Artificial Intelligence helps machines make decisions like humans.
Reason (R): AI systems can learn from data and past experiences.

2 Assertion (A): Machine Learning improves automatically over time.


Reason (R): It is based on predefined instructions only.

3 Assertion (A): NLP allows computers to understand human speech and text.
Reason (R): NLP translates machine code into human language.

4 Assertion (A): Virtual Reality creates a complete virtual world.


Reason (R): In VR, the real-world environment is entirely replaced by a digital one.

5 Assertion (A): Robots can perform tasks without human intervention.


Reason (R): Robots are designed with sensors, processors, and actuators.

6 Assertion (A): Big Data can be processed using traditional tools like Excel.
Reason (R): Big Data has high volume, velocity, and variety.

7 Assertion (A): IoT allows devices to communicate and share data.


Reason (R): IoT devices are connected via the internet and often use sensors.

8 Assertion (A): Sensors convert physical changes into signals.


Reason (R): Sensors store large amounts of data.

9 Assertion (A): Smart cities aim to improve quality of life using technology.
Reason (R): Smart cities ignore sustainability and focus only on digital tools.

10 Assertion (A): Cloud computing allows access to software and data from anywhere.
Reason (R): Cloud services are stored on remote servers connected via the internet

11 Assertion (A): Grid computing uses a single supercomputer to solve problems.


Reason (R): Grid computing connects multiple computers to work on a shared task.

12 Assertion (A): Blockchain data can be easily changed or deleted.


Reason (R): Each block in a blockchain is linked and secured using cryptography.

Answer(Assertion and Reasoning Questions)


1 (a) A and R are true, and R is the correct explanation of A.
2 (c) A is true, but R is false.
3 (c) A is true, but R is false.
4 (a) A and R are true, and R is the correct explanation of A.
5 (a) A and R are true, and R is the correct explanation of A.

106 | P a g e
6 (c) A is false, but R is true
7 (a) A and R are true, and R is the correct explanation of A.
8 (c) A is true, but R is false.
9 (c) A is true, but R is false.
10 (a) A and R are true, and R is the correct explanation of A.
11 (c) A is false, but R is true.
12 (c) A is false, but R is true.

Short type Questions (with Answers)


1 What is the main difference between AI and Machine Learning?
Answer: Artificial Intelligence (AI) refers to the broader concept of machines
performing tasks that require human intelligence. Machine Learning (ML) is
a subset of AI that enables systems to learn and improve from data without
being explicitly programmed.
2 Define Big Data. What are its three main characteristics?
Answer: Big Data refers to extremely large datasets that require advanced
tools for processing. Its main characteristics are Volume, Variety, and
Velocity.
3 Riya uses a learning app that suggests personalized topics for revision based
on her past performance. The app also gives real-time answers and tracks
her progress

a) Identify the technology behind the app and how it mimics human
intelligence.
b) Mention two benefits of using such AI-based tools in education.
Answer:(a) The technology is Artificial Intelligence (AI), which enables the
app to analyze past data and make smart decisions, similar to how a teacher
might suggest topics.
Answer:(b) (i) Personalized learning experience and (ii) instant doubt
resolution
4 Medical students use VR headsets to practice surgery in virtual operation
rooms that simulate real scenarios.
a) Explain how VR creates an immersive experience.
b) List two benefits of using VR for professional training in the medical field.
Answer: (a) VR simulates a 3D environment, making users feel as if they are
in the real surgical room.
Answer: (b) (i) Risk-free learning and (ii) better hands-on practice.
5 What is meant by SaaS in cloud computing? Give one example.
Answer: SaaS stands for Software as a Service. It allows users to access

107 | P a g e
software over the internet. Example: Google Docs.
6 How does blockchain ensure the security of data?
Answer: Blockchain uses cryptographic links between blocks, making it
tamper-proof and ensuring that data cannot be changed without altering all
subsequent blocks.
7 A farm uses soil sensors that send data to the farmer's phone and
automatically switch irrigation pumps on or off.
a) Explain how IoT works in this farming setup.
b) State two advantages of IoT in agriculture.
Answer: (a) Sensors collect data and communicate via the internet to
control pumps automatically.
Answer: (b) (i) Saves water and (ii) increases crop yield.
8 A shopping website recommends clothes and gadgets based on what users
have previously browsed or purchased.
a) Explain how the website “learns” from user behavior.
b) State two ways Machine Learning improves user experience in online
shopping.
Answer: (a)The website uses Machine Learning (ML) to detect patterns in
user activity and uses algorithms to make future recommendations.

Answer: (b) (i) Saves time by showing relevant products and


(ii) enhances user satisfaction

Long Answer Questions (with Answers)


1 Explain the concept of Artificial Intelligence (AI) with two real-life examples.
How does it benefit society?

Answer: Artificial Intelligence(AI) refers to machines performing tasks


that typically require human intelligence. Examples include:
1. Virtual assistants like Siri or Alexa
2. Autonomous vehicles (self-driving cars)

AI benefits society by improving efficiency, accuracy, and enabling


automation in areas like healthcare, education, and transportation.
2 Discuss how Machine Learning works. Mention any two types of Machine
Learning?

Answer: Machine Learning works by feeding data into algorithms that


learn patterns and make decisions. Two types of ML are:

108 | P a g e
1. Supervised Learning – where the model learns from labelled data.
2. Unsupervised Learning – where the model identifies patterns in unlabelled
data.
3 Describe the difference between AR and VR. How are they used in education
and entertainment?
Answer: AR overlays digital content on the real world, while VR immerses
users in a virtual environment.
In education, AR can enhance textbooks with 3D models; VR can simulate
lab experiments.
In entertainment, AR is used in games like Pokémon GO, while VR is used
in virtual tours and 3D games.
4 A farmer uses a mobile app connected to soil sensors in his field. The app
alerts him about moisture levels and turns irrigation pumps on/off
automatically.
a) What does IoT stand for?
b) How do sensors help in smart farming?
c) State one advantage of using IoT in agriculture.
d) Mention one device commonly used in IoT-based farming.
Answer:
(a) Internet of Things
(b) Sensors collect real-time data like soil moisture, temperature, and
humidity, which helps in making timely and accurate decisions for crop
management.
(c) IoT improves crop yield while reducing water and resource wastage
through automated systems.
(d) Soil moisture sensor

5 Explain the term Big Data. Discuss the 5 V’s of Big Data with examples.

Answer: Big Data refers to massive amounts of structured and unstructured


data.
The 5 V’s are:
1. Volume – Huge data size (e.g., social media posts)
2. Velocity – Speed of data generation (e.g., stock market data)
3. Variety – Different data types (e.g., text, video, images)
4. Veracity – Data accuracy and trustworthiness
5. Value – Useful insights from data (e.g., customer trends)

6 What are the different types of cloud computing services? Explain each
with examples.

Answer: The main types of cloud services are:


109 | P a g e
1. SaaS (Software as a Service): Software accessed via internet. Example:
Zoom, Google Docs.
2. PaaS (Platform as a Service): Platform for developers to build
applications. Example: Google App Engine.
3. IaaS (Infrastructure as a Service): Provides virtual hardware. Example:
Amazon Web Services (AWS)
7 During a flu outbreak, health authorities collect data from hospitals, mobile
apps, and pharmacies. They analyze this large and varied data to identify
affected areas and predict future spread.
a) Which technology is used to handle large and complex data sets?
b) Name any two characteristics of Big Data.
c) Why is Big Data important for public health planning?
d) Give one example of a sector apart from health that uses Big Data.
Answer:
a) Big Data Analytics
b) (i) Volume: Refers to the vast amount of data generated.
(ii) Variety: Refers to the different types of data (text, images, numbers,
etc.).
c) It helps in early detection of outbreaks, better allocation of resources, and
accurate prediction of disease spread.
d) The Retail sector uses Big Data for customer behavior analysis and
personalized marketing.

110 | P a g e
KENDRIYA VIDYALAYA SANGATHAN
SAMPLE QUESTION PAPER-01
CLASS: XI
INFORMATICS PRACTICES (065)
Time allowed: 3 Hours Maximum Marks:70

Q No Section-A (21 x 1 = 21 Marks) Marks


1 State whether the following statement is True or False: 1
Python Keywords are also known as Identifiers.
2 IGB = ________ Bytes 1
(A) 210 (B) 220
(C) 2 30 (D)1024
3 SQL stands for: 1
(A) Standard Query Language
(B) Scripting Query Language
(C) Simple Query Language
(D) Structured Query Language
4 How many times “Entry” will print on screen after execution of given code: 1
for x in range (3,9,3):
print(“Entry”)
(A) 2 times (B) 3 times (C) 9 times (D) ERROR
5 Which among the following is an example for Language Processors 1
(A) Compiler (B) Assembler (C) Interpreter (D)All the Above
6 What will be the output of the following code? 1
list1=[1,3]
list2=list1
list1[0]=4
print(list2)
(A) [1,3]
(B) [4,3]
(C) [1,4]
(D) [1,3,4]
7 Evaluate: 1
not(1==1 and 0!=1)
(A) True (B) False (C)Error (D)Cannot say
8 Rows of a relation are known as the _______. 1
(A) Degree (B) Tuples (C) Entity (D) Attribute

111 | P a g e
9 Which of the following is correct with respect to above Python code? 1
d={"a":3,"b":7}
(A) dictionary d is created (B) a and b are the keys of dictionary d.
(C) 3 and 7 are the values of dictionary (D) All of the above.

10 Siri is an example for 1


(A) Natural Language Processing (B) Computer Vision
(C) Data Science (D) Virtual Reality.
11 Fill in the Blank 1
A candidate key that is not a primary key is called -------------------
(A) Super Key (B) Alternate Key
(C) Foreign Key (D) Secondary Key
12 In IoT , T stands for 1
(A) Technology (B) Traffic (C) Things (D) Technique
13 Identify the odd one from the following : 1
(A) Oracle (B) MySQL (C) MS Access (D) Python
14 Which among the following is an example for customized software 1
(A) Photoshop (B) MS Excel (C) Windows (D) Hospital Management
Software
15 Which one of the following attribute can be taken as a primary key? 1
(A) Name (B) Designation (C) EmpId (D) Department
16 Which one of these is not an area of AI? 1
(A) Face/Image Recognition (B) Voice Recognition
(C) Robotics (D) Web Designing
17 SELECT * statement displays all -------------------- of a table. 1
(A) Rows (B) Attributes (C) Tuples (D) Domain values

18 Identify the data type of T: 1


T = {1:’Anu’,2:’Bineesh’,3:’Chitra’}
(A) List (B) Tuple (C) Dictionary (D) String
19 Which of the following identifier names are invalid and why? 1
(A) Serialno1 (B) TotalMarks (C) _Percentage (D) True

Q-20 and Q-21 are Assertion (A) and Reason (R) Type questions. Choose the
correct option as:
(A) Both Assertion (A) and Reason (R) are true, and Reason (R) is the
correct explanation of Assertion (A)
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the
correct explanation of Assertion (A)
(C) Assertion (A) is True, but Reason (R) is False
(D) Assertion (A) is False, but Reason (R) is True
20 Assertion (A): List is mutable data type 1
Reason (R): We can update the values of list elements likeLl[1]=5.

112 | P a g e
21 Assertion (A): In SQL, INSERT INTO is a Data Definition Language 1
(DDL) Command.
Reason (R): DDL commands are used to create, modify, or remove database
structures, such as tables.

Q No Section-B (7 x 2 = 14 Marks) Marks


22 (A) (i)Arrange the memory units in ascending order of storage size 2
MB, KB, TB, GB, Byte
(ii)List out any 2 Output Devices
OR
(B) Differentiate RAM and ROM (Mention any 2 points)
23 Consider the Table ‘‘Infant’’ shown below :
2

Identify the Degree and cardinality of the table .


24 Adrija wants to store the details of IP students in her class. Help her to
write suitable SQL queries for the following.
(i) To create the database IP . 2
(ii) Also tell her how to start working in that database.
25 (A) Define the following: 2
(i) Machine Learning
(ii) Blockchain technology
OR
(B) Explain Natural Language Processing . List out any two NLP
applications
26 Define the term Primary Key in a database. Explain how it is different 2
from a Candidate Key.
27 List out any 4 features of Python. 2
28 Categorize the following commands as DDL or DML:
(A) DROP, DELETE, UPDATE, ALTER
OR 2
(B) Differentiate between char(n) and varchar(n) data types with respect
to databases.
Q No Section-C (4 x 3 = 12 Marks) Marks
29 (i) Differentiate System Software and Application Software with 1
example for each.
2+1
(ii) Give any 2 examples for Customized software.
30 A) Write a program to accept a list of numbers and replace all numbers 3
greater than or equal to 33 with “PASS” and less than 33 with “FAIL”
eg: If the accepted list is [23,45,56,29,90,33], it should be replaced as
[“FAIL”,” PASS”,” PASS”,” FAIL”,” PASS”,” PASS”]
OR
B) Predict the output:
113 | P a g e
List1=[13,18,11,16,13,18,13]
print(List1.index(13))
print(List1.count(18))
List1[2]=10
List1.append(10)
List1.append(List1.count(10))
print(List1)

31 (i) Rewrite the following code in python after removing all the syntax
errors. Underline each correction done in the code.
num1, num2 = 10 5
if num1 % num2 = 0
num1+= 20
num2+= 30
Else: 2+1=3
print(Not Divisible )

(ii) Give 2 examples for Immutable datatypes in python

32 (A) Consider the following list myList. What will be the output of the code 3
after executing of below code:
myList = [10,20,30,40]
myList.append([50,60])
d=myList.pop(2)
print(d)
print(myList)
OR

(B) Write a program to make 1-D array and 2-D array list and write the
output for both

Q No Section-D (2 x 4 = 8 Marks) Marks


33 i. Write an SQL query to create the table “Items“ with the following 4
structure-

ii. Write SQL Query to insert the following data in the Items Table
101, Galaxy S30 Ultra, Samsung, Black, 85000, 10

114 | P a g e
(ii) Aman has created a table “Inventory” and forgot to add a
column “GST” of data type integer. Write SQL command to
add the column in the table.
(iii) Smita is working on SQL query , but she is getting error in
her query.Help her in removing error and writing correct
query
select * from Product where price=NULL;
34 Write the output of the queries (i) to (iv) based on the table given below: 4

I. Select BRAND_NAME, FLAVOUR from CHIPS where PRICE < > 10;
II. Select * from CHIPS where FLAVOUR=”TOMATO” and PRICE > 20;
III. Select BRAND_NAME from CHIPS where price > 15 and QUANTITY <
15;
IV. Select price , price *1.5 from CHIPS where FLAVOUR = “PUDINA”;

Q No Section-E (3 x 5 = 15 Marks) Marks


35 Write python code to create a dictionary of Products with product name 5
as key and price as value .Product name and price must be accepted from
the user .
The program should then search for particular product by inputting product
name and display price of the same on the screen
For Example the expected output in the following format.
Product = {‘Pen’ : 20, ‘Book’: 50 , ‘Pencil’ : 10 }
Enter the Product Name : Book
Product Details Found : ‘Book’: 50

OR
Consider the given dictionary,
D={1:’monday’, 2:’Tuesday’, 3:’Wednesday’,4:’Thursday’}
(i) What will be the output of following code:
print(D.values())
(ii) What will be the output of D[2]
(iii) Write python code to add a new value ‘Friday ‘with key 5.
(iv) Write python code to remove the value ‘Wednesday’ from the
dictionary.
(v) Which among the following statements will the number of key
value pairs in D ?
(A) D.count() (B) count(D) (C) len(D) (D) D.index()

115 | P a g e
36 Mr. Manav, a database administrator in “Global Educational and Training 5
Institute” has created following table named “Training” for the upcoming
training schedule:
Table : Training:
Training_Id TName Topic City Fee

ND01 Mr.Renjit Cyber Security New Delhi 10000


CH01 Mr.Rajesh ICT in Education Chennai 15000
CO01 Ms.Neena Cyber Security Cochin 12000
MU01 Ms.Anjali Data Analysis Mumbai NULL
ND02 Mr.Anand Cyber Security New Delhi 9000
Help him in writing SQL query for the following purpose:
i. To display details of trainings whose fees in the range 10000 -
15000.
ii. To display the topic of free trainings.
iii. To display all the cities where Cyber Security training is scheduled
along with its fee.
iv. To display Trainer name , Topic and Fee of all trainings conducted
in Mumbai and Chennai
v. To display the details of all trainings

37 Consider the Table “INFANT” shown below. 5

Write SQL commands based on the Infant table :


I. Display all the rows from infant table
II. Display the details about the Cot.
III. Display the names of items and their unitprice where the date of
purchase is after 31 st December , 2015.
IV. Display the name of items whose unit price is between 100 and
1000 (including both values).
V. Delete the details of Soft Toy
OR
Write the output for the following SQL commands:
(i) SELECT DISTINCT DISCOUNT FROM INFANT;
(ii) SELECT ITEM FROM INFANT WHRE DISCOUNT BETWEEN 10
AND 30 ;
(iii) SELECT ITEM, DATEPURCHASE FROM INFANT WHERE
DATEPURCHASE < ’2015-01-01’ ;
(iv) SELECT Item,UnitPrice FROM Infant WHERE UnitPrice<800
AND Discount>5;
(v) SELECT ItemCODE, Item FROM Infant WHERE Discount =10 or
Discount=25 ;

116 | P a g e
MARKING SCHEME
KENDRIYA VIDYALAYA SANGATHAN
SAMPLE QUESTION PAPER-01
CLASS: XI
INFORMATICS PRACTICES (065)
Time allowed: 3 Hours Maximum Marks:70
Q No. Section-A Marks
1 False (1 mark for correct answer) 1
2 (C) 230 (1 mark for correct answer) 1
3 (D). Structured Query Language (1 mark for correct answer) 1
4 (A) 2 times (1 mark for correct answer) 1

5 (D) All the Above (1 mark for correct answer) 1


6 (A) [4,3] (1 mark for correct answer) 1
7 (B). False (1 mark for correct answer) 1
8 (B)Tuples (1 mark for correct answer) 1
9 (D) All of the above. (1 mark for correct answer) 1
10 (A) Natural Language Processing (1 mark for correct answer) 1
11 (B)Alternate Key (1 mark for correct answer) 1
12 (C)Things (1 mark for correct answer) 1
13 (D) Python (1 mark for correct answer) 1
14 (D)Hospital Management Software (1 mark for correct answer) 1
15 (C)EmpId (1 mark for correct answer) 1
16 (D)Web Designing (1 mark for correct answer) 1
17 (B) Attributes (1 mark for correct answer) 1
18 (C) Dictionary (1 mark for correct answer) 1
19 (D). True since it is a keyword (1 mark for correct answer) 1
20 (A) Both Assertion (A) and Reason (R) are true, and Reason (R) is the 1
correct explanation of Assertion (A) (1 mark for correct answer)
21 (D). Assertion (A) is False, but Reason R is True 1
(1 mark for correct answer)
Q No. Section-B (7 x 2 = 14 Marks) Marks
22 (A) (i) Bytes, KB, MB, GB, TB
(1 mark for correct definition) 2
(ii) Printer ,Monitor or any other correct answer
½ for each device
OR
1 mark for each difference

(B)

117 | P a g e
RAM ROM
RAM is Random ROM is Read-only Memory
Access Memory
Data of RAM is Data present in Read Only
very volatile, it Memory (ROM) is not volatile,
will exist as long it is permanent. Data will
as there is no remain unchanged even when
interruption in there is a disruption in the
power power supply.
RAM) is expensive ROM is cheaper when compared
when compared to RAM.
to ROM
23 Degree – 5 Cardinality – 4 2
(1 mark each for correct answer )
24 (i) Create database IP ;
(ii) USE IP ; 2
(1 mark for each correct query)
25 (A) i) Machine Learning – Machine learning is a growing technology
which enables computers to learn automatically from past data
ii) Blockchain technology – It works on the concept of shared
database where each computer has a copy of the database and so it is
not possible for a single user to alter data.
(1 mark each for correct definition)
OR 2
Natural Language Processing –It enables the machines to
(B) understand, analyse, manipulate, and interpret human languages
NLP applications – Spam filters , Virtual Assistants
(1 mark for correct definition)
(1/2 each mark for any two applications)

26 Primary Key : A set of attributes that can uniquely identify each row in a
table (relation). It must contain unique values and cannot be null.
How it differs from Candidate Key
There can be multiple Candidate Keys in a table (relation), but only one of
them is selected as Primary Key. 2
(1 mark for correct definition) (1 mark for correct difference)
27 High Level Language ,Portable ,Cross Platform Language, Interpreted 2
(1/2 mark each for any 4 correct points)
28 (A) DDL - DROP , ALTER 2
DML – DELETE , UPDATE
(1/2 mark for each command)
OR
(B) char(n) varchar(n)
1 CHAR datatype is used to VARCHAR datatype is used to
store strings of fixed store strings of variable length
length
2 In CHAR, If the length of In VARCHAR, If the length of
118 | P a g e
the string is less than set the string is less than the
or fixed-length then it is fixed-length, then it will
padded with space. store as it is ie not padded
with extra space.
(1 mark each for any 2 relevant points )
Q No Section-C (4 x 3 = 12 Marks) Marks

29 (i)System Software is the type of software that is the interface


between application software and the system .It is essential for 3
the working of computer . eg.OS
Application software is designed to meet the requirements of the user
Eg: MS Word , Powerpoint

(1 mark for correct definition )


(1/2 mark for each example)

Library software , Billing software


(ii)
(1/2 mark for each example)

30 (A) L=eval(input(“Enter the List Elements”))


print(“The given List : “,L) 3
n=len(L)
for I in range(0,n):
if L[i]>=33:
L[i]=’PASS’
else:
L[i]=’FAIL’
print(“Modified List : “,L)
( 1 mark for for accepting the list)
(1 mark for traversing the list using for loop)
(1 mark for if condition and replacing list elements )
OR
(B) 0
2
[13, 18, 10, 16, 13, 18, 13, 10, 2]
1 mark for each line of output

31 num1, num2 = 10 , 5 3
if num1 % num2 == 0 :
num1+= 20
num2+= 30
else:
print(“Not Divisible” )
½ mark for each correction
Immutable datatypes - string , tuple
(1/2 mark each)

32 (A) 30 (1 mark for correct output) 3

119 | P a g e
[10, 20, 40, [50, 60]] (2 mark for correct output)

OR

(B)

½ mark each for import numpy in both 1-D and 2-D Array
1 mark for correct array()
1 mark for correct print statement with output
Q No. Section-D (2 x 4 = 8 Marks) Marks

33 I. Create table items(item_id varchar(5) primary key ,


item_name varchar(25),manufacturer varchar(15),
color varchar(15), price int, quantity int not null);
4
II. Insert into items values( 101, ‘Galaxy S30 Ultra’,
‘Samsung’, ‘Black’, 85000, 10 ) ;
III. Alter table inventory add gst int;
IV. Select * product where price is null;
(1 mark for each correct answer)
34 4

(iv) PRICE PRICE*1.5


10 15
(1 mark for each correct answer)
Q No. Section-E (3 x 5 = 15 Marks) Marks

35 product = dict() # create an empty dictionary


for I in range(0,n): 5
pname= input(“Enter the Product Name: “)
price = int(input(“Enter the Price: “))
product[pname] = price
print(“Product Detatls :”,
product)
pn= input(“Enter the product name to be searched: “)

120 | P a g e
if pn in product:
print(“Product Details Found -
“,pn,’\t\t’,product[pn])
else:
print(“Product Details Not
Found”) ( 1 mark for for loop)
(1 mark for creating dictionary)
(1mark for search )
OR
(i) dict_values([ ‘Monday’,’Tuesday’, ‘Wedneday’,’Thursday’])
(ii) ‘Tuesday’
(iii) D[5]=’Friday’

(iv) del D[3]


(v)len(D)
1 mark for each correct answer
36
i. Select * from training where fee between 10000 and 15000.
ii. Select topic from training where fee is null ;
iii. Select city,fee from training where topic=’cyber security’ ;
iv. Select Tname , Topic , Fee from training where city = ‘Mumbai’ or
city =’ Chennai ‘;
v. Select * from training;
(1 mark for each correct query)

37 (A) Write SQL commands based on the Infant table :

I. select * from infant;


II. SELECT * FROM Infant WHERE Item=’Cot’;
III. SELECT Item, unitprice FROM Infant WHERE
DatePurchase>’2015-12-31’;
IV. Select item from infant where unitprice between 100 and
1000;
V. DELETE FROM INFANT WHERE ITEM=’SOFT TOY’;
(1 mark for each correct query) 5
OR
(B) Write the output for the following SQL commands:

SELECT DISTINCT DISCOUNT FROM INFANT;


DISCOUNT
10
25
7
5
SELECT ITEM FROM INFANT WHRE DISCOUNT BETWEEN 10
AND 30 ;
ITEM
Frock
Cot
Soft Toy

121 | P a g e
SELECT ITEM, DATEPURCHASE FROM INFANT WHERE
DATEPURCHASE < ’2015-01-01’ ;
ITEM DATEPURCHASE
BABY SOCKS 2014-10-16

SELECT Item,UnitPrice FROM Infant WHERE UnitPrice<800 AND


Discount>5;
Frock 700
Baby Socks 100
SELECT ItemCODE, Item FROM Infant WHERE Discount =10 or
Discount=25 ;
ItemCODE Item
101 Frock
103 Soft Toy
102 Cot
(1 mark for each correct output)

122 | P a g e
KENDRIYA VIDYALAYA SANGATHAN
SAMPLE QUESTION PAPER 02
CLASS XI : INFORMATICS PRACTICES (065)
TIME: 03 HOURS M.M: 70

Q.No SECTION A (21 X 1 =21 marks) Marks


1 1074 ZB = ? 1
a) 1 YB 50ZB b) 1EB 50ZB c) 1YB 50 PB d)1PB 50 TB

2 A database can have only one table in MySql.State True or False 1

3 Shilpi is teaching Arithmetic operators in Python. One of her student 1


wrote the following statement:’7’+5
Predict the output of the above mentioned statement:
a) 75 b)12 c) TypeError d) 77777
4 Which command is used to add new record in table? 1
5 Which is not a valid operator in SQL? 1
a) ABOVE b) IN
c) LIKE d) BETWEEN

6 Which of the following identifiers is/are invalid? 1


a) Data b) _Data c) Data123 d) 4_Data
7 Identify the selection statement among the following: 1
a) for b) while c) if d) range
8 1 nibble= ------------- bits 1
a) 2 b) 4 c) 8 d) 16
9 Which among the following devices has the highest storage capacity? 1
a) RAM b) ROM c) Pendrive d) Hard Disk

10 Find the output produced by the following code: L=[ 1


12, 14.6, [‘a’,’b’,’c’],”hello”]
print(len(L))
a) 6 b) 4 c) 5 d) None of the above
11 Identify the correct command which will produce the output given below: 1
[0,-2,-4,-6,-8]

a)list(range(-2,-8,-2))
b) list(range(0,-8,-2))
c) list(range(-2,-10,-2))
d) list(range(0,-10,-2))

12 Choose the incorrect statement related to Where clause: 1

a) It is used to filter records


b) It is used to retrieve data that meet some specified conditions
c) It is used with SELECT statements as well as with INSERT statements
d) It is used with arithmetical as well as logical operators

125 | P a g e
13 Comments are executed by interpreter. State True or False 1
14 A company interested in cloud computing is looking for a provider who 1
offers a set of basic services such as virtual server provisioning and on-
demand storage that can be combined into a platform for deploying and
running customized applications. What type of cloud computing model fits
these requirements?
a) Platform as a Service
b) Software as a Service
c) Infrastructure as a Service
15 The COUNT(*) function provides the total number of __________ within a 1
relation (table) in a relational database.
(A) Columns (B) Unique values (C)Not-null values (D)Rows
16 Identify the SQL command used to delete a relation (table) from a relational 1
database.
(A) DROP TABLE (B) REMOVE TABLE
(C) DELETE TABLE (D)ERASE TABLE
17 Which is not one of the features of IoT devices? 1
a) Remotely controllable b) Programmable
c) Can turn themselves off if necessary d) None of the above
18 from the below python code display the value of first element of array and 1
display number 35 from an array
import numpy as np
Array=np.array([3,6,9,12,15,18,36,35,38])
print(Array[ ],Array[ ])
(a) [1],[7] (b) [1],[8] (c) [0],[8] (d)[0],[7]

19 “Imagine what if our bulbs, fans and refrigerator also become a part of 1
LAN or Internet. Think about of the advantages and tasks that can be
accomplished if all these devices with smart connectivity features are
able to communicate amongst themselves and we are also able to
communicate with them using computers or smart phones.”
In your opinion, which feature are we talking about in the above context?
(i) AR (ii) VR (iii) WoT (iv) IoT

20 Assertion(A): List is a sequence in Python 1


ReasoningI: Individual values in a list can be accessed using its index
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is False but R is True
21 Assertion (A): Random Access Memory is volatile and stores data 1
currently in used.
Reason I: RAM is storage medium that retains its contents ever after the
supply of electricity turned off. [1]
(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

126 | P a g e
SECTION B (7 x 2 = 14 Marks)
22 Deleting digitally stored data means changing the details of data at bit 2
level, which can be very time consuming. Therefore, when any data is
simply deleted, its address entry is marked as free, and that much
space is shown as empty to the user, without actually deleting the data.
In case data gets deleted accidentally or corrupted, there arises a need
to recover the data. Recovery of the data is possible only if the
contents/memory space marked as deleted 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.
Or
Write down the type of memory needed to do the following:
i) To execute the program
ii) To store the instructions which cannot be overwritten
23 How to create an Array of list in python using NumPy? Explain with 2
suitable example.
24 What are DDL and DML? Give one command of each. 2

25 The Doc_name column of a table HOSPITAL is given below: 2


Doc_Name
Avinash
Hariharan
Vinayak
Deepak
Sanjeev
Write the output of the following queries:
i) SELECT Doc_name FROM HOSPITAL WHERE Doc_name LIKE ‘%v’;.
ii)SELECT Doc_name FROM HOSPITAL WHERE Doc_name LIKE ‘_e%’
26 Differentiate between Virtual Reality and Augmented Reality. 2
27 The following query is producing an error. Identify the error and 2
also write the correct query. SELECT * FROM EMP ORDER BY
NAME WHERE SALARY>=5000;
28 Consider the following table ITEM : 2
Item_no Item_name Price
1 Pen 10
2 Pencil 5
3 Rubber 7
4 Sharpener 8
What is the degree and cardinality of the above mentioned table?
Or
Write any two advantages of using MySql?

SECTION C(4 x 3 = 12 Marks)


29 Write the most appropriate list functions to perform the following: 3
i) To delete a value from the list

127 | P a g e
ii) arrange the elements of the list in ascending order
iii) to add an element in any position of a list
30 (i) Himank has written the following statement in Python, but 1+2
it is showing an error: =3
X = 0o81
According to you what could be the problem?
(ii) “Our heritage monuments are our assets. They are a
reflection of our rich and glorious past and an inspiration
for our future. UNESCO has identified some of Indian
Heritage sites as World Heritage Sites.”
Identify at least two parameters from the above text that can be used as
key value pair to set up a dictionary. Form a dictionary to create at least 5
records of World Heritage Sites.
31 (i) Write an SQL statement to create a table named STUDENTS, with the 3
following specifications:
Column Name Data Type
StudentID Numeric
FirstName Varchar(20)
LastName Varchar(20)
DateOfBirth Date
Percentage Float(10,2)
ii.
iii. (ii) Write SQL Query to insert the following data in the Students Table
1, Supriya, Singh, 2010-08-18, 75.5
32 Consider the table “Accessories” given below and write suitable output 3
of the following:

(i) SELECT DISTINCT NAME FROM ACCESSORIES WHERE


PRICE>5000;
(ii) SELECT AVG(PRICE), MAX(PRICE) FROM ACCESSORIES
WHERE PRICE>=10000;
(iii) SELECT NAME, PRICE*.05 DISCOUNT FROM ACCESSORIES
WHERE ID IN („S02‟,‟S03‟)

128 | P a g e
SECTION D (2X4=8 Marks)
33 i) What will be the output of following code: 1+1
dict1 = {“Rollno”:20, “Marks”:65} +2
dict2 = {“Rollno”:20, “Marks”:65} =4
print(dict1 == dict2)
ii) Name different types of comments in Python.
iii) Predict the output of the following:
quota = [“sports”, “ pwd”, “ews”, “gen”]
Marks= [58,70,45,69]
for k in range(len(quota)):
if quota[k]==”sports”:
Marks[k]+=2
if quota[k]==”ews”:
Marks[k]+=5

34 i) Suppose there is a computer with RAM but no secondary storage.


1+1
Why we are not able to install software on that computer? +2=
ii) Why cache memory is considered crucial for microprocessor 4
performance?
iii) 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.

SECTION E (3 X 5=15 Marks)


35 Consider the table ‘Transact’ given below and write suitable SQL queries 5
of the following:
TABLE: TRANSACT
TRNO ANO AMOUNT TYPE DOT
T001 101 2500 Withdraw 2017-12-21
T002 103 3000 Deposit 2016-06-01
T003 102 2000 Withdraw 2017-05-12
T004 103 1000 Deposit 2018-10-22
T005 102 12000 Deposit 2017-11-06
(i) To display details of all transactions of TYPE Withdraw
from TRANSACT table
(ii) To display the date of transaction (DOT)along with the
amount from table TRANSACT for Account having ANO
as 102
(iii) To display the column values of ANO without
repetition.
(iv) To increase the amount by 500 for all transactions of
deposit type in the TRANSACT table.
(v) To delete the row of the transaction with TRNO T004.

129 | P a g e
36 Consider the table ‘Teacher_Details’ given below and write suitable SQL 5
queries of the following:
Table: Teacher_Details
T_ID T_Name T_DOJ T_Subject Num_of_Periods
1001 Bharti 2018-10-15 Hindi 27
1002 Pratima NULL NULL 32
1003 Savitri 2012-11-13 Science 29
1004 Aashna 2020-02-24 English 28
i) Display the T_Name and Num_of_Periods by increasing
the number of periods each by 1.
ii) Display T_Name of all those teachers whose date of joining
is after 1st Jan 2019.
iii) Display T_ID and T_Name of all those teachers whose number
of periods are in the range of 25 to 30. (both values
included)
iv) Display the details of all those teachers who have not assigned
any subject.
v) Display the details of all those teachers whose subject is either
Hindi or Science.
37 a) A data analyst wants to preprocess a list of numbers by replacing all 3+2
positive numbers with 1 and negative numbers with -1. The analyst =5
needs a Python program to accept the list from the user, modify it, and
display the result.
Requirements:
1. Accept a list of numbers from the user.
2. Replace all positive numbers with 1 and negative numbers with -
1.
3. Display the modified list.
Solution:
Write a Python program that meets the requirements above.

b) A statistician wants to calculate the average of a list of numbers. The


statistician needs a Python program to accept the list from the user and
display the average.
Requirements:
1. Accept a list of numbers from the user.
2. Calculate the average of the numbers.
3. Display the average.
Solution:
Write a Python program that meets the requirements above.

OR

a) A programmer wants to perform various operations on a list of


numbers. The programmer needs to understand how to slice, append,
and reverse lists.
Requirements:
1. Find the output of the given code. Code:

130 | P a g e
list1 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
print(list1[::2])
print(list1 + [21, 22])
print(list1[::-])

b) A data analyst wants to understand nested lists to store complex data.


Requirements:

Define what a nested list is.


Provide an example of a nested list.

131 | P a g e
KENDRIYA VIDYALAYA SANGATHAN
SAMPLE PAPER 02
CLASS XI -INFORMATICS PRACTICES (065)
MARKING SCHEME
TIME: 03 HOURS M.M: 70
SECTION A (21 x1=21 Marks)
1 Ans: (a) 1 GB 50MB 1

2 Ans: False 1
3 Ans: (c) TypeError 1

4 Ans: INSERT INTO 1


5 Ans: (a) ABOVE 1

6 Ans: d) 4_Data 1

7 Ans: c) if 1

8 Ans: b) 4 1

9 Ans: d) Hard Disk 1

10 Ans: b) 4 1

11 d) list (range (0,-10,-2)) 1

12 c) It is used with SELECT statements as well as with INSERT statements 1

13 False 1

14 a) Platform as a Service (PaaS) 1

15 d)Rows 1

16 a) DROP TABLE 1

17 d) None of the above 1

18 d) [0],[7] 1

19 d) IoT 1

20 b) Both A and R are true and R is not the correct explanation for A 1

132 | P a g e
21 a) Both A and R are true and R is the correct explanation for A 1

SECTION A (7 x 2=14 Marks)


22 2
i)Yes, data can be recovered after deletion, but only if the memory space
marked as deleted has not been overwritten by new data.
ii)When data is deleted, the operating system marks the memory space as
available for new data, but the actual data remains intact until it's
overwritten. Therefore, data recovery software can potentially retrieve the
deleted data by accessing the memory space before it's overwritten.
Or
i) To execute the program: RAM (Random Access Memory)
RAM is volatile memory that temporarily stores program instructions and data
while the computer is running.
ii) To store the instructions which cannot be overwritten: ROM (Read-Only
Memory)
ROM is non-volatile memory that permanently stores instructions and data that
cannot be modified or overwritten.
1 mark for each correct explanation
23 NumPy Arrays are grid-like structures similar to lists in Python. NumPy array 2
can be created by converting a regular Python list into an array using the
np.array() function.
import numpy as np
List1= [10,50,90,130]
Arr1=np.array(List1)
print (List1) # will display list [10,50,90,130]
print (Arr1) # will display array of list [10 50 90 130]
24 DDL (Data Definition Language) 2
DDL is a set of SQL commands used to define and modify the structure of a
database, including creating, altering, and dropping tables, indexes, and
relationships.

Example DDL command:


CREATE TABLE customers (id INT, name VARCHAR(255), email VARCHAR(255));

DML (Data Manipulation Language)


DML is a set of SQL commands used to manipulate and modify the data within a
database, including inserting, updating, and deleting data.
Example DML command:
INSERT INTO customers VALUES (1, 'John Doe', '[email protected]');
1mark for explanation and 1 mark for example
25 i) Doc_name 2
Sanjeev
ii) Doc_name
Deepak
1 mark for each correct value
26 Virtual Reality (VR) 2
- Creates a completely artificial environment
- Immerses users in a simulated world
- Blocks out the physical environment

133 | P a g e
- Typically requires a headset or device
Examples: Gaming, simulations, virtual tours
Augmented Reality (AR)
- Overlays digital information onto the real world
- Enhances the physical environment with virtual objects
- Combines digital and physical elements
- Can be experienced through smartphones, tablets, or smart glasses
Examples: Pokémon Go, Snapchat filters, Google Maps
1 mark for explanation and 1 mark for example

27 As per MySQL, ORDER BY must be the last clause in SQL QUERY, and in this query 2
ORDER BY is used before WHERE which is wrong, the correct query will be:

SELECT * FROM EMP WHERE SALARY>=5000 ORDER BY NAME;

2 mark for correct answer, 1 mark may be awarded for identifying the error
28 Degree :3 2
Cardinality :4
Or
1. Open-Source and Cost-Effective: MySQL is an open-source relational database
management system, which means it is free to download, use, and modify. This
reduces the overall cost of development and maintenance.

2. Scalable and High-Performance: MySQL is designed to handle large volumes of


data and scale horizontally, making it an excellent choice for high-traffic
websites and applications. It also supports various storage engines, allowing
for optimization of performance and data integrity.

1 mark for each correct answer/explanation

SECTION C (4 x3 =12 marks)


29 i) remove() 3
ii) sort()
iii) insert()
1 mark for each correct answer
30 (i) The problem with Himank's statement is that Python interprets numbers 1+2=3
starting with 0o as octal (base 8) numbers. However, the digit 8 is not a
valid digit in octal notation (only 0-7 are allowed).

To fix the error, Himank can simply remove the leading zero, like this:
(1 mark for the correct answer)

(ii) Two parameters that can be used as key-value pairs to set up a dictionary are:

1. "Site Name" (key)


2. "Description" (value)
Here's a dictionary with 5 records of World Heritage Sites in India:
world_heritage_sites = {
"Taj Mahal": "A white marble mausoleum in Agra, built by Mughal Emperor Shah
Jahan",

134 | P a g e
"Red Fort": "A historic fort in Delhi, built by Mughal Emperor Shah Jahan",
"Humayun's Tomb": "A tomb in Delhi, built by Haji Begum, the wife of Humayun",
"Qutub Minar": "A minaret in Delhi, built by Qutb-ud-din Aibak",
"Fatehpur Sikri": "A historic city in Uttar Pradesh, built by Mughal Emperor
Akbar" }
print(world_heritage_sites)
(2 marks for correct answer)

31 i) Create table students(StudentID int, FirstName Varchar(20), 3


LastName Varchar(10), DateOfBirth Date, Percentage decimal(10,2));

2 Marks for Correct Create Command


ii) insert into students values( 1, ‘Supriya’, ‘Singh’, ‘2010-08-18’, 75.50;
Ans: 1 Mark for Correct insert into command

32 Consider the table “Accessories” given below and write suitable output of the 3
following:
i) SELECT DISTINCT NAME FROM ACCESSORIES WHERE
PRICE>5000;
Ans:Mother Board
LCD
ii) SELECT AVG(PRICE), MAX(PRICE) FROM ACCESSORIES WHERE
PRICE>=10000;
AVG(PRICE) MAX(PRICE)
12500 13000

iii) SELECT NAME, PRICE*.05 A S DISCOUNT FROM ACCESSORIES


WHERE ID IN(“S02‟,‟S03‟)

NAME DISCOUNT
Keyboard 25
Mother Board 650
Keyboard 20
Hard Disk 225
( 1 mark for each correct output)

SECTION D (4 x2 =8 Marks)
33 i) True 4
ii) Single Line comment and Multi Line comment
iii) [60, 70, 50, 69]
(½ mark to be awarded for each correct value)

34 i) We are not able to install software on a computer with RAM but no 4


secondary storage because:

- Software installation requires a permanent storage location to store the


program files and data.
- RAM is volatile memory, meaning its contents are lost when the computer is
powered off.
- Without secondary storage (like a hard drive or solid-state drive), there's no

135 | P a g e
place to store the installed software.
(1 mark for correct explanation)
ii) Cache memory is considered crucial for microprocessor performance
because:

- Cache memory is a small, fast memory location that stores frequently


accessed data.
- It acts as a buffer between the microprocessor and main memory, reducing
the time it takes to access data.
- By storing critical data in cache memory, the microprocessor can access it
much faster, resulting in improved performance.
(1 mark for correct explanation)
iii) Yes, discarding an old, broken, or malfunctioning hard disk without
deleting data can be harmful from a security perspective:

- Hard disks can contain sensitive information, such as personal data,


passwords, or confidential documents.
- Even if the hard disk is damaged or malfunctioning, it's possible for someone
to recover the data using specialized tools.
- If the hard disk falls into the wrong hands, the recovered data could be
misused, leading to identity theft, financial loss, or other security breaches.
(1 mark for Yes and 1 mark for justification)
SECTION E (5 x3= 15 Marks)

35 i) Select * from TRANSACT where TYPE=”Withdraw”; 5


ii) Select DOT,Amount from TRANSACT where ANO=102;
iii) SELECT DISTINCT ANO FROM TRANSACT

iv) UPDATE TRANSACT SET Amount=Amount+500 where


TYPE=’Deposit’;

v) DELETE FROM TRANSACT where TRNO =’T004’;

1 Mark each for correct query


36 i) Select T_name, Num_of_Periods+1 from Teacher_Details; 5
ii) Select T_Name from Teacher_Details where T_DOJ > ’2019-01-01’;
iii) Select T_ID, T_Name from Teacher_Details where No_of_Periods between 25
and 30;
iv) Select * from Teacher_Details where T_Subject is NULL;
v) Select * from Teacher_Details where T_Subject = ‘Hindi’ or T_Subject =
’Science’;
(or any other correct query) ( 1 mark for each correct query)

136 | P a g e
37 a) A data analyst wants to preprocess a list of numbers by replacing all 3+2
positive numbers with 1 and negative numbers with -1. The analyst needs =5
a Python program to accept the list from the user, modify it, and display
the result.
Requirements:
1. Accept a list of numbers from the user.
2. Replace all positive numbers with 1 and negative numbers with -1.
3. Display the modified list.
Solution:
Write a Python program that meets the requirements above.
Ans: 3 Marks for any correct logic

b) A statistician wants to calculate the average of a list of numbers. The


statistician needs a Python program to accept the list from the user and
display the average.
Requirements:
1. Accept a list of numbers from the user.
2. Calculate the average of the numbers.
3. Display the average.
Solution:
Write a Python program that meets the requirements above.

2 Marks for any correct logic

OR
a) [11,13,15,17,19]
[11,12,13,14,15,16,17,18,19,20,21,22]
[20,19,18,17,16,15,14,13,12,11]

(3 marks for each correct output)

b) A data analyst wants to understand nested lists to store complex data.


Requirements:
Define what a nested list is.
Provide an example of a nested list.

2 Marks for Correct Explanation and Example.

137 | P a g e
KENDRIYA VIDYALAYA SANGATHAN
UNSOLVED PAPER 1
CLASS XI - INFORMATICS PRACTICES (065)

Time allowed: 3 Hours Maximum Marks:70


Q No. Section-A (21 x 1 = 21 Marks) Marks
1 Identify the software among the following. 1
(A) Monitor (B) Keyboard (C) Windows (D) Speaker
2 The full form of CPU is- 1
(A) Control Processor Unit (B) Central Procedural Unit
(C) Central Precision Unit (D) Central Processing Unit
3 The ________ is a volatile memory in computers. 1
(A) RAM (B) ROM (C) DVD (D) Hard Disk
4 Which of the following is NOT a feature of Python programming language? 1
(A) Open-source (B) Interpreted (C) Case-insensitive (D) Uses indentation
5 Identify the arithmetic operator in python from the following- 1
(A) % (B) = (C) is (D) <
6 Which character is used to write comments in python? 1
(A) @ (B) ! (C) # (D) $
7 When this python code will execute, then which output will come? 1
import numpy as np
L1=[1,2]
L2=[3,4]
arr = np.array([L1, L2])
print(arr[1, 0])
(a) 1 (b) 2 (c) 3 (d) 4
8 Which keyword is used for accepting data from a user? 1

(A) accept (B) read (C) print (D) input


9 The default separator in the print statement is ________ 1

(A) (comma) (B) (single quote) (C) (space) (D) (newline)


10 Which operator has the highest precedence among the following? 1

(A) % (B) and (C) < (D) =


11 Which line number in the following program will give an error? 1

(A) 1 (B) 2 (C) 6 (D) No error in the program


12 Which operator in SQL tests a column for absence of data? 1
(A) EXISTS (B) NOT (C) IS NULL (D) None of these

13 The FROM clause in SQL is used to- 1


138 | P a g e
(A) specify what table we are selecting the data
(B) specify the columns that we want to be displayed
(C) specify search condition
(D) remove repeating values from being displayed
14 Which SQL statement is used to change the data in a table of a database? 1
(A) SAVE (B) UPDATE (C) SAVE AS (D) MODIFY
15 The SQL query to find the details of all the cities whose humidity is in the 1
range of 63 to 79 (including both 63 and 79) is-
(A) SELECT * FROM weather WHERE humidity IN (63 to 79)
(B) SELECT * FROM weather WHERE humidity NOT IN (63 AND 79)
(C) SELECT * FROM weather WHERE humidity BETWEEN 63 AND 79
(D) SELECT * FROM weather WHERE humidity NOT BETWEEN 63 AND 79

16 The SQL ALTER statement is used to- 1


(A) change the table data. (B) change the table structure.
(C) delete rows from the table. (D) add rows to the table.
17 The command to eliminate a table from a database is- 1
(A) DROP TABLE CUSTOMER; (B) DELETE TABLE CUSTOMER;
(C) REMOVE TABLE CUSTOMER; (D) UPDATE TABLE CUSTOMER;
18 Which of the following query is correct for using comparison operators in 1
SQL?
A. SELECT name, course_name FROM student WHERE age>50 and <80;
B. SELECT name, course_name FROM student WHERE age>50 and age
<80;
C. SELECT name, course_name FROM student WHERE age>50 and
WHERE age<80;
D. None of these
19 CREATE TABLE employee (name VARCHAR(10), id INTEGER); 1
What type of statement is this?
(A) DML (B) DDL (C) View (D) Integrity constraint
Q-20,21 are Assertion (A) and Reason (R) Type questions. Choose the
correct option as:
(A) Both Assertion (A) and Reason (R) are true, and Reason (R) is the
correct explanation of Assertion (A)
(B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not
the correct explanation of Assertion (A)
(C) Assertion (A) is True, but Reason (R) is False
(D) Assertion (A) is False, but Reason (R) is True
20 Assertion (A): List and Dictionary are mutable data types in python. 1
Reason (R): In both list and dictionary we can add, delete and update the
elements in place
21 Assertion (A): In SQL, INSERT INTO is a Data Definition Language (DDL) 1
Command.
Reason (R): DDL commands are used to create, modify, or remove database

139 | P a g e
structures, such as tables.
QNo. Section-B (7 x 2 = 14 Marks) Marks
22 (A) What is the difference between RAM and ROM? 2
OR
(B) What is the difference between Primary Memory and Secondary
Memory?
23 Rahul, a beginner in the field of Computer Science wants to know about the 2
different types of software. Explain to him the advantages and disadvantages
of Proprietary software?

24 Explain the if-elif-else statement in Python using appropriate code example. 2

25 (A) Given a list L=[1,2,3,4] and an ndarray N having elements 2


[1 2 3 4] . What will be the result produced by the following
statements?
(a) L*2 (b) N*3 (c) L+L (d) N+N

OR

(B) Find the output


L=[10, 11, 12, 13, 14]
x=L.pop(2)
L.insert(0, x – 5)
L.append(2)
L.sort(reverse=True)
print(L)
26 2
Student just started learning Databases and is confused about the Primary
Key concept. Explain the term Primary Key in a database. Tell how it is
different from a Candidate Key.
27 Write MySQL command to create the Table ‘LIBRARY’ with given 2
constraints.
Table: LIBRARY
COLUMN NAME DATA TYPE(SIZE) CONSTRAINT
BookId Int Primary Key
BookName Varchar(40) Not Null
Type Char(4)
Author Varchar(40)
No_Copies Int
Price Decimal(5,2)
28 (A) Explain Blockchain OR 2
(B) Explain Grid Computing
QNo Section-C (4 x 3 = 12 Marks) Marks
29 Draw and explain the block diagram of a computer. 2+1=

140 | P a g e
and write the name of Two Input and Output devices. 3
30 (A) Phuntsok has started his coding lessons in Python. Help him to 3
write a program to accept the sales made in a shop and calculate
the percentage of discount as per the following table:
Sr.No Sales Discount
1 < 1000 No discount
2 Between 1000 5%
and 5000
3 More than 5000 10%
Display the discount percentage as well as the final
discounted price to be paid.
OR
Sonam, a software trainee has been assigned a task to write a
(B) program that accepts the percentage of a student and then gives
the result of the student as per the following table. Help her in
accomplishing this task
percentage Result
More than 75 percent First Class
60 to 75 percent Second Class
40 to 60 percent Pass Class
Less than 40 percent Fail

31 Gulshifa is working on a database project for a company employing many 3


salespeople. She is working on the following table SALES. Help her to answer
the questions that follow:

(a) Suggest the Primary key for the table giving appropriate reasons.
(b) Write the SQL command to insert the following data in the table:
Salesid - E009, Name-Sukumar, City-Nagpur, Commission-10
(c) Is the command used in part (b) a DDL or a DML command
32 (A) What is Big Data? Explain any four features of Big Data. 3
OR
(B) What is Cloud Computing? Explain any two services offered on
the cloud.
Q No. Section-D (2 x 4 = 8 Marks) Marks
33 Write a program to accept the name of an item and its price repeatedly from 4
the user and use it to create a dictionary. The key is the item name and the
value is the price of the item. Ask the user for an item name and then find its
price

141 | P a g e
34 (A) Consider the following table BOOK and answer the questions 4
that follow:
Table: BOOK
BCODE TITLE AUTHOR PRICE
MIDNIGHT’S SALMAN
B001 500
CHILDREN RUSHDIE
THE GOD OF ARUNDHATI
B002 450
SMALL THINGS ROY
VIKRAM
B003 A SUITABLE BOY 600
SETH
THE WHITE ARAVIND
B004 399
TIGER ADIGA
TRAIN TO
B005 KHUSHWAN 350
PAKISTAN
T SINGH
Write SQL query to-
(a) Display book titles and the author names.
(b) Display the book titles priced more than 400.
(c) Display the details of books written by ARUNDHATI
ROY and KHUSHWANT SINGH.
(d) Remove the book ‘THE WHITE TIGER’ from the
table.
OR
(B) Consider following table MEDICINE and answer the questions
that follow:
Table: MEDICINE
MID MED_NAME SUPP_CITY STOCK DEL_DATE
M01 PARACETAMOL MUMBAI 200 2023-06-15
M02 AMOXICILLIN KOLKATA 50 2022-03-21
M03 COUGH SYRUP BENGALURU 120 2023-02-10
M04 INSULIN CHENNAI 135 2023-01-25
M05 IBUPROFEN HMEDABAD 30 2022-04-05

Write SQL queries to-

(a) Display the Medicine names and the supplier cities of all
medicines
(b) Display the medicine names from Mumbai and Chennai
cities.
(c) Display the medicine names delivered in 2022
(d) To remove the medicine ‘INSULIN’ from the table.
Q No. Section-E (3 x 5 = 15 Marks) Marks
35 Rafael is working on a project monitoring the sales of a Company and is 5
working on the table SALES as shown below:

142 | P a g e
Assist him by writing the output of the following SQL queries:
(A) select distinct City from Sales;
(B) Select Name, Commission * 0.5 As NewCommission from Sales;
(C) Select * from Sales where (City =‘Delhi’ or City = ’Mumbai’) and
Commission>20;
(D) Select Name, City from Sales where Commission between 20 and 30;
(E) Select Name from Sales where City != ‘Delhi’ and City !=’Kolkata’;

36 Simran is working with a media company and is analysing the performance of 5


Movies. She is working on the table MOVIE shown below.

MovieID Title Year Rating


1 LAGAAN 2001 7.8
2 TAARE ZAMEEN PAR 2007 8.5
3 3 IDIOTS 2009 9.4
4 DANGAL 2016 8.9
5 ANDHADHUN 2018 7.3

Help her to write SQL statement to:


(A) Display the details of movies released after 2010.
(B) Display titles and the ratings of all the movies.
(C) Display the movie name and the year of release of movies having
ratings in the range of 7.1 to 8.9 (inclusive of both)
(D) Add a new column named 'Revenue' which will store the revenue
earned by that movie till date.
(E) Remove all movies released prior to 2005 from the table.

37 (A) 5
Write a program that will manage the inventory of a shop.
The program should create a dictionary consisting of five
products from user input in which the key is the product
name and the value is the quantity presently in stock. The
user must input the product name and the quantity
separately, the program must add it dynamically to the

143 | P a g e
dictionary.

The program should then ask from the user a list containing
five numbers. The list of numbers are the quantities that are
to be reduced from the stock. The program should reduce the
(B) quantities from the dictionary and then display the updated
dictionary OR

Write a program that creates a dictionary dynamically from


user input of five product names and the corresponding price
of the product. The product name is the key and the price
becomes the value of the dictionary.

The program should then accept a list of five integers which


consist of the number of items bought for the five products in
the dictionary. The program should then find the total amount
of the bill by referring the dictionary created in the previous
step above.

144 | P a g e
Web links:
1. Syllabus for Higher Secondary Stage prescribed by NCERT:
https://ncert.nic.in/pdf/syllabus/IPHSS.pdf

2. CBSE Syllabus Class XI – IP (065) Session 2025-2026


https://cbseacademic.nic.in/web_material/CurriculumMain26/SrSec/
Informatics_Practices_SrSec_2025-26.pdf
3. NCERT Publication Book for IP (Class XI)
https://ncert.nic.in/textbook.php?keip1=0-8

4. Digital Text Book Class XI- IP on Diksha Portal


https://diksha.gov.in/resources/play/collection/do_3130335324
985507841785?contentType=TextBook

145 | P a g e

You might also like