Class XII Informatics Practices (065)

Minimum Learning Support Material · CBSE 2026-27

Notes · Run-checked examples · 1121 solved questions · Flashcards · Quiz · Practice Paper Maker

Designed by NareN, PGT (Computer Science), PM SHRI K V Shalimar Bagh, Delhi-88 (Shift-I) ✨ Click Here For Your Valuable Feedback ✨
1

Know the paper first

CBSE Sample Question Paper 2026-27: 37 questions, 70 marks, 3 hours

SectionQuestionsMarks eachTotalWhat comes
AQ1 to Q21121MCQ, True/False, fill in the blank. Q20 and Q21 are Assertion-Reason (one on Pandas, one on SQL).
BQ22 to Q28214Pandas (Q22, Q28), Societal Impacts (Q23, Q27), data visualization (Q24), networks (Q25), SQL functions (Q26)
CQ29 to Q32312Societal situations, Series/DataFrame code, SQL queries with functions, output of SQL functions
DQ33, Q3448Matplotlib program, SQL with GROUP BY, HAVING and two tables
EQ35 to Q37515Network case study, DataFrame program, SQL commands in five parts

Unit-wise marks in the theory paper

Blueprint of the paper

One common blueprint, as per the CBSE Sample Question Paper 2026-27. All twenty practice papers of this kit follow it. Each cell shows the number of questions, with their marks in brackets.

Unit and topicSec A1 mark each1 mSec B2 marks each2 mSec C3 marks each3 mSec D4 marks each4 mSec E5 marks each5 mTotalmarks
Unit 1Pandas: Series, DataFrame, CSV6 (6)2 (4)1 (3)-1 (5)18
Unit 1Data Visualization (Matplotlib)1 (1)1 (2)-1 (4)-7
Unit 2SQL: functions, GROUP BY, join, commands8 (8)1 (2)2 (6)1 (4)1 (5)25
Unit 3Computer Networks3 (3)1 (2)--1 (5)10
Unit 4Societal Impacts3 (3)2 (4)1 (3)--10
Total21 (21)7 (14)4 (12)2 (8)3 (15)70

A to E are the sections; 1 m means 1 mark each. Unit 1 = 18 + 7 = 25 marks. The downloaded blueprint also has the question-wise plan from Q1 to Q37.

The fixed slots: 35 marks you can predict

In the CBSE Sample Paper 2026-27, these question numbers carry these topics. Prepare one model answer for each slot.

Q29Societal: 3 situations3 marks
Q30Series or DataFrame code3 marks
Q31SQL queries with functions3 marks
Q32Output of SQL functions3 marks
Q33Matplotlib chart program4 marks
Q34GROUP BY, HAVING, join4 marks
Q35Network case study5 marks
Q36DataFrame program5 marks
Q37SQL commands, 5 parts5 marks

Internal choice (OR) is given in seven questions: Q22, Q25, Q28, Q30, Q32, Q34 and Q37.

Practical: 30 marks

2

Pass plan in three steps

Where the 70 marks come from, easiest first

Marks come fastest from the questions that follow a fixed model. Climb the ladder one step at a time.

Step 1 · 23 marksSocietal Impacts (10) + Networks (10) + data visualization short answer and one-markers (3). Mostly definitions, differences and the case study. Learn the tables in sections 8 and 9.
Step 2 · 20 marks moreSQL functions and queries: the three function families, GROUP BY and HAVING, equi-join, and the five commands INSERT, UPDATE, DELETE, ALTER, DROP.
Step 3 · 17 marks morePandas programs: create a Series and a DataFrame, add or remove rows and columns, head and tail, CSV, and one Matplotlib program.
Marks milne wali baat
  • Write import pandas as pd and import matplotlib.pyplot as plt at the top of every program.
  • In SQL output questions, write the column heading also.
  • In the case study, give the reason with every answer.
Common mistake
  • axis=0 is row, axis=1 is column. Do not mix them.
  • loc includes the end label; iloc leaves the stop out.
  • HAVING is for groups; WHERE is for rows.
  • In SQL functions, counting of characters starts from 1, not 0.
3

Pandas Series

Unit 1 · one-dimensional labelled data

Pandas is a Python library for working with data in rows and columns. It gives two data structures: the Series (one column of data) and the DataFrame (a full table).

import pandas as pd

Picture: a Series is one column with labels

A Series has two parts: the index (labels) and the values. If you do not give labels, Pandas gives 0, 1, 2 ...

S = pd.Series([50, 20, 40, 10], index=['a', 'b', 'c', 'd'])

a500
b201
c402
d103

Top: labels. Middle: values. Bottom: positions.

In daily life: A marks list: the names of the students are the labels and the marks are the values.

Four ways to create a Series

FromStatementWhat you get
a listpd.Series([10, 20, 30])index 0, 1, 2
a list with labelspd.Series([10, 20], index=['a', 'b'])index 'a', 'b'
a dictionarypd.Series({'Jan': 31, 'Feb': 28})keys become the index
one valuepd.Series(5, index=[0, 1, 2])the value is repeated for every label
a NumPy arraypd.Series(np.array([1, 2, 3]))index 0, 1, 2

Picture: slicing by position and slicing by label

S[1:3] takes positions 1 and 2. Position 3 is left out.

a500
b201
c402
d103

S['b':'d'] takes the labels b, c and d. The end label is included.

a500
b201
c402
d103

In daily life: Positions work like house numbers on one side of a lane: stop before the last number. Labels work like names: from Bela to Devi means Devi also.

Try it Series slicing lab

S = pd.Series([50, 20, 40, 10, 30], index=['a', 'b', 'c', 'd', 'e'])

Picture: adding two Series

Pandas first matches the labels. A label that is in only one Series gets NaN (missing value).

S1

a10
b20
c30
d

S2

a
b5
c5
d5

S1 + S2

aNaN
b25.0
c35.0
dNaN

In daily life: Two shopkeepers add their stock lists. An item kept by only one of them cannot be added, so its total is left blank.

Series functions with examples

Every card has three examples. The line after >>> is what you type; the green lines are what Python shows. All the examples start from these two Series:

S = pd.Series([50, 20, 40, 10], index=['a', 'b', 'c', 'd'])
T = pd.Series([1, 2, 3], index=['b', 'c', 'e'])
Series: create, select, slice and calculate12 functions · 3 examples each
pd.Series(data, index)makes a Series from a list, a dictionary or one value
>>> pd.Series([5, 10, 15])
0     5
1    10
2    15
dtype: int64

>>> pd.Series({'Jan': 31, 'Feb': 28})
Jan    31
Feb    28
dtype: int64

>>> pd.Series(7, index=['x', 'y', 'z'])
x    7
y    7
z    7
dtype: int64
S.head(n)first n elements (5 if n is not given)
>>> S.head(2)
a    50
b    20
dtype: int64

>>> S.head(1)
a    50
dtype: int64

>>> S.head()
a    50
b    20
c    40
d    10
dtype: int64
S.tail(n)last n elements (5 if n is not given)
>>> S.tail(2)
c    40
d    10
dtype: int64

>>> S.tail(1)
d    10
dtype: int64

>>> S.tail(3)
b    20
c    40
d    10
dtype: int64
S.index and S.valuesthe labels and the values
>>> S.index
Index(['a', 'b', 'c', 'd'], dtype='object')

>>> S.values
[50 20 40 10]

>>> S.index[0]
'a'
S.size, len(S), S.count()number of elements; count() leaves out NaN
>>> S.size
4

>>> len(S)
4

>>> (S + T).count()
2
S[label], S.loc[], S.iloc[]one element by its label or by its position
>>> S['c']
40

>>> S.loc['a']
50

>>> S.iloc[3]
10
S[start:stop]slice: positions leave out the stop, labels include the end
>>> S[1:3]
b    20
c    40
dtype: int64

>>> S['b':'d']
b    20
c    40
d    10
dtype: int64

>>> S[:2]
a    50
b    20
dtype: int64
S[condition]Boolean indexing: keeps the elements where the condition is True
>>> S > 20
a     True
b    False
c     True
d    False
dtype: bool

>>> S[S > 20]
a    50
c    40
dtype: int64

>>> S[S == 10]
d    10
dtype: int64
S + n, S * narithmetic on every element
>>> S + 5
a    55
b    25
c    45
d    15
dtype: int64

>>> S * 2
a    100
b     40
c     80
d     20
dtype: int64

>>> S // 10
a    5
b    2
c    4
d    1
dtype: int64
S + Ttwo Series are matched label by label
>>> S + T
a     NaN
b    21.0
c    42.0
d     NaN
e     NaN
dtype: float64

>>> S * T
a     NaN
b    20.0
c    80.0
d     NaN
e     NaN
dtype: float64

>>> S.add(T, fill_value=0)
a    50.0
b    21.0
c    42.0
d    10.0
e     3.0
dtype: float64
S.max(), S.min(), S.sum()largest, smallest and total
>>> S.max()
50

>>> S.min()
10

>>> S.sum()
120
Changing a Seriesvalues and labels can be changed; the size cannot
>>> S['a'] = 99
>>> S
a    99
b    20
c    40
d    10
dtype: int64

>>> S.index = ['w', 'x', 'y', 'z']
>>> S
w    50
x    20
y    40
z    10
dtype: int64

>>> S[1:3] = 0
>>> S
a    50
b     0
c     0
d    10
dtype: int64
Remember
  • head() and tail() give 5 elements when no number is written.
  • A condition such as S > 20 gives True/False for every element. Put it inside S[ ] to pick the elements.
  • When NaN comes in the answer, the data type becomes float: 25 is shown as 25.0.
Common mistake
  • S.size is written without brackets. S.count() has brackets.
  • S[1:3] gives two elements, not three.
  • Writing S1 + S2 does not join the two Series one after the other. It adds the values label by label.
4

Pandas DataFrame

Unit 1 · two-dimensional labelled data

A DataFrame is a table: it has rows and columns, and both have labels. Each column is a Series, and different columns can hold different types of data.

Picture: the parts of a DataFrame

NameEngMathsR1Asha7888R2Ravi6572R3Tina9195column labels: df.columns (axis = 1 goes across)axis = 0row labels: df.indexvalues
A DataFrame has row labels (index), column labels (columns) and values. Each column is a Series.

In daily life: A class register: the roll numbers are the row labels, the subject names are the column labels.

Ways to create a DataFrame

import pandas as pd

# 1. from a dictionary of lists: keys become the column labels
df = pd.DataFrame({'Name': ['Asha', 'Ravi', 'Tina'],
                   'Eng': [78, 65, 91],
                   'Maths': [88, 72, 95]},
                  index=['R1', 'R2', 'R3'])

# 2. from a list of dictionaries: each dictionary is one row
df2 = pd.DataFrame([{'Name': 'Asha', 'Eng': 78}, {'Name': 'Ravi'}])      # Eng of Ravi becomes NaN

# 3. from a dictionary of Series
df3 = pd.DataFrame({'Eng': pd.Series([78, 65], index=['R1', 'R2']),
                    'Maths': pd.Series([88, 72], index=['R1', 'R2'])})

# 4. from a CSV file
df4 = pd.read_csv('marks.csv')

Rows and columns: add, select, delete

WorkOn a columnOn a row
Selectdf['Eng']df.loc['R2'] or df.iloc[1]
Adddf['Total'] = df['Eng'] + df['Maths']df.loc['R4'] = ['Om', 54, 61]
Deletedf = df.drop('Eng', axis=1) or del df['Eng']df = df.drop('R2', axis=0)
Renamedf = df.rename(columns={'Eng': 'English'})df = df.rename(index={'R1': 'A1'})

loc: by labels

df.loc['R1':'R2', 'Eng']

Row labels R1 to R2 (both included), column Eng.

iloc: by positions

df.iloc[0:2, 1]

Row positions 0 and 1 (2 is left out), column position 1.

DataFrame functions with examples

All the examples start from this DataFrame:

df = pd.DataFrame({'Name': ['Asha', 'Ravi', 'Tina'],
                   'Eng': [78, 65, 91],
                   'Maths': [88, 72, 95]},
                  index=['R1', 'R2', 'R3'])
DataFrame: create, look at, select and change13 functions · 3 examples each
pd.DataFrame(data)makes a DataFrame from a dictionary of lists, a list of dictionaries or a dictionary of Series
>>> pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
   A  B
0  1  3
1  2  4

>>> pd.DataFrame([{'A': 1, 'B': 3}, {'A': 2}])
   A    B
0  1  3.0
1  2  NaN

>>> pd.DataFrame({'A': pd.Series([1, 2], index=['x', 'y'])})
   A
x  1
y  2
df.shape, df.size, df.ndimrows and columns, number of values, number of dimensions
>>> df.shape
(3, 3)

>>> df.size
9

>>> df.ndim
2
df.columns, df.index, df.dtypescolumn labels, row labels and data types
>>> list(df.columns)
['Name', 'Eng', 'Maths']

>>> list(df.index)
['R1', 'R2', 'R3']

>>> df.dtypes
Name     object
Eng       int64
Maths     int64
dtype: object
df.head(n), df.tail(n)first or last n rows
>>> df.head(2)
    Name  Eng  Maths
R1  Asha   78     88
R2  Ravi   65     72

>>> df.tail(1)
    Name  Eng  Maths
R3  Tina   91     95

>>> df.head(1)
    Name  Eng  Maths
R1  Asha   78     88
df['col']one column (a Series) or a list of columns (a DataFrame)
>>> df['Eng']
R1    78
R2    65
R3    91
Name: Eng, dtype: int64

>>> df[['Name', 'Maths']]
    Name  Maths
R1  Asha     88
R2  Ravi     72
R3  Tina     95

>>> df['Eng'].max()
91
df.loc[row, col]selects by labels; the end label is included
>>> df.loc['R2']
Name     Ravi
Eng        65
Maths      72
Name: R2, dtype: object

>>> df.loc['R1':'R2', 'Eng']
R1    78
R2    65
Name: Eng, dtype: int64

>>> df.loc['R3', 'Name']
'Tina'
df.iloc[row, col]selects by positions; the stop is left out
>>> df.iloc[0]
Name     Asha
Eng        78
Maths      88
Name: R1, dtype: object

>>> df.iloc[0:2, 1:3]
    Eng  Maths
R1   78     88
R2   65     72

>>> df.iloc[2, 0]
'Tina'
df[condition]Boolean indexing: the rows where the condition is True
>>> df[df['Eng'] > 70]
    Name  Eng  Maths
R1  Asha   78     88
R3  Tina   91     95

>>> df[df['Name'] == 'Ravi']
    Name  Eng  Maths
R2  Ravi   65     72

>>> df[df['Maths'] >= 90]['Name']
R3    Tina
Name: Name, dtype: object
df['new'] = ...adds a column (or changes it, if it is already there)
>>> df['Total'] = df['Eng'] + df['Maths']
>>> df
    Name  Eng  Maths  Total
R1  Asha   78     88    166
R2  Ravi   65     72    137
R3  Tina   91     95    186

>>> df['Sec'] = 'A'
>>> df
    Name  Eng  Maths Sec
R1  Asha   78     88   A
R2  Ravi   65     72   A
R3  Tina   91     95   A

>>> df['Sci'] = [80, 60, 99]
>>> df
    Name  Eng  Maths  Sci
R1  Asha   78     88   80
R2  Ravi   65     72   60
R3  Tina   91     95   99
df.loc['label'] = [...]adds a row (or changes it, if the label is already there)
>>> df.loc['R4'] = ['Om', 54, 61]
>>> df
    Name  Eng  Maths
R1  Asha   78     88
R2  Ravi   65     72
R3  Tina   91     95
R4    Om   54     61

>>> df.loc['R2'] = ['Ravi', 70, 75]
>>> df
    Name  Eng  Maths
R1  Asha   78     88
R2  Ravi   70     75
R3  Tina   91     95

>>> df.loc['R4'] = ['Om', 54, 61]
>>> df.shape
(4, 3)
df.drop(label, axis)returns a copy without the row (axis=0) or the column (axis=1)
>>> df.drop('Eng', axis=1)
    Name  Maths
R1  Asha     88
R2  Ravi     72
R3  Tina     95

>>> df.drop('R2', axis=0)
    Name  Eng  Maths
R1  Asha   78     88
R3  Tina   91     95

>>> df.drop(['R1', 'R3'])
    Name  Eng  Maths
R2  Ravi   65     72
df.rename()returns a copy with new column labels or row labels
>>> df.rename(columns={'Eng': 'English'})
    Name  English  Maths
R1  Asha       78     88
R2  Ravi       65     72
R3  Tina       91     95

>>> df.rename(index={'R1': 'A1'})
    Name  Eng  Maths
A1  Asha   78     88
R2  Ravi   65     72
R3  Tina   91     95

>>> df.rename(columns={'Name': 'Student', 'Maths': 'M'})
   Student  Eng   M
R1    Asha   78  88
R2    Ravi   65  72
R3    Tina   91  95
df.T, len(df)transpose, and the number of rows
>>> df.T
         R1    R2    R3
Name   Asha  Ravi  Tina
Eng      78    65    91
Maths    88    72    95

>>> len(df)
3

>>> len(df.columns)
3

Going through the rows one by one

import pandas as pd
df = pd.DataFrame({'Name': ['Asha', 'Ravi', 'Tina'], 'Eng': [78, 65, 91], 'Maths': [88, 72, 95]}, index=['R1', 'R2', 'R3'])
for i, row in df.iterrows():
    print(i, row['Name'], row['Eng'] + row['Maths'])

Output:

R1 Asha 166
R2 Ravi 137
R3 Tina 186
Remember
  • df.shape is (rows, columns). df.size is rows x columns. len(df) is the number of rows.
  • A new column needs one value for every row. A new row needs one value for every column.
  • drop() and rename() give a new DataFrame. Store it back: df = df.drop(...).
Common mistake
  • df.drop('Eng') without axis=1 looks for a row named Eng and gives an error.
  • df['R1'] looks for a column named R1. For a row write df.loc['R1'].
  • df.head without brackets does not show the first five rows.
5

Importing and exporting data: CSV files

Unit 1 · between a CSV file and a DataFrame

A CSV (Comma Separated Values) file is a plain text file. Each line is one row, and the values are separated by commas. It opens in a spreadsheet, in Notepad and in Pandas, so it is the easiest way to move data from one software to another.

Picture: file to DataFrame and back

marks.csvName,MarksAsha,91DataFrame df Name Marks0 Asha 91pd.read_csv('marks.csv')df.to_csv('marks.csv')
read_csv() brings the data of a file into a DataFrame. to_csv() writes a DataFrame to a file.

In daily life: Copying the marks from the register (file) to the blackboard (DataFrame), working on them, and writing the result back in the register.

Writing: to_csv()

df.to_csv('marks.csv')

marks.csv (row labels are also written):

,Name,Eng,Maths
R1,Asha,78,88
R2,Ravi,65,72
R3,Tina,91,95
df.to_csv('marks2.csv', index=False)

marks2.csv (no row labels):

Name,Eng,Maths
Asha,78,88
Ravi,65,72
Tina,91,95

Reading: read_csv()

import pandas as pd
df = pd.read_csv('marks2.csv')
print(df)

Output:

   Name  Eng  Maths
0  Asha   78     88
1  Ravi   65     72
2  Tina   91     95

Pandas gives the default row labels 0, 1, 2.

Parameters asked in the paper

FunctionParameterUse
read_csv()septhe separator used in the file, for example sep=';'. The default is a comma.
read_csv()header=Nonethe file has no heading line; the first line is data
read_csv()names=[...]your own column names
to_csv()index=Falsedo not write the row labels
to_csv()header=Falsedo not write the column names
to_csv()sepwrite with another separator
6

Data visualization with Matplotlib

Unit 1 · line plot, bar graph and histogram

Data visualization means showing data as a picture: a chart or a graph. A picture shows the highest value, the lowest value and the trend at one look. In Python we use the pyplot module of the Matplotlib library.

import matplotlib.pyplot as plt

Picture: the parts of a chart

Monthly Salestitle()Monthxlabel()Salesylabel()2026legend()plot()show() displays the chart; savefig() saves it

In daily life: A chart without a title and axis labels is like a map without place names.

Which chart for which data

ChartFunctionUse it whenExample
Line chartplt.plot(x, y)you want to show a change or trend over timesales of 12 months
Bar chartplt.bar(x, height)
plt.barh(y, width)
you want to compare separate categoriesstudents in four houses
Histogramplt.hist(data, bins)you want to see how numeric values are spread over rangesmarks of 200 students in ranges of 10

Four model programs with their charts

Line chart: change over time

import matplotlib.pyplot as plt
month = ['Jan', 'Feb', 'Mar', 'Apr', 'May']
sales = [30, 45, 40, 60, 75]
plt.plot(month, sales, color='blue', marker='o')
plt.title('Monthly Sales')
plt.xlabel('Month')
plt.ylabel('Sales (in thousand Rs)')
plt.show()
Line chart: change over time

Bar chart: compare categories

import matplotlib.pyplot as plt
house = ['Shivaji', 'Tagore', 'Raman', 'Ashoka']
points = [85, 60, 95, 70]
plt.bar(house, points, color='green')
plt.title('House Points')
plt.xlabel('House')
plt.ylabel('Points')
plt.show()
Bar chart: compare categories

Histogram: how the values are spread

import matplotlib.pyplot as plt
marks = [35, 42, 48, 55, 58, 61, 64, 66, 70, 72, 75, 78, 81, 85, 92]
plt.hist(marks, bins=[30, 40, 50, 60, 70, 80, 90, 100], edgecolor='black')
plt.title('Marks of 15 Students')
plt.xlabel('Marks')
plt.ylabel('Number of Students')
plt.show()
Histogram: how the values are spread

Two lines with a legend

import matplotlib.pyplot as plt
test = ['UT1', 'UT2', 'UT3', 'UT4']
asha = [32, 35, 30, 38]
ravi = [25, 31, 34, 36]
plt.plot(test, asha, label='Asha')
plt.plot(test, ravi, label='Ravi', linestyle='--')
plt.title('Marks in Unit Tests')
plt.xlabel('Test')
plt.ylabel('Marks')
plt.legend()
plt.savefig('marks.png')
plt.show()
Two lines with a legend

Functions and parameters to remember

Function or parameterWork
plt.title("...")heading of the chart
plt.xlabel("..."), plt.ylabel("...")labels of the X-axis and Y-axis
plt.legend()shows the key; give label= in every plot()
plt.grid(True)grid lines
plt.savefig("a.png")saves the chart as a picture; write it before show()
plt.show()displays the chart
colorcolour: 'r', 'g', 'b', 'k' (black) or a name such as 'orange'
linestyle'-' solid, '--' dashed, ':' dotted, '-.' dash-dot
linewidththickness of the line
marker, markersizesymbol on each point: 'o' circle, '*' star, 's' square, 'D' diamond
width (in bar)thickness of the bars; default 0.8
bins (in hist)number of intervals, or the list of interval edges; default 10
edgecolorcolour of the border of bars

Bar chart and histogram: the difference

  • A bar chart is for categories (names); a histogram is for numbers in ranges.
  • Bars of a bar chart have gaps; bars of a histogram touch.
  • In a bar chart you give the heights; in a histogram Python counts the values in each range.
Common mistake
  • Writing plt.savefig() after plt.show() saves a blank picture.
  • plt.legend() shows nothing if label is not given in plot().
  • The two lists given to plot() or bar() must have the same number of values.
7

Database query using SQL

Unit 2 · functions, grouping and two tables

Unit 2 is about asking questions from a table with SQL. Three things are new in Class XII: functions (math, text, date), aggregate functions with GROUP BY, and two tables with equi-join.

Picture: two kinds of functions

ashaASHAraviRAVItinaTINAUCASE(Name): 3 rows in, 3 rows out91557891MAX(Marks): 3 rows in, 1 row out
A single-row function gives one answer for every row. An aggregate function gives one answer for the whole group.

In daily life: Changing every name on a list to capital letters is single-row work. Finding the topper of the list is aggregate work.

All the examples below use these two tables. Every example starts again from the same data.

Table: student

RNoNameCityMarksFeeDOB
1AshaDelhi915000.502009-03-15
2RaviAgra554500.752008-11-02
3TinaDelhi78NULL2009-07-21
4OmAgra825000.502008-01-30
5ZoyaPune674000.252009-12-09

Table: city

CityState
DelhiDelhi
AgraUttar Pradesh
PuneMaharashtra

Math, text and date functions with examples

Math functions3 functions · 3 examples each
POWER(a, b)a raised to the power b. POW() is the same
SELECT POWER(2, 5);
POWER(2, 5)
32
SELECT POWER(9, 2);
POWER(9, 2)
81
SELECT Name, POWER(Marks, 2) FROM student WHERE RNo = 2;
NamePOWER(Marks, 2)
Ravi3025
ROUND(x, d)rounds x to d decimal places; no d means a whole number
SELECT ROUND(45.678, 1);
ROUND(45.678, 1)
45.7
SELECT ROUND(45.678);
ROUND(45.678)
46
SELECT ROUND(1256.78, -2);
ROUND(1256.78, -2)
1300
MOD(a, b)the remainder when a is divided by b
SELECT MOD(17, 5);
MOD(17, 5)
2
SELECT MOD(20, 4);
MOD(20, 4)
0
SELECT Name, MOD(Marks, 10) FROM student WHERE City = 'Agra';
NameMOD(Marks, 10)
Ravi5
Om2

Picture: counting characters for MID, LEFT, RIGHT and INSTR

In SQL the first character is at position 1. A space is also a character.

MID('Informatics', 3, 4) starts at position 3 and takes 4 characters: form

1I
2n
3f
4o
5r
6m
7a
8t
9i
10c
11s

LEFT('Informatics', 4) gives Info and RIGHT('Informatics', 3) gives ics

1I
2n
3f
4o
5r
6m
7a
8t
9i
10c
11s

INSTR('Informatics', 'ma') gives 6, the position where ma starts

1I
2n
3f
4o
5r
6m
7a
8t
9i
10c
11s
Text functions10 functions · 3 examples each
UCASE(text) / UPPER(text)changes to capital letters
SELECT UCASE('kvs');
UCASE("kvs")
KVS
SELECT UPPER('New Delhi');
UPPER("New Delhi")
NEW DELHI
SELECT UCASE(Name) FROM student WHERE City = 'Delhi';
UCASE(Name)
ASHA
TINA
LCASE(text) / LOWER(text)changes to small letters
SELECT LCASE('CBSE');
LCASE("CBSE")
cbse
SELECT LOWER('New Delhi');
LOWER("New Delhi")
new delhi
SELECT LCASE(City) FROM student WHERE RNo < 3;
LCASE(City)
delhi
agra
MID(text, start, n) / SUBSTRING() / SUBSTR()n characters from the position start; counting starts at 1
SELECT MID('Informatics', 3, 4);
MID("Informatics", 3, 4)
form
SELECT SUBSTRING('Practices', 1, 5);
SUBSTRING("Practices", 1, 5)
Pract
SELECT SUBSTR(Name, 2, 2) FROM student WHERE City = 'Delhi';
SUBSTR(Name, 2, 2)
sh
in
LENGTH(text)the number of characters, spaces included
SELECT LENGTH('Pandas');
LENGTH("Pandas")
6
SELECT LENGTH('New Delhi');
LENGTH("New Delhi")
9
SELECT Name, LENGTH(Name) FROM student WHERE Marks > 80;
NameLENGTH(Name)
Asha4
Om2
LEFT(text, n)the first n characters
SELECT LEFT('Informatics', 4);
LEFT("Informatics", 4)
Info
SELECT LEFT('Delhi', 1);
LEFT("Delhi", 1)
D
SELECT LEFT(City, 3) FROM student WHERE RNo <= 2;
LEFT(City, 3)
Del
Agr
RIGHT(text, n)the last n characters
SELECT RIGHT('Informatics', 3);
RIGHT("Informatics", 3)
ics
SELECT RIGHT('2026-27', 2);
RIGHT("2026-27", 2)
27
SELECT RIGHT(Name, 2) FROM student WHERE City = 'Agra';
RIGHT(Name, 2)
vi
Om
INSTR(text, part)the position of the first match; 0 if not found
SELECT INSTR('Informatics', 'ma');
INSTR("Informatics", "ma")
6
SELECT INSTR('Pandas', 'a');
INSTR("Pandas", "a")
2
SELECT INSTR('Pandas', 'x');
INSTR("Pandas", "x")
0
LTRIM(text)removes the spaces on the left
SELECT LTRIM('   KV');
LTRIM(" KV")
KV
SELECT LENGTH(LTRIM('  KV  '));
LENGTH(LTRIM(" KV "))
4
SELECT LENGTH('  KV  ');
LENGTH(" KV ")
6
RTRIM(text)removes the spaces on the right
SELECT RTRIM('KV   ');
RTRIM("KV ")
KV
SELECT LENGTH(RTRIM('  KV  '));
LENGTH(RTRIM(" KV "))
4
SELECT LENGTH(RTRIM('KV '));
LENGTH(RTRIM("KV "))
2
TRIM(text)removes the spaces on both sides; spaces inside stay
SELECT TRIM('  KV  ');
TRIM(" KV ")
KV
SELECT LENGTH(TRIM('  KV  '));
LENGTH(TRIM(" KV "))
2
SELECT LENGTH(TRIM('  New Delhi '));
LENGTH(TRIM(" New Delhi "))
9
Date functions7 functions · 3 examples each
NOW()the current date and time of the computer
SELECT NOW();

Shows the date and time of that moment, for example 2026-11-13 10:30:45.

SELECT DATE(NOW());

Shows only today's date, for example 2026-11-13.

SELECT YEAR(NOW());

Shows the current year, for example 2026.

DATE(datetime)takes out the date part
SELECT DATE('2026-11-13 10:30:45');
DATE("2026-11-13 10:30:45")
2026-11-13
SELECT DATE('2027-03-01 08:00:00');
DATE("2027-03-01 08:00:00")
2027-03-01
SELECT Name, DATE(DOB) FROM student WHERE RNo = 1;
NameDATE(DOB)
Asha2009-03-15
MONTH(date)the month number, 1 to 12
SELECT MONTH('2026-11-13');
MONTH("2026-11-13")
11
SELECT MONTH('2027-03-01');
MONTH("2027-03-01")
3
SELECT Name, MONTH(DOB) FROM student WHERE City = 'Delhi';
NameMONTH(DOB)
Asha3
Tina7
MONTHNAME(date)the name of the month
SELECT MONTHNAME('2026-11-13');
MONTHNAME("2026-11-13")
November
SELECT MONTHNAME('2027-03-01');
MONTHNAME("2027-03-01")
March
SELECT Name, MONTHNAME(DOB) FROM student WHERE City = 'Agra';
NameMONTHNAME(DOB)
RaviNovember
OmJanuary
YEAR(date)the year
SELECT YEAR('2026-11-13');
YEAR("2026-11-13")
2026
SELECT Name FROM student WHERE YEAR(DOB) = 2008;
Name
Ravi
Om
SELECT Name, YEAR(DOB) FROM student WHERE Marks > 80;
NameYEAR(DOB)
Asha2009
Om2008
DAY(date)the day of the month, 1 to 31
SELECT DAY('2026-11-13');
DAY("2026-11-13")
13
SELECT DAY('2027-03-01');
DAY("2027-03-01")
1
SELECT Name, DAY(DOB) FROM student WHERE City = 'Pune';
NameDAY(DOB)
Zoya9
DAYNAME(date)the name of the week day
SELECT DAYNAME('2026-11-13');
DAYNAME("2026-11-13")
Friday
SELECT DAYNAME('2027-01-26');
DAYNAME("2027-01-26")
Tuesday
SELECT Name, DAYNAME(DOB) FROM student WHERE RNo <= 2;
NameDAYNAME(DOB)
AshaSunday
RaviSunday

Try it SQL function tester

Aggregate functions, GROUP BY, HAVING, ORDER BY and equi-join

Picture: how GROUP BY makes groups

Asha Delhi 91Ravi Agra 55Tina Delhi 78Om Agra 82Zoya Pune 67Delhi91, 78Agra55, 82Pune67Delhi 2Agra 2Pune 1City, COUNT(*)
GROUP BY City puts the rows of the same city together. The aggregate function then works on each group, and HAVING can drop some groups.

In daily life: Counting the students of each house: first make the children stand house-wise, then count each line.

Aggregate functions5 functions · 3 examples each
MAX(column)the largest value
SELECT MAX(Marks) FROM student;
MAX(Marks)
91
SELECT MAX(Name) FROM student;
MAX(Name)
Zoya
SELECT MAX(DOB) FROM student;
MAX(DOB)
2009-12-09
MIN(column)the smallest value
SELECT MIN(Marks) FROM student;
MIN(Marks)
55
SELECT MIN(Fee) FROM student;
MIN(Fee)
4000.25
SELECT MIN(Marks) FROM student WHERE City = 'Delhi';
MIN(Marks)
78
AVG(column)the average; NULL is left out
SELECT AVG(Marks) FROM student;
AVG(Marks)
74.6000
SELECT AVG(Marks) FROM student WHERE City = 'Agra';
AVG(Marks)
68.5000
SELECT ROUND(AVG(Marks), 1) FROM student;
ROUND(AVG(Marks), 1)
74.6
SUM(column)the total; NULL is left out
SELECT SUM(Marks) FROM student;
SUM(Marks)
373
SELECT SUM(Fee) FROM student;
SUM(Fee)
18502.00
SELECT SUM(Marks) FROM student WHERE City = 'Delhi';
SUM(Marks)
169
COUNT()COUNT(*) counts rows; COUNT(column) leaves out NULL
SELECT COUNT(*) FROM student;
COUNT(*)
5
SELECT COUNT(Fee) FROM student;
COUNT(Fee)
4
SELECT COUNT(DISTINCT City) FROM student;
COUNT(DISTINCT City)
3
Grouping, ordering and joining4 functions · 3 examples each
GROUP BYmakes one group for each different value; one output row per group
SELECT City, COUNT(*)
  FROM student GROUP BY City;
CityCOUNT(*)
Agra2
Delhi2
Pune1
SELECT City, MAX(Marks)
  FROM student GROUP BY City;
CityMAX(Marks)
Agra82
Delhi91
Pune67
SELECT City, SUM(Marks)
  FROM student GROUP BY City;
CitySUM(Marks)
Agra137
Delhi169
Pune67
HAVINGkeeps only the groups that pass the condition
SELECT City, COUNT(*)
  FROM student
  GROUP BY City HAVING COUNT(*) > 1;
CityCOUNT(*)
Agra2
Delhi2
SELECT City, SUM(Marks)
  FROM student
  GROUP BY City HAVING SUM(Marks) > 100;
CitySUM(Marks)
Agra137
Delhi169
SELECT City, MAX(Marks)
  FROM student
  GROUP BY City HAVING MAX(Marks) < 90;
CityMAX(Marks)
Agra82
Pune67
ORDER BYsorts the output; ascending unless DESC is written
SELECT Name, Marks FROM student ORDER BY Marks;
NameMarks
Ravi55
Zoya67
Tina78
Om82
Asha91
SELECT Name, Marks FROM student ORDER BY Marks DESC;
NameMarks
Asha91
Om82
Tina78
Zoya67
Ravi55
SELECT City, Name FROM student ORDER BY City, Name;
CityName
AgraOm
AgraRavi
DelhiAsha
DelhiTina
PuneZoya
Equi-join of two tablesjoins the rows that have the same value in the common column
SELECT Name, State
  FROM student, city
  WHERE student.City = city.City;
NameState
AshaDelhi
RaviUttar Pradesh
TinaDelhi
OmUttar Pradesh
ZoyaMaharashtra
SELECT Name, Marks, State
  FROM student, city
  WHERE student.City = city.City AND Marks > 80;
NameMarksState
Asha91Delhi
Om82Uttar Pradesh
SELECT State, COUNT(*)
  FROM student, city
  WHERE student.City = city.City GROUP BY State;
StateCOUNT(*)
Delhi2
Maharashtra1
Uttar Pradesh2

Try it LIKE pattern tester

% stands for any number of characters, _ stands for exactly one character. MySQL ignores capital and small letters while matching.

The order of clauses in a query

SELECT>FROM>WHERE>GROUP BY>HAVING>ORDER BY

Picture: how one SELECT query works, step by step

SELECT city, COUNT(*) FROM student
WHERE marks > 60
GROUP BY city
HAVING COUNT(*) > 1;
1
FROM student

Take the whole table.

namecitymarks
AshaDelhi91
RaviAgra55
TinaDelhi78
OmAgra82
ZoyaPune67
2
WHERE marks > 60

Keep only the rows that pass the condition. Ravi (55) goes out.

namecitymarks
AshaDelhi91
TinaDelhi78
OmAgra82
ZoyaPune67
3
GROUP BY city

Put the rows of the same city together.

cityrows in the group
DelhiAsha, Tina
AgraOm
PuneZoya
4
HAVING COUNT(*) > 1

Keep only the groups that pass the condition.

cityrows in the group
DelhiAsha, Tina
5
SELECT city, COUNT(*)

Show the asked columns. This is the output.

cityCOUNT(*)
Delhi2

In daily life: Sorting answer sheets: take all sheets, remove the absent ones (WHERE), make bundles class-wise (GROUP BY), keep only the big bundles (HAVING), and write the count of each bundle.

Differences asked again and again

FirstSecond
WHERE / HAVINGWHERE puts a condition on rows, before grouping. No aggregate function in it.HAVING puts a condition on groups, after GROUP BY. Aggregate functions are allowed.
Single-row / aggregateWorks on one row at a time and gives one result per row: ROUND(), UCASE(), MONTH().Works on many rows and gives one result: SUM(), AVG(), MAX(), MIN(), COUNT().
COUNT(*) / COUNT(col)Counts all the rows.Counts only the rows where the column is not NULL.
ORDER BY / GROUP BYSorts the output rows.Makes one output row for each group.
DELETE / DROPDML: removes rows; the table stays.DDL: removes the whole table with its structure.
UPDATE / ALTERDML: changes the data in rows.DDL: changes the structure, for example adds a column.
LTRIM / RTRIM / TRIMLTRIM removes spaces on the left; RTRIM on the right.TRIM removes them on both sides.
DAY / DAYNAMEDAY() gives the date number, 1 to 31.DAYNAME() gives the name of the week day.

The five commands of the 5-mark question

INSERT INTO student VALUES (6, 'Kabir', 'Pune', 74, 4200.00, '2009-05-05');     -- add a row
UPDATE student SET Marks = Marks + 5 WHERE City = 'Agra';                      -- change values
DELETE FROM student WHERE Marks < 60;                                          -- remove rows
ALTER TABLE student ADD Email VARCHAR(40);                                     -- add a column
DROP TABLE student;                                                            -- remove the table
Remember
  • Text and dates are written in quotes; numbers are not.
  • Every column written in SELECT with an aggregate function should also be in GROUP BY.
  • In an equi-join, write the common column with the table name: student.City = city.City.
Common mistake
  • WHERE SUM(Marks) > 100 is wrong. Use HAVING.
  • = NULL is wrong. Use IS NULL.
  • Forgetting the join condition gives every row of one table with every row of the other (Cartesian product).
  • UPDATE or DELETE without WHERE changes all the rows.
8

Introduction to computer networks

Unit 3 · 10 marks: 3 one-markers, one 2-mark question and the case study

A computer network is a group of computers and devices connected to each other to share data and resources such as printers and the Internet.

Picture: networks by the area they cover

WAN: country or the whole world (the Internet)MAN: one cityLAN: one building or campusPAN: aroundone person
TypeFull formAreaExample
PANPersonal Area Networkaround one person, about 10 mphone and Bluetooth earbuds
LANLocal Area Networka room, building or campusthe computer lab of a school
MANMetropolitan Area Networka citycable TV network, branches of a bank in one city
WANWide Area Networkcountries and continentsthe Internet

Network devices

DeviceWorkRemember it as
Modemchanges digital signals to analog and back, to connect to the Internet lineMOdulator-DEModulator
Hubconnects the computers of a LAN; sends the data to all of themthe loudspeaker
Switchconnects the computers of a LAN; sends the data only to the right computerthe postman
Repeatermakes a weak signal strong again; used when the cable is longer than about 100 mthe booster
Routerconnects different networks and chooses the best path for the datathe traffic police
Gatewayconnects two networks that use different protocolsthe translator at the gate

Picture: where each device sits

InternetModemRouterSwitchPCPCPCRepeaterlong cable toa far blockModem: joins the Internet lineRouter: joins two networksSwitch: joins the PCs of a blockRepeater: makes a weaksignal strong again
From the Internet to your PC: modem, then router, then switch.

Picture: hub and switch

HubPCPCPCsends to ALLSwitchPCPCPCsends to ONE
A hub repeats the data to every PC. A switch sends it only to the PC it is meant for.

In daily life: A hub is like announcing a message on the school speaker: everybody hears it. A switch is like handing a letter to one student.

Network topologies

Topology is the way in which the computers of a network are connected.

Star
PCPCPCPCSwitch
Every computer has its own cable to a central switch or hub.
Bus
PCPCPCPCbackbone cable
All the computers share one main cable.
Tree
HubHubMain hub
Star groups are joined to a main device, like branches.
Mesh
PCPCPCPC
Every computer is joined to every other computer.
TopologyGood pointWeak point
StarOne computer or cable fails, the others keep working. A fault is easy to find.If the central device fails, the whole network stops. Needs more cable.
BusLeast cable, cheapest, easy to set up.If the main cable breaks, the whole network stops. Slow when traffic is heavy.
TreeEasy to add a new group of computers.If the main cable or main hub fails, the groups are cut off.
MeshVery reliable: data has many paths.Needs the most cable, so it is the costliest.

Internet, Web and its applications

Internet

The worldwide network of networks: the cables, devices and connections.

World Wide Web (WWW)

A service on the Internet: linked web pages that we open in a browser.

URL

Uniform Resource Locator: the unique address of a page.

https://www.cbse.gov.in/index.html

protocol · domain name · file name

Applications

  • Web: opening websites
  • E-mail: letters and files to a mail address
  • Chat: live typed messages
  • VoIP: voice calls over the Internet (Voice over Internet Protocol)

Picture: what happens when you open a website

You typethe URLWebbrowserDomain nameto IP addressWebserverthe server sends the web page back by HTTP / HTTPS
The domain name is changed into the IP address of the web server, and the server sends the page.

Websites

TermMeaning
Web pageone document on the Web, with its own URL
Websitea collection of related web pages under one domain name; its first page is the home page
Static web pagesame content for every visitor; made with HTML; changes only when the developer edits it. Example: the "About us" page of a school
Dynamic web pagecontent changes with the user, time or data; uses scripts and a database. Example: a result page, a shopping cart
Web serverthe computer that stores a website and sends its pages to browsers
Web hostingthe service of keeping a website on a web server so that anyone can open it on the Internet

Web browsers

TermMeaning
Web browserthe program that asks for web pages and shows them: Google Chrome, Mozilla Firefox, Microsoft Edge, Safari
Browser settingshome page, default search engine, clear history and cookies, block pop-ups, saved passwords, private (incognito) window
Add-on (extension)a small program that adds a feature to the browser, such as an ad blocker
Plug-ina program that helps the browser show content it cannot handle on its own, such as some video or document formats
Cookiessmall text files that a website saves on the user's computer to remember login, language or cart items. They are not viruses, but they can affect privacy.

The case study: five answers, five rules

Rules

  • Server: in the block with the most computers.
  • Cable layout: star, from the server block to the other blocks.
  • Switch or hub: one in every block.
  • Repeater: on a cable longer than about 100 m.
  • Type of network: inside one campus it is a LAN; between cities it is a WAN.
  • Website that shows different data to each user: dynamic.
Remember

Write the reason with every answer. "Block D, because it has the maximum number of computers (150)" gets the full mark; "Block D" alone may not.

Try it Case-study solver

Type the block names, number of computers and distances from any question.

9

Societal impacts

Unit 4 · 10 marks from definitions, differences and situations

Unit 4 is about using technology safely, legally and politely. Most answers are short definitions and differences, so this is the easiest 10 marks of the paper.

Digital footprint

The trail of data we leave behind when we use the Internet. It stays for a very long time, even after we delete a post.

Active digital footprint

Data we share on purpose.

Posts, comments, e-mails, filled forms
Passive digital footprint

Data collected without our action.

Sites visited, location, search history, cookies

Net etiquettes (netiquette)

Be ethical
  • No piracy, no plagiarism
  • Share only true and useful knowledge
Be respectful
  • Respect privacy
  • Respect different views; be polite
Be responsible
  • No cyber bullying
  • Do not feed the troll
  • Think before you post
Be secure and credible
  • Strong passwords; know who you befriend
  • Check a message before forwarding it

Data protection and Intellectual Property Rights (IPR)

Data protection means keeping personal data (name, Aadhaar number, bank details, photos) safe from misuse. IPR are the legal rights of a person over the creations of the mind.

RightProtectsExampleRemember
Copyrightoriginal creative workbook, song, film, software, photographgiven automatically to the creator
Patentan inventiona new machine or medicinemust be applied for; valid for 20 years
Trademarkname, logo or symbol of a brandlogo of a shoe companycan be renewed again and again

Plagiarism

Using the work or idea of another person as your own, without giving credit.

Avoid it: write in your own words, name the source, use quotation marks for copied lines.

Licensing

A licence is the legal permission that tells how a work or software may be used.

Public licences: GNU GPL, Creative Commons (CC), Apache.

Free and open source software (FOSS)

Free and open source softwareProprietary software
Source codegiven to everyonekept secret by the company
Costfree to usea licence must be bought
Changing and sharingallowednot allowed
ExamplesLinux, LibreOffice, Python, Mozilla Firefox, MySQLMicrosoft Windows, Microsoft Office, Adobe Photoshop

Cyber crime and cyber laws

Hacking

Getting into a computer or account without permission.

Ethical hackers do it with permission, to find weak points.
Phishing

A fake e-mail, message or website that looks real and asks for passwords or bank details.

Never share OTP, PIN or password.
Cyber bullying

Troubling, insulting or threatening someone online again and again.

Do not reply; keep proof; block; tell an elder.
Cyber law: IT Act, 2000

The Information Technology Act, 2000 (amended in 2008) gives legal recognition to electronic records and digital signatures, and fixes the punishment for cyber crimes.

E-waste: hazards and management

E-waste is discarded electrical and electronic equipment: old phones, computers, batteries, chargers. It has lead, mercury and cadmium, which poison the soil, water and air.

Reduce: buy only when needed>Reuse or refurbish: repair, donate>Recycle: give to an authorised recycler

Health concerns of using technology

ProblemCausePrevention
Eye strain, headachelooking at a screen for long hourslook away at regular intervals; keep the screen at arm's length; blink often
Back and neck painwrong posturesit straight; screen at eye level; feet flat on the floor
Pain in wrists and fingers (repetitive strain injury)typing or gaming for long hourskeep the wrists straight; take short breaks
Poor sleep, stress, addictiontoo much screen time, mostly at nightfix a time limit; play outdoor games; no screen before sleeping
Remember
  • In a situation-based question, first name the act (phishing, plagiarism ...), then write one line of reason.
  • Patent is for an invention, copyright is for a creation, trademark is for a brand.
Common mistake
  • Free software does not mean "no rules". It also has a licence.
  • Freeware is free of cost, but its source code is not given. It is not open source.
  • Recycling and refurbishing are different: recycling breaks the item into materials; refurbishing repairs the same item.
10

Question bank: every type, with answers

1121 questions in 20 types, arranged in the order of the CBSE Sample Paper 2026-27

SQP 2026-27 32 questions follow the CBSE sample paper (shortened and reworded) Practice 1089 written on the same pattern

Tap a type to open it. In Section A, tap an option to check yourself. Every Pandas output, chart and SQL output shown in the answers was produced by running the code.

Section A · 1 mark each

A1Pandas: MCQ and True/False1 mark · 144 questions
A1.1SQP 2026-271 mark

State True or False: A Series S1 has the index 'a', 'b', 'c', 'd', 'e'. S1['b':'d'] and S1[1:3] give the same elements.

Answer

(b) False Slicing with labels includes the end label, so S1['b':'d'] gives b, c, d. Slicing with positions leaves the stop out, so S1[1:3] gives only b, c.

A1.2SQP 2026-271 mark

What does pd.Series(5, index=[0, 1, 2]) create?

Answer

(a) A Series of three elements, each equal to 5 A single (scalar) value is repeated for every index label.

A1.3SQP 2026-271 mark

Two Series are added. A label is present in only one of them. What is stored against that label in the result?

Answer

(a) NaN Pandas matches labels first. Where a label has no partner, the result is NaN.

A1.4SQP 2026-271 mark

Which parameter of to_csv() stops the row labels (index) from being written to the file?

Answer

(a) index=False df.to_csv('f.csv', index=False) writes only the columns, without the row labels.

A1.5SQP 2026-271 mark

A DataFrame is made from a list of dictionaries. The keys of the dictionaries become the

Answer

(c) column labels Each dictionary is one row; its keys are the column names.

A1.6Practice1 mark

State True or False: The columns of a DataFrame can have different data types.

Answer

(a) True Each column has its own dtype, e.g. Name (object) and Marks (int64) in one DataFrame.

A1.7Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([17, 38, 8, 23, 5], index=['A', 'B', 'C', 'D', 'E'])
print((S * 2)['B'])
Answer

(a) 76 Every element is doubled.

A1.8Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([80, 115, 170, 75, 140], index=['P1', 'P2', 'P3', 'P4', 'P5'])
print(S[1:3].sum())
Answer

(a) 285 Positions 1 and 2 are taken; position 3 is left out.

A1.9Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([84, 118, 34, 79, 55], index=['Rohit', 'Virat', 'Gill', 'Rahul', 'Pant'])
print(S[1:3].sum())
Answer

(b) 152 Positions 1 and 2 are taken; position 3 is left out.

A1.10Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Class': ['IX', 'X', 'XI', 'XII'],
                   'Boys': [29, 28, 24, 20],
                   'Girls': [18, 13, 14, 26]},
                  index=['C1', 'C2', 'C3', 'C4'])
print(df['Girls'].sum())
Answer

(b) 71 Working: df['Girls'] = [C1: 18, C2: 13, C3: 14, C4: 26]; df['Girls'].sum() adds the values = 71.

A1.11Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([600, 1200, 1400, 900, 1000], index=['Yoga', 'Dance', 'Music', 'Art', 'Chess'])
print(S.max())
Answer

(c) 1400 Working: S.max() gives the largest value = 1400.

A1.12Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([6, 17, 19, 30, 26], index=['Delhi', 'Pune', 'Agra', 'Kochi', 'Leh'])
print(len(S[S < 19]))
Answer

(b) 2 Working: S < 19 is True for Delhi (6), Pune (17), so S[S < 19] keeps 2 values; len(S[S < 19]) = 2.

A1.13Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'House': ['Shivaji', 'Tagore', 'Raman', 'Ashoka'],
                   'Gold': [9, 11, 7, 8],
                   'Silver': [3, 6, 7, 12]},
                  index=['H1', 'H2', 'H3', 'H4'])
print(df.T.shape)
Answer

(c) (3, 4) The transpose turns 4 rows and 3 columns into 3 rows and 4 columns.

A1.14Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([240, 300, 170, 20, 190], index=['Jun', 'Jul', 'Aug', 'Sep', 'Oct'])
print(S.min() + S.max())
Answer

(c) 320 Working: S.min() gives the smallest value = 20; S.max() gives the largest value = 300; 20 + 300 = 320.

A1.15Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([84, 118, 34, 79, 55], index=['Rohit', 'Virat', 'Gill', 'Rahul', 'Pant'])
print(S['Virat':'Rahul'].sum())
Answer

(c) 231 With labels, the end label is included.

A1.16Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Team': ['Alpha', 'Beta', 'Gamma', 'Delta'],
                   'Round1': [30, 40, 15, 25],
                   'Round2': [50, 10, 25, 35]},
                  index=['Q1', 'Q2', 'Q3', 'Q4'])
print(df.iloc[2, 1])
Answer

(d) 15 Row position 2 is the third row; column position 1 is the second column.

A1.17Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([84, 118, 34, 79, 55], index=['Rohit', 'Virat', 'Gill', 'Rahul', 'Pant'])
print((S * 2)['Virat'])
Answer

(d) 236 Every element is doubled.

A1.18Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([70, 60, 75, 20, 15], index=['Eng', 'Hin', 'Maths', 'Sci', 'IP'])
print(S.tail(2).max())
Answer

(c) 20 tail(2) takes the last two elements.

A1.19Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([17, 38, 8, 23, 5], index=['A', 'B', 'C', 'D', 'E'])
print(len(S[S < 17]))
Answer

(d) 2 Working: S < 17 is True for C (8), E (5), so S[S < 17] keeps 2 values; len(S[S < 17]) = 2.

A1.20Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Item': ['Samosa', 'Tea', 'Juice', 'Sandwich'],
                   'Price': [20, 30, 55, 60],
                   'Sold': [140, 20, 90, 60]},
                  index=['C1', 'C2', 'C3', 'C4'])
print(df.shape)
Answer

(b) (4, 3) shape gives (rows, columns).

A1.21Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([240, 300, 170, 20, 190], index=['Jun', 'Jul', 'Aug', 'Sep', 'Oct'])
print(S.head(2).sum())
Answer

(d) 540 head(2) takes the first two elements.

A1.22Practice1 mark

Which attribute gives the column labels of a DataFrame?

Answer

(d) columns df.columns gives the column labels; df.index gives the row labels.

A1.23Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([300, 140, 50, 390, 80], index=['Pen', 'Book', 'Bag', 'Box', 'Ink'])
print(S['Book':'Box'].sum())
Answer

(c) 580 With labels, the end label is included.

A1.24Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Player': ['Rohit', 'Virat', 'Gill', 'Pant'],
                   'Fours': [36, 27, 14, 26],
                   'Sixes': [2, 13, 17, 3]},
                  index=['P1', 'P2', 'P3', 'P4'])
print(df['Sixes'].sum())
Answer

(b) 35 Working: df['Sixes'] = [P1: 2, P2: 13, P3: 17, P4: 3]; df['Sixes'].sum() adds the values = 35.

A1.25Practice1 mark

Which parameter of read_csv() gives your own column names?

Answer

(b) names names=['A', 'B', ...] sets the column names (use with header=None when the file has no heading row).

A1.26Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Gamer': ['Neo', 'Rex', 'Sky', 'Max'],
                   'Round1': [32, 20, 59, 52],
                   'Round2': [42, 65, 32, 61]},
                  index=['G1', 'G2', 'G3', 'G4'])
print(df.tail(1)['Round2'].sum())
Answer

(b) 61 tail(1) is the last row.

A1.27Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Class': ['VI', 'VII', 'VIII', 'IX'],
                   'Students': [31, 36, 28, 38],
                   'Teachers': [5, 3, 4, 6]},
                  index=['T1', 'T2', 'T3', 'T4'])
print(len(df))
Answer

(a) 4 len() of a DataFrame is the number of rows.

A1.28Practice1 mark

df.shape returns

Answer

(b) a tuple (number of rows, number of columns) shape is a tuple (rows, columns), e.g. (4, 3).

A1.29Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Customer': ['Farah', 'Girish', 'Harsh', 'Indu'],
                   'Deposit': [60, 180, 120, 160],
                   'Withdraw': [45, 40, 50, 15]},
                  index=['A1', 'A2', 'A3', 'A4'])
print(df.tail(1)['Withdraw'].sum())
Answer

(d) 15 tail(1) is the last row.

A1.30Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([40, 240, 260, 120, 300], index=['H1', 'H2', 'H3', 'H4', 'H5'])
print(S[S > 240].count())
Answer

(c) 2 Only the elements greater than 240 are counted.

A1.31Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Dept': ['Sports', 'Library', 'Lab', 'Music'],
                   'Allotted': [190, 170, 90, 140],
                   'Spent': [20, 25, 30, 55]},
                  index=['D1', 'D2', 'D3', 'D4'])
print(len(df))
Answer

(c) 4 len() of a DataFrame is the number of rows.

A1.32Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'City': ['Delhi', 'Shimla', 'Jaipur', 'Kochi'],
                   'MaxTemp': [39, 31, 34, 30],
                   'MinTemp': [18, 16, 24, 13]},
                  index=['W1', 'W2', 'W3', 'W4'])
print(df.size)
Answer

(c) 12 size = rows x columns.

A1.33Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([160, 130, 320, 250, 200], index=['F1', 'F2', 'F3', 'F4', 'F5'])
print((S * 2)['F2'])
Answer

(b) 260 Every element is doubled.

A1.34Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([600, 1200, 1400, 900, 1000], index=['Yoga', 'Dance', 'Music', 'Art', 'Chess'])
print(S['Dance':'Art'].sum())
Answer

(c) 3500 With labels, the end label is included.

A1.35Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([95, 110, 65, 90, 85], index=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
print(S.max())
Answer

(a) 110 Working: S.max() gives the largest value = 110.

A1.36Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([26, 24, 38, 44, 12], index=['Red', 'Blue', 'Green', 'Gold', 'Pink'])
print(S.min() + S.max())
Answer

(d) 56 Working: S.min() gives the smallest value = 12; S.max() gives the largest value = 44; 12 + 44 = 56.

A1.37Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Village': ['Rampur', 'Sonpur', 'Lalganj', 'Nayagaon'],
                   'Wheat': [55, 65, 85, 30],
                   'Rice': [65, 30, 50, 40]},
                  index=['V1', 'V2', 'V3', 'V4'])
print(len(df))
Answer

(c) 4 len() of a DataFrame is the number of rows.

A1.38Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Show': ['Morning', 'Noon', 'Evening', 'Night'],
                   'Tickets': [40, 100, 60, 130],
                   'Price': [250, 200, 150, 300]},
                  index=['T1', 'T2', 'T3', 'T4'])
print(df.iloc[2, 1])
Answer

(c) 60 Row position 2 is the third row; column position 1 is the second column.

A1.39Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([275, 200, 125, 450, 175], index=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
print((S * 2)['Tue'])
Answer

(b) 400 Every element is doubled.

A1.40Practice1 mark

A Series is made from a list of 4 values and no index is given. Its index will be

Answer

(b) 0, 1, 2, 3 The default index is 0, 1, 2, ... so 4 values get 0, 1, 2, 3.

A1.41Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Subject': ['English', 'Hindi', 'Maths', 'Science'],
                   'Issued': [20, 30, 75, 70],
                   'Available': [95, 65, 105, 110]},
                  index=['B1', 'B2', 'B3', 'B4'])
print(len(df.columns))
Answer

(d) 3 Working: df.columns = ['Subject', 'Issued', 'Available'] (column labels); len(df.columns) = 3.

A1.42Practice1 mark

S[S > 50] returns

Answer

(a) only the elements of S that are greater than 50 This is Boolean indexing.

A1.43Practice1 mark

Which function writes a DataFrame to a CSV file?

Answer

(c) to_csv() df.to_csv('file.csv') saves the DataFrame as a CSV file.

A1.44Practice1 mark

Which function reads a CSV file into a DataFrame?

Answer

(c) read_csv() pd.read_csv('file.csv') reads the file into a DataFrame.

A1.45Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([80, 115, 170, 75, 140], index=['P1', 'P2', 'P3', 'P4', 'P5'])
print(S.loc['P5'] - S.iloc[0])
Answer

(d) 60 Working: S.loc['P5'] = 140 (by label); S.iloc[0] = 80 (by position, counting from 0); 140 - 80 = 60.

A1.46Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([300, 140, 50, 390, 80], index=['Pen', 'Book', 'Bag', 'Box', 'Ink'])
print((S * 2)['Book'])
Answer

(d) 280 Every element is doubled.

A1.47Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Player': ['Rohit', 'Virat', 'Gill', 'Pant'],
                   'Fours': [36, 27, 14, 26],
                   'Sixes': [2, 13, 17, 3]},
                  index=['P1', 'P2', 'P3', 'P4'])
print(df.shape)
Answer

(d) (4, 3) shape gives (rows, columns).

A1.48Practice1 mark

len(df) gives the number of

Answer

(d) rows len(df) counts the rows; len(df.columns) counts the columns.

A1.49Practice1 mark

S.tail(3) returns

Answer

(a) the last three elements of S tail(n) gives the last n elements; head(n) gives the first n.

A1.50Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([160, 130, 320, 250, 200], index=['F1', 'F2', 'F3', 'F4', 'F5'])
print(S.size)
Answer

(c) 5 Working: S.size = 5 (number of elements).

A1.51Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Village': ['Rampur', 'Sonpur', 'Lalganj', 'Nayagaon'],
                   'Wheat': [55, 65, 85, 30],
                   'Rice': [65, 30, 50, 40]},
                  index=['V1', 'V2', 'V3', 'V4'])
print(df.iloc[2, 1])
Answer

(a) 85 Row position 2 is the third row; column position 1 is the second column.

A1.52Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Item': ['Pen', 'Notebook', 'Bag', 'Stapler'],
                   'Price': [260, 150, 170, 190],
                   'Qty': [55, 35, 20, 10]},
                  index=['S1', 'S2', 'S3', 'S4'])
print(df[df['Price'] > 170].shape[0])
Answer

(d) 2 The rows that pass the condition are counted.

A1.53Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Vehicle': ['Car', 'Bike', 'Bus', 'Van'],
                   'Litres': [55, 45, 25, 35],
                   'Rate': [92, 106, 104, 100]},
                  index=['V1', 'V2', 'V3', 'V4'])
print(df.shape)
Answer

(b) (4, 3) shape gives (rows, columns).

A1.54Practice1 mark

In Pandas, NaN stands for

Answer

(c) Not a Number NaN marks a missing value.

A1.55Practice1 mark

Which statement changes the column name 'Name' to 'Student' in df?

Answer

(a) df = df.rename(columns={'Name': 'Student'}) rename(columns={old: new}) returns a DataFrame with the new name; assign it back (or use inplace=True).

A1.56Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([26, 24, 38, 44, 12], index=['Red', 'Blue', 'Green', 'Gold', 'Pink'])
print(S.size)
Answer

(b) 5 Working: S.size = 5 (number of elements).

A1.57Practice1 mark

The name Pandas comes from the term

Answer

(c) Panel Data pandas comes from Panel Data (also 'Python Data Analysis').

A1.58Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([600, 750, 450, 900, 650], index=['Anil', 'Bela', 'Chand', 'Devi', 'Esha'])
print(S.tail(2).max())
Answer

(b) 900 tail(2) takes the last two elements.

A1.59Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([275, 200, 125, 450, 175], index=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
print(S['Tue':'Thu'].sum())
Answer

(b) 775 With labels, the end label is included.

A1.60Practice1 mark

State True or False: All the values of one Series can be changed, but its size cannot be changed.

Answer

(a) True A Series is value-mutable and size-immutable.

A1.61Practice1 mark

Which statement removes the column 'Fee' from the DataFrame df and returns the result?

Answer

(b) df.drop('Fee', axis=1) axis=1 means column; axis=0 means row.

A1.62Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Name': ['Gopal', 'Hema', 'Irfan', 'Jyoti'],
                   'Basic': [20000, 48000, 28000, 40000],
                   'Bonus': [3500, 5500, 4000, 2000]},
                  index=['E1', 'E2', 'E3', 'E4'])
print(df.size)
Answer

(d) 12 size = rows x columns.

A1.63Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([40, 240, 260, 120, 300], index=['H1', 'H2', 'H3', 'H4', 'H5'])
print(S['H2':'H4'].sum())
Answer

(d) 620 With labels, the end label is included.

A1.64Practice1 mark

Which attribute gives the number of elements of a Series?

Answer

(a) size S.size is an attribute, so no brackets are written.

A1.65Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Shop': ['Alpha', 'Bharat', 'City', 'Deluxe'],
                   'Income': [85, 80, 115, 90],
                   'Expense': [40, 25, 45, 20]},
                  index=['S1', 'S2', 'S3', 'S4'])
print(df.tail(1)['Expense'].sum())
Answer

(b) 20 tail(1) is the last row.

A1.66Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([95, 110, 65, 90, 85], index=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
print(S[S > 90].count())
Answer

(d) 2 Only the elements greater than 90 are counted.

A1.67Practice1 mark

In df.loc[:, 'Eng':'Sci'] the column 'Sci' is

Answer

(b) included in the result With labels, both ends of a slice are included.

A1.68Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([240, 300, 170, 20, 190], index=['Jun', 'Jul', 'Aug', 'Sep', 'Oct'])
print(S[1:3].sum())
Answer

(d) 470 Positions 1 and 2 are taken; position 3 is left out.

A1.69Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([40, 240, 260, 120, 300], index=['H1', 'H2', 'H3', 'H4', 'H5'])
print(S.max())
Answer

(b) 300 Working: S.max() gives the largest value = 300.

A1.70Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([49, 69, 89, 51, 85], index=['Asha', 'Ravi', 'Tina', 'Om', 'Zoya'])
print(S.loc['Zoya'] - S.iloc[0])
Answer

(a) 36 Working: S.loc['Zoya'] = 85 (by label); S.iloc[0] = 49 (by position, counting from 0); 85 - 49 = 36.

A1.71Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Garden': ['Rose', 'Lotus', 'Lily', 'Tulip'],
                   'Trees': [110, 90, 20, 70],
                   'Shrubs': [70, 120, 100, 190]},
                  index=['G1', 'G2', 'G3', 'G4'])
print(len(df.columns))
Answer

(d) 3 Working: df.columns = ['Garden', 'Trees', 'Shrubs'] (column labels); len(df.columns) = 3.

A1.72Practice1 mark

A Pandas Series is a

Answer

(b) one-dimensional labelled array A Series is one column of values with labels (index): one-dimensional.

A1.73Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Item': ['Pen', 'Notebook', 'Bag', 'Stapler'],
                   'Price': [260, 150, 170, 190],
                   'Qty': [55, 35, 20, 10]},
                  index=['S1', 'S2', 'S3', 'S4'])
print(df.loc['S2', 'Qty'])
Answer

(a) 35 loc uses the row label and the column label.

A1.74Practice1 mark

Which loop goes through a DataFrame row by row?

Answer

(a) for i, row in df.iterrows(): iterrows() gives the row label and the row as a Series.

A1.75Practice1 mark

One column of a DataFrame, such as df['Marks'], is a

Answer

(a) Series Taking one column gives a Series whose index is the row labels.

A1.76Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Name': ['Gopal', 'Hema', 'Irfan', 'Jyoti'],
                   'Basic': [20000, 48000, 28000, 40000],
                   'Bonus': [3500, 5500, 4000, 2000]},
                  index=['E1', 'E2', 'E3', 'E4'])
print(len(df.columns))
Answer

(a) 3 Working: df.columns = ['Name', 'Basic', 'Bonus'] (column labels); len(df.columns) = 3.

A1.77Practice1 mark

Which parameter of to_csv() stops the column names from being written?

Answer

(a) header=False header=False leaves out the heading row.

A1.78Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Item': ['Samosa', 'Tea', 'Juice', 'Sandwich'],
                   'Price': [20, 30, 55, 60],
                   'Sold': [140, 20, 90, 60]},
                  index=['C1', 'C2', 'C3', 'C4'])
print(df.tail(1)['Sold'].sum())
Answer

(b) 60 tail(1) is the last row.

A1.79Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([70, 60, 75, 20, 15], index=['Eng', 'Hin', 'Maths', 'Sci', 'IP'])
print((S * 2)['Hin'])
Answer

(b) 120 Every element is doubled.

A1.80Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Class': ['IX', 'X', 'XI', 'XII'],
                   'Boys': [29, 28, 24, 20],
                   'Girls': [18, 13, 14, 26]},
                  index=['C1', 'C2', 'C3', 'C4'])
print(df.tail(1)['Girls'].sum())
Answer

(d) 26 tail(1) is the last row.

A1.81Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Subject': ['English', 'Hindi', 'Maths', 'Science'],
                   'Issued': [20, 30, 75, 70],
                   'Available': [95, 65, 105, 110]},
                  index=['B1', 'B2', 'B3', 'B4'])
print(df.iloc[2, 1])
Answer

(a) 75 Row position 2 is the third row; column position 1 is the second column.

A1.82Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Name': ['Kabir', 'Meera', 'Nitin', 'Pooja'],
                   'Qtr1': [54, 58, 36, 22],
                   'Qtr2': [56, 20, 18, 48]},
                  index=['S1', 'S2', 'S3', 'S4'])
print(df.iloc[2, 1])
Answer

(a) 36 Row position 2 is the third row; column position 1 is the second column.

A1.83Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Name': ['Asha', 'Ravi', 'Tina', 'Om'],
                   'Eng': [85, 63, 67, 60],
                   'Maths': [60, 61, 73, 63]},
                  index=['R1', 'R2', 'R3', 'R4'])
print(df.tail(1)['Maths'].sum())
Answer

(a) 63 tail(1) is the last row.

A1.84Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([17, 38, 8, 23, 5], index=['A', 'B', 'C', 'D', 'E'])
print(S['D'])
Answer

(c) 23 Working: S['D'] = 23.

A1.85Practice1 mark

df.iloc[] selects rows and columns by

Answer

(d) their integer positions iloc uses integer positions (0, 1, 2, ...), and the end of a slice is not included.

A1.86Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([40, 70, 65, 45, 30], index=['Jan', 'Feb', 'Mar', 'Apr', 'May'])
print(S[S > 45].count())
Answer

(a) 2 Only the elements greater than 45 are counted.

A1.87Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Name': ['Ishaan', 'Jaya', 'Kunal', 'Lata'],
                   'Theory': [31, 54, 32, 34],
                   'Practical': [25, 29, 21, 22]},
                  index=['E1', 'E2', 'E3', 'E4'])
print(df.head(2)['Theory'].sum())
Answer

(d) 85 Working: df.head(2) takes rows E1, E2; df.head(2)['Theory'] = [E1: 31, E2: 54]; df.head(2)['Theory'].sum() adds the values = 85.

A1.88Practice1 mark

Which statement deletes the column 'Age' from df itself?

Answer

(b) del df['Age'] del df['Age'] removes the column from df itself; drop() returns a new DataFrame unless inplace=True.

A1.89Practice1 mark

Which statement adds a new row with the label 'R5' to a DataFrame df that has two columns?

Answer

(d) df.loc['R5'] = ['Pen', 20] df.loc['R5'] = [values] adds a row with that label; the list must have one value per column.

A1.90Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Customer': ['Farah', 'Girish', 'Harsh', 'Indu'],
                   'Deposit': [60, 180, 120, 160],
                   'Withdraw': [45, 40, 50, 15]},
                  index=['A1', 'A2', 'A3', 'A4'])
print(df.head(2)['Deposit'].sum())
Answer

(d) 240 Working: df.head(2) takes rows A1, A2; df.head(2)['Deposit'] = [A1: 60, A2: 180]; df.head(2)['Deposit'].sum() adds the values = 240.

A1.91Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([80, 115, 170, 75, 140], index=['P1', 'P2', 'P3', 'P4', 'P5'])
print(S.head(2).sum())
Answer

(b) 195 head(2) takes the first two elements.

A1.92Practice1 mark

Which attribute shows the data type of every column of a DataFrame?

Answer

(b) dtypes df.dtypes gives the dtype of each column.

A1.93Practice1 mark

For a DataFrame, df.size is equal to

Answer

(c) number of rows x number of columns size = rows × columns, the total number of values.

A1.94Practice1 mark

A Pandas DataFrame is a

Answer

(b) two-dimensional labelled data structure with rows and columns A DataFrame is a 2-D table with row labels (index) and column labels.

A1.95Practice1 mark

A Series is created from a dictionary. The keys of the dictionary become the

Answer

(a) index of the Series Keys become the index labels and values become the data.

A1.96Practice1 mark

State True or False: df.drop('R1') changes df itself.

Answer

(b) False drop() returns a new DataFrame. Store it: df = df.drop('R1').

A1.97Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Product': ['Mouse', 'Keyboard', 'Webcam', 'Speaker'],
                   'Rate': [1600, 2400, 1500, 900],
                   'Units': [17, 11, 18, 6]},
                  index=['O1', 'O2', 'O3', 'O4'])
print(df['Units'].sum())
Answer

(a) 52 Working: df['Units'] = [O1: 17, O2: 11, O3: 18, O4: 6]; df['Units'].sum() adds the values = 52.

A1.98Practice1 mark

A CSV file has no heading row. Which parameter of read_csv() tells Pandas this?

Answer

(d) header=None header=None tells pandas the first line is data, not column names.

A1.99Practice1 mark

Which attribute interchanges the rows and columns of a DataFrame?

Answer

(a) T df.T is the transpose.

A1.100Practice1 mark

State True or False: df.iloc[0:2] returns three rows.

Answer

(b) False Position slicing leaves the stop out, so rows 0 and 1 are returned.

A1.101Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Garden': ['Rose', 'Lotus', 'Lily', 'Tulip'],
                   'Trees': [110, 90, 20, 70],
                   'Shrubs': [70, 120, 100, 190]},
                  index=['G1', 'G2', 'G3', 'G4'])
print(df.size)
Answer

(a) 12 size = rows x columns.

A1.102Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([275, 200, 125, 450, 175], index=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
print(S[S > 200].count())
Answer

(d) 2 Only the elements greater than 200 are counted.

A1.103Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([40, 70, 65, 45, 30], index=['Jan', 'Feb', 'Mar', 'Apr', 'May'])
print(S[1:3].sum())
Answer

(a) 135 Positions 1 and 2 are taken; position 3 is left out.

A1.104Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([6, 17, 19, 30, 26], index=['Delhi', 'Pune', 'Agra', 'Kochi', 'Leh'])
print(S.head(2).sum())
Answer

(d) 23 head(2) takes the first two elements.

A1.105Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([6, 17, 19, 30, 26], index=['Delhi', 'Pune', 'Agra', 'Kochi', 'Leh'])
print(S.tail(2).max())
Answer

(c) 30 tail(2) takes the last two elements.

A1.106Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([600, 1200, 1400, 900, 1000], index=['Yoga', 'Dance', 'Music', 'Art', 'Chess'])
print(S.size)
Answer

(c) 5 Working: S.size = 5 (number of elements).

A1.107Practice1 mark

What is the value of df.ndim for any DataFrame?

Answer

(a) 2 A DataFrame has rows and columns, so ndim is 2 (a Series has ndim 1).

A1.108Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Dept': ['Sports', 'Library', 'Lab', 'Music'],
                   'Allotted': [190, 170, 90, 140],
                   'Spent': [20, 25, 30, 55]},
                  index=['D1', 'D2', 'D3', 'D4'])
print(df.loc['D2', 'Spent'])
Answer

(d) 25 loc uses the row label and the column label.

A1.109Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'RoomType': ['Single', 'Double', 'Deluxe', 'Suite'],
                   'Rent': [3800, 2400, 2000, 2600],
                   'Days': [3, 2, 5, 6]},
                  index=['H1', 'H2', 'H3', 'H4'])
print(df.size)
Answer

(b) 12 size = rows x columns.

A1.110Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([70, 60, 75, 20, 15], index=['Eng', 'Hin', 'Maths', 'Sci', 'IP'])
print(S.iloc[2])
Answer

(c) 75 iloc counts positions from 0.

A1.111Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'House': ['Shivaji', 'Tagore', 'Raman', 'Ashoka'],
                   'Gold': [9, 11, 7, 8],
                   'Silver': [3, 6, 7, 12]},
                  index=['H1', 'H2', 'H3', 'H4'])
print(df.loc['H2', 'Silver'])
Answer

(d) 6 loc uses the row label and the column label.

A1.112Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Show': ['Morning', 'Noon', 'Evening', 'Night'],
                   'Tickets': [40, 100, 60, 130],
                   'Price': [250, 200, 150, 300]},
                  index=['T1', 'T2', 'T3', 'T4'])
print(len(df.columns))
Answer

(d) 3 Working: df.columns = ['Show', 'Tickets', 'Price'] (column labels); len(df.columns) = 3.

A1.113Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Model': ['Astra', 'Bolt', 'Comet', 'Dyna'],
                   'Price': [10000, 15000, 20000, 27000],
                   'Stock': [4, 13, 3, 10]},
                  index=['M1', 'M2', 'M3', 'M4'])
print(df.iloc[2, 1])
Answer

(d) 20000 Row position 2 is the third row; column position 1 is the second column.

A1.114Practice1 mark

Which statement adds a new column 'Total' to the DataFrame df?

Answer

(c) df['Total'] = df['Eng'] + df['Maths'] Assigning to a new column label creates the column: df['Total'] = df['Eng'] + df['Maths'].

A1.115Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([40, 70, 65, 45, 30], index=['Jan', 'Feb', 'Mar', 'Apr', 'May'])
print(S.tail(2).max())
Answer

(a) 45 tail(2) takes the last two elements.

A1.116Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Gamer': ['Neo', 'Rex', 'Sky', 'Max'],
                   'Round1': [32, 20, 59, 52],
                   'Round2': [42, 65, 32, 61]},
                  index=['G1', 'G2', 'G3', 'G4'])
print(df.loc['G2', 'Round2'])
Answer

(b) 65 loc uses the row label and the column label.

A1.117Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Model': ['Astra', 'Bolt', 'Comet', 'Dyna'],
                   'Price': [10000, 15000, 20000, 27000],
                   'Stock': [4, 13, 3, 10]},
                  index=['M1', 'M2', 'M3', 'M4'])
print(df.T.shape)
Answer

(a) (3, 4) The transpose turns 4 rows and 3 columns into 3 rows and 4 columns.

A1.118Practice1 mark

df.loc[] selects rows and columns by

Answer

(d) their labels loc uses labels, and the end label of a slice is included.

A1.119Practice1 mark

Pandas is built on top of which library?

Answer

(b) NumPy pandas uses NumPy arrays inside, so it is built on NumPy.

A1.120Practice1 mark

S * 2, where S is a Series of numbers,

Answer

(b) multiplies every element by 2 Arithmetic on a Series works on every element (vector operation).

A1.121Practice1 mark

S.values returns the values of the Series as

Answer

(a) a NumPy array S.values gives a NumPy array of the values.

A1.122Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([600, 750, 450, 900, 650], index=['Anil', 'Bela', 'Chand', 'Devi', 'Esha'])
print(S.max())
Answer

(b) 900 Working: S.max() gives the largest value = 900.

A1.123Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Product': ['Mouse', 'Keyboard', 'Webcam', 'Speaker'],
                   'Rate': [1600, 2400, 1500, 900],
                   'Units': [17, 11, 18, 6]},
                  index=['O1', 'O2', 'O3', 'O4'])
print(df.shape)
Answer

(a) (4, 3) shape gives (rows, columns).

A1.124Practice1 mark

How many rows does df.head() show when no number is given?

Answer

(b) 5 The default n of head() is 5.

A1.125Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([49, 69, 89, 51, 85], index=['Asha', 'Ravi', 'Tina', 'Om', 'Zoya'])
print(S[1:3].sum())
Answer

(b) 158 Positions 1 and 2 are taken; position 3 is left out.

A1.126Practice1 mark

Which statement imports Pandas in the usual way?

Answer

(c) import pandas as pd import pandas as pd lets us write pd.Series and pd.DataFrame.

A1.127Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([26, 24, 38, 44, 12], index=['Red', 'Blue', 'Green', 'Gold', 'Pink'])
print(S['Blue':'Gold'].sum())
Answer

(c) 106 With labels, the end label is included.

A1.128Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Shop': ['Alpha', 'Bharat', 'City', 'Deluxe'],
                   'Income': [85, 80, 115, 90],
                   'Expense': [40, 25, 45, 20]},
                  index=['S1', 'S2', 'S3', 'S4'])
print(df.size)
Answer

(b) 12 size = rows x columns.

A1.129Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([600, 750, 450, 900, 650], index=['Anil', 'Bela', 'Chand', 'Devi', 'Esha'])
print(S['Bela':'Devi'].sum())
Answer

(c) 2100 With labels, the end label is included.

A1.130Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Name': ['Kabir', 'Meera', 'Nitin', 'Pooja'],
                   'Qtr1': [54, 58, 36, 22],
                   'Qtr2': [56, 20, 18, 48]},
                  index=['S1', 'S2', 'S3', 'S4'])
print(df[df['Qtr1'] > 36].shape[0])
Answer

(d) 2 The rows that pass the condition are counted.

A1.131Practice1 mark

The values in a file are separated by semicolons. Which parameter of read_csv() is used?

Answer

(b) sep=';' sep=';' tells read_csv() the separator (default is ',').

A1.132Practice1 mark

In Pandas, axis=0 refers to

Answer

(a) rows (the index) axis=0 means along the rows (index); axis=1 means the columns.

A1.133Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Name': ['Asha', 'Ravi', 'Tina', 'Om'],
                   'Eng': [85, 63, 67, 60],
                   'Maths': [60, 61, 73, 63]},
                  index=['R1', 'R2', 'R3', 'R4'])
print(df.iloc[2, 1])
Answer

(d) 67 Row position 2 is the third row; column position 1 is the second column.

A1.134Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'City': ['Delhi', 'Shimla', 'Jaipur', 'Kochi'],
                   'MaxTemp': [39, 31, 34, 30],
                   'MinTemp': [18, 16, 24, 13]},
                  index=['W1', 'W2', 'W3', 'W4'])
print(df.shape)
Answer

(c) (4, 3) shape gives (rows, columns).

A1.135Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Team': ['Alpha', 'Beta', 'Gamma', 'Delta'],
                   'Round1': [30, 40, 15, 25],
                   'Round2': [50, 10, 25, 35]},
                  index=['Q1', 'Q2', 'Q3', 'Q4'])
print(df.size)
Answer

(a) 12 size = rows x columns.

A1.136Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([160, 130, 320, 250, 200], index=['F1', 'F2', 'F3', 'F4', 'F5'])
print(S.index[1])
Answer

(d) F2 index holds the labels; position 1 is the second label.

A1.137Practice1 mark

pd.Series({'a': 10, 'b': 20}, index=['a', 'c']) has the values

Answer

(a) 10 and NaN Label 'c' is not a key of the dictionary, so its value is NaN.

A1.138Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([300, 140, 50, 390, 80], index=['Pen', 'Book', 'Bag', 'Box', 'Ink'])
print(S.size)
Answer

(c) 5 Working: S.size = 5 (number of elements).

A1.139Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Class': ['VI', 'VII', 'VIII', 'IX'],
                   'Students': [31, 36, 28, 38],
                   'Teachers': [5, 3, 4, 6]},
                  index=['T1', 'T2', 'T3', 'T4'])
print(len(df.columns))
Answer

(c) 3 Working: df.columns = ['Class', 'Students', 'Teachers'] (column labels); len(df.columns) = 3.

A1.140Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Vehicle': ['Car', 'Bike', 'Bus', 'Van'],
                   'Litres': [55, 45, 25, 35],
                   'Rate': [92, 106, 104, 100]},
                  index=['V1', 'V2', 'V3', 'V4'])
print(df.size)
Answer

(c) 12 size = rows x columns.

A1.141Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'Name': ['Ishaan', 'Jaya', 'Kunal', 'Lata'],
                   'Theory': [31, 54, 32, 34],
                   'Practical': [25, 29, 21, 22]},
                  index=['E1', 'E2', 'E3', 'E4'])
print(df.size)
Answer

(c) 12 size = rows x columns.

A1.142Practice1 mark

What is the output of this code?

import pandas as pd
df = pd.DataFrame({'RoomType': ['Single', 'Double', 'Deluxe', 'Suite'],
                   'Rent': [3800, 2400, 2000, 2600],
                   'Days': [3, 2, 5, 6]},
                  index=['H1', 'H2', 'H3', 'H4'])
print(df[df['Rent'] > 2400].shape[0])
Answer

(c) 2 The rows that pass the condition are counted.

A1.143Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([49, 69, 89, 51, 85], index=['Asha', 'Ravi', 'Tina', 'Om', 'Zoya'])
print((S * 2)['Ravi'])
Answer

(b) 138 Every element is doubled.

A1.144Practice1 mark

What is the output of this code?

import pandas as pd
S = pd.Series([95, 110, 65, 90, 85], index=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
print(S.loc['Fri'] - S.iloc[0])
Answer

(a) -10 Working: S.loc['Fri'] = 85 (by label); S.iloc[0] = 95 (by position, counting from 0); 85 - 95 = -10.

A2Data visualization MCQ1 mark · 45 questions
A2.1SQP 2026-271 mark

Which function of Matplotlib gives a label to the Y-axis?

Answer

(d) ylabel() plt.ylabel('text') labels the y-axis.

A2.2Practice1 mark

Which module of Matplotlib is imported for drawing charts?

Answer

(c) pyplot matplotlib.pyplot has plot(), bar(), hist() and show().

A2.3Practice1 mark

Which statement imports the plotting module in the usual way?

Answer

(b) import matplotlib.pyplot as plt import matplotlib.pyplot as plt is the usual way.

A2.4Practice1 mark

Which function draws a line chart?

Answer

(c) plot() plt.plot(x, y) joins the points with lines.

A2.5Practice1 mark

Which function draws a vertical bar chart?

Answer

(b) bar() plt.bar(x, heights) draws vertical bars.

A2.6Practice1 mark

Which function draws a horizontal bar chart?

Answer

(a) barh() plt.barh(y, widths) draws horizontal bars.

A2.7Practice1 mark

Which function draws a histogram?

Answer

(c) hist() plt.hist(data, bins) draws a histogram.

A2.8Practice1 mark

Which function displays the chart on the screen?

Answer

(c) show() plt.show() displays the chart.

A2.9Practice1 mark

Which function saves the chart as a picture file?

Answer

(c) savefig() plt.savefig('name.png') saves the chart as a picture.

A2.10Practice1 mark

Which function writes a heading on top of the chart?

Answer

(a) title() plt.title('text') writes the heading.

A2.11Practice1 mark

Which function gives a label to the X-axis?

Answer

(b) xlabel() plt.xlabel('text') labels the x-axis.

A2.12Practice1 mark

Which function shows the small box that tells which line or bar stands for which data?

Answer

(b) legend() plt.legend() shows the legend box.

A2.13Practice1 mark

For plt.legend() to show a name, which parameter must be given in plt.plot()?

Answer

(a) label label='Sales' in plot() gives the name that legend() shows.

A2.14Practice1 mark

Which statement shows grid lines on the chart?

Answer

(a) plt.grid(True) plt.grid(True) draws grid lines.

A2.15Practice1 mark

Which parameter of hist() sets the number of intervals?

Answer

(b) bins bins sets the number of intervals (default 10).

A2.16Practice1 mark

Which chart is best to show the trend of sales over twelve months?

Answer

(d) Line chart A line chart shows how a value rises and falls over time.

A2.17Practice1 mark

Which chart is best to compare the sales of five products?

Answer

(b) Bar chart A bar chart compares values of separate items side by side.

A2.18Practice1 mark

Which chart is best to show how the marks of 500 students are spread over ranges such as 0-10, 10-20 ...?

Answer

(d) Histogram A histogram shows how many values fall in each range (frequency distribution).

A2.19Practice1 mark

In plt.plot(x, y, color='g') the line is drawn in

Answer

(d) green 'g' is the short code for green (r red, b blue, k black, y yellow).

The chart this code draws (with sample values for x, y)

4060801234
A2.20Practice1 mark

Which value of linestyle draws a dashed line?

Answer

(a) '--' '--' is dashed, ':' dotted, '-.' dash-dot and '-' solid.

A2.21Practice1 mark

Which value of linestyle draws a dotted line?

Answer

(d) ':' ':' draws a dotted line.

A2.22Practice1 mark

Which parameter of plot() sets the thickness of the line?

Answer

(d) linewidth linewidth (or lw) sets the thickness.

A2.23Practice1 mark

Which parameter of plot() puts a symbol on every data point?

Answer

(b) marker marker='o' puts a circle on each point.

A2.24Practice1 mark

marker='o' shows every data point as a

Answer

(d) circle 'o' is a circle; 's' square, '^' triangle, '*' star.

A2.25Practice1 mark

marker='*' shows every data point as a

Answer

(a) star '*' draws a star at each point.

A2.26Practice1 mark

plt.plot(x, y, 'r--') draws a

Answer

(b) red dashed line In the format string, 'r' means red and '--' means dashed.

The chart this code draws (with sample values for x, y)

4060801234
A2.27Practice1 mark

Which parameter of bar() sets the thickness of the bars?

Answer

(b) width width sets the bar thickness (default 0.8).

A2.28Practice1 mark

Which parameter of bar() gives the colour of the border of the bars?

Answer

(b) edgecolor edgecolor sets the border colour of the bars.

A2.29Practice1 mark

In plt.bar(x, y) the second argument gives the

Answer

(d) heights of the bars The first argument gives the positions/labels; the second gives the heights.

A2.30Practice1 mark

In a histogram, the Y-axis normally shows the

Answer

(a) frequency (number of values in each interval) The height of each bar is the frequency: how many values fall in that interval.

A2.31Practice1 mark

How many bins does plt.hist(data) use when bins is not given?

Answer

(c) 10 The default number of bins is 10.

A2.32Practice1 mark

To save a chart correctly in a program, plt.savefig() should be written

Answer

(d) before plt.show() After show() the figure is cleared, so a blank picture may be saved.

A2.33Practice1 mark

plt.savefig('sales.png') saves the chart

Answer

(d) as the picture file sales.png in the current folder savefig() writes the picture file in the current folder.

A2.34Practice1 mark

Which function changes the labels written along the X-axis?

Answer

(b) xticks() plt.xticks(positions, labels) sets the x-axis tick labels.

A2.35Practice1 mark

plt.legend(loc='upper left') places the legend

Answer

(a) in the top left corner of the chart loc chooses where the legend box goes; 'upper left' is the top-left corner.

A2.36Practice1 mark

Data visualization means

Answer

(d) showing data in the form of charts and graphs Data visualization shows data as charts and graphs so patterns are easy to see.

A2.37Practice1 mark

Which parameter gives different colours to the bars of plt.bar()?

Answer

(d) color=['r', 'g', 'b'] A list of colours, one for each bar, can be given to color.

A2.38Practice1 mark

In plt.hist(marks, bins=[0, 20, 40, 60, 80, 100]) how many bars (intervals) are made?

Answer

(c) 5 Six edges make five intervals.

A2.39Practice1 mark

df.plot(kind='bar') draws

Answer

(a) a bar chart of the numeric columns of df kind='bar' draws a bar chart of the numeric columns, with the index on the x-axis.

A2.40Practice1 mark

Which value of kind in df.plot() draws a histogram?

Answer

(a) 'hist' kind='hist' draws a histogram.

A2.41Practice1 mark

State True or False: A histogram has gaps between its bars, just like a bar chart.

Answer

(b) False Histogram bars touch each other because the intervals are continuous.

A2.42Practice1 mark

State True or False: A histogram is drawn for one list of numeric values.

Answer

(a) True hist() takes one set of numbers and counts them in intervals.

A2.43Practice1 mark

State True or False: plt.title() must be written after plt.show().

Answer

(b) False Everything that decorates the chart is written before show().

A2.44Practice1 mark

State True or False: More than one line can be drawn on the same chart by calling plt.plot() more than once.

Answer

(a) True Each plt.plot() before plt.show() adds another line to the same chart.

A2.45Practice1 mark

State True or False: plt.xlabel() and plt.ylabel() are needed for the chart to be drawn.

Answer

(b) False They only add labels. The chart is drawn without them also.

A3SQL: MCQ, True/False and output1 mark · 168 questions
A3.1SQP 2026-271 mark

Which function returns the number of characters in a string?

Answer

(d) LENGTH() LENGTH('India') = 5; spaces are counted too.

A3.2SQP 2026-271 mark

Which of these is a Data Manipulation Language (DML) command?

Answer

(d) UPDATE DML changes the data: INSERT, UPDATE, DELETE.

A3.3SQP 2026-271 mark

Fill in the blank: the ______ clause is used with GROUP BY to put a condition on groups.

Answer

(c) HAVING HAVING filters groups; WHERE filters rows.

A3.4SQP 2026-271 mark

Which keyword sorts the output in descending order?

Answer

(b) DESC ORDER BY ... DESC sorts from the largest to the smallest.

A3.5SQP 2026-271 mark

Which function takes out a given number of characters from a string, starting at a given position?

Answer

(b) MID() MID('Digital', 3, 4) = 'gita': start at position 3, take 4 characters (same as SUBSTRING()).

A3.6SQP 2026-271 mark

Which condition finds the rows where the column Email is not empty?

Answer

(a) Email IS NOT NULL IS NOT NULL checks for a value; = NULL never works.

A3.7SQP 2026-271 mark

State True or False: BETWEEN 10 AND 20 includes both 10 and 20.

Answer

(a) True BETWEEN includes both limits.

A3.8Practice1 mark

What is the output of this query?

SELECT LENGTH(RIGHT('Database', 5));
Answer

(c) 5 Solve the inner function first.

A3.9Practice1 mark

What is the output of this query?

SELECT SUBSTR('Python', 2, 2);
Answer

(b) yt MID(text, start, n) takes n characters; counting starts from 1.

A3.10Practice1 mark

What is the output of this query?

SELECT POWER(4, 3);
Answer

(c) 64 POWER(a, b) is a multiplied by itself b times.

A3.11Practice1 mark

What is the output of this query?

SELECT LENGTH(TRIM(' Python '));
Answer

(c) 6 TRIM() removes spaces from both ends, LTRIM() from the left end, RTRIM() from the right end. Spaces inside the text stay.

A3.12Practice1 mark

What is the output of this query?

SELECT ROUND(559.496, -1);
Answer

(a) 560 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.13Practice1 mark

What is the output of this query?

SELECT POWER(6, 4);
Answer

(d) 1296 POWER(a, b) is a multiplied by itself b times.

A3.14Practice1 mark

What is the output of this query?

SELECT LENGTH('DataFrame');
Answer

(a) 9 LENGTH() counts every character, spaces also.

A3.15Practice1 mark

What is the output of this query?

SELECT RIGHT('Kendriya', 4);
Answer

(b) riya RIGHT(text, n) takes the last n characters.

A3.16Practice1 mark

What is the output of this query?

SELECT UPPER(RIGHT('Cyber Safety', 3));
Answer

(b) ETY Solve the inner function first.

A3.17Practice1 mark

What is the output of this query?

SELECT MONTH('2025-08-14');
Answer

(b) 8 The date is written as year-month-day.

A3.18Practice1 mark

What is the output of this query?

SELECT ROUND(354.338, 1);
Answer

(d) 354.3 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.19Practice1 mark

An aggregate function works on

Answer

(d) a group of rows and returns one value Aggregate functions take many rows and return one value, e.g. SUM(), AVG().

A3.20Practice1 mark

What is the output of this query?

SELECT LENGTH('Data Science');
Answer

(c) 12 LENGTH() counts every character, spaces also.

A3.21Practice1 mark

What is the output of this query?

SELECT MOD(92, 6);
Answer

(c) 2 MOD(a, b) is the remainder when a is divided by b.

A3.22Practice1 mark

What is the output of this query?

SELECT SUBSTRING('Computer', 3, 4);
Answer

(a) mput MID(text, start, n) takes n characters; counting starts from 1.

A3.23Practice1 mark

What is the output of this query?

SELECT LEFT('Shalimar Bagh', 6);
Answer

(c) Shalim LEFT(text, n) takes the first n characters.

A3.24Practice1 mark

What is the output of this query?

SELECT MOD(71, 9);
Answer

(b) 8 MOD(a, b) is the remainder when a is divided by b.

A3.25Practice1 mark

What is the output of this query?

SELECT ROUND(131.828, 1);
Answer

(d) 131.8 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.26Practice1 mark

What is the output of this query?

SELECT LENGTH('Visualization');
Answer

(b) 13 LENGTH() counts every character, spaces also.

A3.27Practice1 mark

The column Price of a table has five rows with the values NULL, 250, 550, 700, 350. What does SELECT SUM(Price) FROM ... return?

Answer

(b) 1850 NULL values are ignored.

A3.28Practice1 mark

Which of these is an aggregate (multiple-row) function?

Answer

(d) AVG() AVG() works on a group of rows; LENGTH(), UCASE() and ROUND() work on one row at a time.

A3.29Practice1 mark

What is the output of this query?

SELECT UCASE(MID('DataFrame', 4, 2));
Answer

(c) AF Solve the inner function first.

A3.30Practice1 mark

What is the output of this query?

SELECT LOWER('Histogram');
Answer

(b) histogram UCASE() and UPPER() give capital letters; LCASE() and LOWER() give small letters.

A3.31Practice1 mark

What is the output of this query?

SELECT ROUND(818.017, 1);
Answer

(b) 818.0 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.32Practice1 mark

What is the output of this query?

SELECT MOD(31, 6);
Answer

(a) 1 MOD(a, b) is the remainder when a is divided by b.

A3.33Practice1 mark

What is the output of this query?

SELECT ROUND(326.586, 1);
Answer

(d) 326.6 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.34Practice1 mark

What is the output of this query?

SELECT POWER(7, 2);
Answer

(a) 49 POWER(a, b) is a multiplied by itself b times.

A3.35Practice1 mark

What is the output of this query?

SELECT MOD(22, 7);
Answer

(d) 1 MOD(a, b) is the remainder when a is divided by b.

A3.36Practice1 mark

State True or False: HAVING can be used without an aggregate function in the query.

Answer

(a) True For example HAVING City = 'Delhi' on a grouped column is allowed, though WHERE is the better place for it.

A3.37Practice1 mark

What is the output of this query?

SELECT LENGTH(TRIM(' DataFrame '));
Answer

(b) 9 TRIM() removes spaces from both ends, LTRIM() from the left end, RTRIM() from the right end. Spaces inside the text stay.

A3.38Practice1 mark

What is the output of this query?

SELECT RIGHT('Digital India', 11);
Answer

(c) gital India RIGHT(text, n) takes the last n characters.

A3.39Practice1 mark

What is the output of this query?

SELECT POWER(MOD(15, 5), 3);
Answer

(b) 0 Solve the inner function first.

A3.40Practice1 mark

The column Fee of a table has five rows with the values 700, 650, NULL, 100, 200. What does SELECT MIN(Fee) FROM ... return?

Answer

(a) 100 NULL values are ignored.

A3.41Practice1 mark

What is the output of this query?

SELECT YEAR('2024-08-11');
Answer

(b) 2024 The date is written as year-month-day.

A3.42Practice1 mark

What is the output of this query?

SELECT MONTH('2024-08-19');
Answer

(b) 8 The date is written as year-month-day.

A3.43Practice1 mark

The column Price of a table has five rows with the values NULL, 150, 650, 250, 650. What does SELECT COUNT(*) FROM ... return?

Answer

(d) 5 COUNT(*) counts all the rows.

A3.44Practice1 mark

What is the output of this query?

SELECT MID('Web Server', 2, 4);
Answer

(d) eb S MID(text, start, n) takes n characters; counting starts from 1.

A3.45Practice1 mark

Which keyword shows each value of a column only once?

Answer

(c) DISTINCT DISTINCT removes duplicate values.

A3.46Practice1 mark

Table A has 5 rows and table B has 4 rows. How many rows does SELECT * FROM A, B; give?

Answer

(a) 20 With no join condition, every row of A is paired with every row of B (Cartesian product).

A3.47Practice1 mark

What is the output of this query?

SELECT INSTR('Internet', 'nt');
Answer

(a) 2 INSTR(text, part) gives the position of the first match; counting starts from 1.

A3.48Practice1 mark

MAX(Name) on a text column returns

Answer

(c) the name that comes last in alphabetical order For text, MAX gives the value that comes last in alphabetical order.

A3.49Practice1 mark

What is the output of this query?

SELECT YEAR('2025-08-19');
Answer

(b) 2025 The date is written as year-month-day.

A3.50Practice1 mark

What is the output of this query?

SELECT LEFT('Visualization', 8);
Answer

(d) Visualiz LEFT(text, n) takes the first n characters.

A3.51Practice1 mark

What is the output of this query?

SELECT MOD(65, 7);
Answer

(d) 2 MOD(a, b) is the remainder when a is divided by b.

A3.52Practice1 mark

What is the output of this query?

SELECT LENGTH('Cyber Safety');
Answer

(a) 12 LENGTH() counts every character, spaces also.

A3.53Practice1 mark

Which command changes the values stored in existing rows?

Answer

(d) UPDATE UPDATE table SET column = value WHERE condition.

A3.54Practice1 mark

Which pattern finds the names that end with the letter s?

Answer

(d) LIKE '%s' % means any characters before, so LIKE '%s' means ending with s.

A3.55Practice1 mark

What is the output of this query?

SELECT SUBSTR('Pandas', 2, 3);
Answer

(b) and MID(text, start, n) takes n characters; counting starts from 1.

A3.56Practice1 mark

What is the output of this query?

SELECT MONTH('2026-02-12');
Answer

(b) 2 The date is written as year-month-day.

A3.57Practice1 mark

Which of these is a Data Definition Language (DDL) command?

Answer

(b) ALTER DDL defines the structure: CREATE, ALTER, DROP.

A3.58Practice1 mark

State True or False: A SELECT query can have both WHERE and HAVING clauses.

Answer

(a) True WHERE filters rows first, then HAVING filters the groups.

A3.59Practice1 mark

What is the output of this query?

SELECT MOD(POWER(4, 2), 4);
Answer

(c) 0 Solve the inner function first.

A3.60Practice1 mark

The column Price of a table has five rows with the values 150, 550, 300, 350, NULL. What does SELECT MAX(Price) FROM ... return?

Answer

(d) 550 NULL values are ignored.

A3.61Practice1 mark

What is the output of this query?

SELECT LEFT('Digital India', 7);
Answer

(b) Digital LEFT(text, n) takes the first n characters.

A3.62Practice1 mark

Functions such as LENGTH() and ROUND(), which give one result for every row, are called

Answer

(a) single-row functions Single-row (scalar) functions return one value for each row.

A3.63Practice1 mark

The column Marks of a table has five rows with the values NULL, 60, 70, 25, 75. What does SELECT COUNT(Marks) FROM ... return?

Answer

(d) 4 COUNT(column) does not count NULL.

A3.64Practice1 mark

Which function gives the same result as UCASE()?

Answer

(d) UPPER() UCASE() and UPPER() both change text to capital letters.

A3.65Practice1 mark

What is the output of this query?

SELECT ROUND(394.763, -1);
Answer

(d) 390 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.66Practice1 mark

What is the output of this query?

SELECT INSTR('Knowledge', 'l');
Answer

(b) 5 INSTR(text, part) gives the position of the first match; counting starts from 1.

A3.67Practice1 mark

COUNT(*) counts

Answer

(a) all the rows, including rows with NULL values COUNT(*) counts every row, including rows with NULL values.

A3.68Practice1 mark

What is the output of this query?

SELECT LEFT('Cyber Safety', 5);
Answer

(c) Cyber LEFT(text, n) takes the first n characters.

A3.69Practice1 mark

What is the output of this query?

SELECT ROUND(522.541, 0);
Answer

(d) 523 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.70Practice1 mark

Which function removes the spaces only from the left end of a string?

Answer

(d) LTRIM() LTRIM() removes leading (left) spaces; RTRIM() removes trailing ones.

A3.71Practice1 mark

What is the output of this query?

SELECT INSTR('Histogram', 'is');
Answer

(a) 2 INSTR(text, part) gives the position of the first match; counting starts from 1.

A3.72Practice1 mark

What is the output of this query?

SELECT LEFT('Python', 3);
Answer

(b) Pyt LEFT(text, n) takes the first n characters.

A3.73Practice1 mark

The aggregate functions SUM() and AVG() ______ the NULL values of a column.

Answer

(a) ignore Aggregate functions skip NULL values.

A3.74Practice1 mark

What is the output of this query?

SELECT LEFT(RIGHT('New Delhi', 6), 2);
Answer

(c) D Solve the inner function first.

A3.75Practice1 mark

Which of these cannot be written in a WHERE clause?

Answer

(c) SUM(Fee) > 5000 Aggregate functions are used with HAVING, not with WHERE.

A3.76Practice1 mark

What is the output of this query?

SELECT POWER(5, 2);
Answer

(d) 25 POWER(a, b) is a multiplied by itself b times.

A3.77Practice1 mark

Which function returns the current date and time?

Answer

(a) NOW() NOW() gives the current date and time; CURDATE() gives only the date.

A3.78Practice1 mark

What is the output of this query?

SELECT YEAR('2025-05-18');
Answer

(a) 2025 The date is written as year-month-day.

A3.79Practice1 mark

What is the output of this query?

SELECT MID('Open Source', 6, 2);
Answer

(c) So MID(text, start, n) takes n characters; counting starts from 1.

A3.80Practice1 mark

What is the output of this query?

SELECT ROUND(630.508, -1);
Answer

(a) 630 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.81Practice1 mark

What is the output of this query?

SELECT LCASE('Histogram');
Answer

(d) histogram UCASE() and UPPER() give capital letters; LCASE() and LOWER() give small letters.

A3.82Practice1 mark

Which of these is a date function?

Answer

(b) MONTHNAME() MONTHNAME('2026-11-13') = 'November'.

A3.83Practice1 mark

Which is the correct order of clauses in a query?

Answer

(b) SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY must be written in this order.

A3.84Practice1 mark

Table A has 3 columns and table B has 2 columns. How many columns does SELECT * FROM A, B; give?

Answer

(b) 5 The columns of the two tables are placed side by side, so they are added.

A3.85Practice1 mark

What is the output of this query?

SELECT MONTHNAME('2025-01-27');
Answer

(a) January The date is written as year-month-day.

A3.86Practice1 mark

The column Salary of a table has five rows with the values 400, 950, NULL, 650, 950. What does SELECT MAX(Salary) FROM ... return?

Answer

(d) 950 NULL values are ignored.

A3.87Practice1 mark

The column Salary of a table has five rows with the values NULL, 650, 950, 850, 700. What does SELECT COUNT(Salary) FROM ... return?

Answer

(c) 4 COUNT(column) does not count NULL.

A3.88Practice1 mark

Which command adds a new column to an existing table?

Answer

(a) ALTER TABLE ... ADD ALTER TABLE STUDENT ADD Phone VARCHAR(10); adds a column.

A3.89Practice1 mark

Table A has 4 columns and table B has 4 columns. How many columns does SELECT * FROM A, B; give?

Answer

(b) 8 The columns of the two tables are placed side by side, so they are added.

A3.90Practice1 mark

What is the output of this query?

SELECT LCASE('Computer');
Answer

(b) computer UCASE() and UPPER() give capital letters; LCASE() and LOWER() give small letters.

A3.91Practice1 mark

What is the output of this query?

SELECT LENGTH('Histogram') + INSTR('Histogram', 'r');
Answer

(b) 16 Solve the inner function first.

A3.92Practice1 mark

What is the output of this query?

SELECT SUBSTR('Pandas', 3, 2);
Answer

(c) nd MID(text, start, n) takes n characters; counting starts from 1.

A3.93Practice1 mark

Table A has 5 rows and table B has 5 rows. How many rows does SELECT * FROM A, B; give?

Answer

(d) 25 With no join condition, every row of A is paired with every row of B (Cartesian product).

A3.94Practice1 mark

What is the output of this query?

SELECT UPPER('Data Science');
Answer

(b) DATA SCIENCE UCASE() and UPPER() give capital letters; LCASE() and LOWER() give small letters.

A3.95Practice1 mark

What is the output of this query?

SELECT POWER(MOD(34, 6), 2);
Answer

(c) 16 Solve the inner function first.

A3.96Practice1 mark

What is the output of this query?

SELECT SUBSTRING('Welcome', 3, 2);
Answer

(d) lc MID(text, start, n) takes n characters; counting starts from 1.

A3.97Practice1 mark

What is the output of this query?

SELECT LENGTH('Structured');
Answer

(a) 10 LENGTH() counts every character, spaces also.

A3.98Practice1 mark

The column Fee of a table has five rows with the values 500, 300, NULL, 700, 850. What does SELECT AVG(Fee) FROM ... return?

Answer

(c) 587.5 NULL values are ignored.

A3.99Practice1 mark

TRIM() removes spaces from

Answer

(a) both ends of a string TRIM() removes spaces from both ends.

A3.100Practice1 mark

What is the output of this query?

SELECT MOD(19, 3);
Answer

(d) 1 MOD(a, b) is the remainder when a is divided by b.

A3.101Practice1 mark

State True or False: ORDER BY Name DESC shows the names from Z to A.

Answer

(a) True DESC is descending, so Z comes first.

A3.102Practice1 mark

What is the output of this query?

SELECT YEAR('2025-10-14');
Answer

(c) 2025 The date is written as year-month-day.

A3.103Practice1 mark

Which clause is used with SELECT to show the output in sorted order?

Answer

(b) ORDER BY ORDER BY sorts the output.

A3.104Practice1 mark

DAY('2026-11-13') returns

Answer

(d) 13 DAY() gives the day of the month: 13.

A3.105Practice1 mark

Table A has 4 columns and table B has 5 columns. How many columns does SELECT * FROM A, B; give?

Answer

(d) 9 The columns of the two tables are placed side by side, so they are added.

A3.106Practice1 mark

What is the output of this query?

SELECT RIGHT('Matplotlib', 4);
Answer

(b) tlib RIGHT(text, n) takes the last n characters.

A3.107Practice1 mark

The column Salary of a table has five rows with the values 300, 400, 750, 650, NULL. What does SELECT SUM(Salary) FROM ... return?

Answer

(b) 2100 NULL values are ignored.

A3.108Practice1 mark

What is the output of this query?

SELECT MOD(72, 6);
Answer

(d) 0 MOD(a, b) is the remainder when a is divided by b.

A3.109Practice1 mark

What is the output of this query?

SELECT ROUND(943.182, -1);
Answer

(b) 940 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.110Practice1 mark

What is the output of this query?

SELECT MOD(30, 5) + POWER(7, 2);
Answer

(b) 49 Solve the inner function first.

A3.111Practice1 mark

What is the output of this query?

SELECT INSTR('Technology', 'n');
Answer

(d) 5 INSTR(text, part) gives the position of the first match; counting starts from 1.

A3.112Practice1 mark

What is the output of this query?

SELECT MID('Structured', 6, 3);
Answer

(b) tur MID(text, start, n) takes n characters; counting starts from 1.

A3.113Practice1 mark

If ASC or DESC is not written with ORDER BY, the output is sorted in

Answer

(a) ascending order ASC (ascending) is the default.

A3.114Practice1 mark

What is the output of this query?

SELECT ROUND(102.239, 1);
Answer

(b) 102.2 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.115Practice1 mark

COUNT(Fee) counts

Answer

(a) the rows where Fee is not NULL COUNT(column) counts only the values that are not NULL.

A3.116Practice1 mark

Which clause filters rows before the groups are made?

Answer

(c) WHERE WHERE works on rows before GROUP BY; HAVING works on groups after.

A3.117Practice1 mark

What is the output of this query?

SELECT ROUND(943.128, 1);
Answer

(b) 943.1 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.118Practice1 mark

The column Salary of a table has five rows with the values 300, 650, NULL, 750, 450. What does SELECT AVG(Salary) FROM ... return?

Answer

(c) 537.5 NULL values are ignored.

A3.119Practice1 mark

Which function gives the same result as MID()?

Answer

(a) SUBSTRING() MID(), SUBSTR() and SUBSTRING() do the same work.

A3.120Practice1 mark

Which pattern finds the names whose second letter is a?

Answer

(d) LIKE '_a%' _ is exactly one character, then 'a', then % for the rest: LIKE '_a%'.

A3.121Practice1 mark

What is the output of this query?

SELECT LENGTH('Computer');
Answer

(a) 8 LENGTH() counts every character, spaces also.

A3.122Practice1 mark

State True or False: WHERE Fee = NULL finds the rows where the fee is missing.

Answer

(b) False NULL is tested with IS NULL.

A3.123Practice1 mark

INSTR('school', 'x') returns

Answer

(d) 0 INSTR() returns 0 when the second string is not found.

A3.124Practice1 mark

What is the output of this query?

SELECT POWER(7, 4);
Answer

(d) 2401 POWER(a, b) is a multiplied by itself b times.

A3.125Practice1 mark

Which function returns the name of the week day of a date?

Answer

(d) DAYNAME() DAYNAME('2026-11-13') = 'Friday'.

A3.126Practice1 mark

What is the output of this query?

SELECT LENGTH(RIGHT('Digital India', 2));
Answer

(c) 2 Solve the inner function first.

A3.127Practice1 mark

What is the output of this query?

SELECT YEAR('2027-12-26') - 2003;
Answer

(b) 24 Solve the inner function first.

A3.128Practice1 mark

What is the output of this query?

SELECT INSTR('Data Science', 'a');
Answer

(a) 2 INSTR(text, part) gives the position of the first match; counting starts from 1.

A3.129Practice1 mark

What is the output of this query?

SELECT POWER(MOD(12, 4), 2);
Answer

(c) 0 Solve the inner function first.

A3.130Practice1 mark

What is the output of this query?

SELECT LENGTH(TRIM('   Internet   '));
Answer

(d) 8 TRIM() removes spaces from both ends, LTRIM() from the left end, RTRIM() from the right end. Spaces inside the text stay.

A3.131Practice1 mark

What is the output of this query?

SELECT LEFT(MONTHNAME('2027-10-22'), 3);
Answer

(d) Oct Solve the inner function first.

A3.132Practice1 mark

What is the output of this query?

SELECT ROUND(979.242, 1);
Answer

(c) 979.2 ROUND(x, d) rounds x to d decimal places. With no d, or d = 0, it rounds to a whole number. A negative d rounds to tens or hundreds.

A3.133Practice1 mark

What is the output of this query?

SELECT LEFT('Practices', 5);
Answer

(b) Pract LEFT(text, n) takes the first n characters.

A3.134Practice1 mark

What is the output of this query?

SELECT UCASE(MID('Pandas', 3, 3));
Answer

(d) NDA Solve the inner function first.

A3.135Practice1 mark

What is the output of this query?

SELECT INSTR('Welcome', 'me');
Answer

(b) 6 INSTR(text, part) gives the position of the first match; counting starts from 1.

A3.136Practice1 mark

What is the output of this query?

SELECT MOD(YEAR('2025-12-11'), 100);
Answer

(a) 25 Solve the inner function first.

A3.137Practice1 mark

What is the output of this query?

SELECT LEFT(MONTHNAME('2025-10-04'), 3);
Answer

(a) Oct Solve the inner function first.

A3.138Practice1 mark

What is the output of this query?

SELECT INSTR('DataFrame', 'Fr');
Answer

(c) 5 INSTR(text, part) gives the position of the first match; counting starts from 1.

A3.139Practice1 mark

What is the output of this query?

SELECT MOD(POWER(3, 3), 8);
Answer

(b) 3 Solve the inner function first.

A3.140Practice1 mark

What is the output of this query?

SELECT LENGTH(RTRIM(' Structured  '));
Answer

(a) 11 TRIM() removes spaces from both ends, LTRIM() from the left end, RTRIM() from the right end. Spaces inside the text stay.

A3.141Practice1 mark

What is the output of this query?

SELECT LENGTH('Kendriya');
Answer

(c) 8 LENGTH() counts every character, spaces also.

A3.142Practice1 mark

What is the output of this query?

SELECT YEAR('2025-12-17') - 2012;
Answer

(b) 13 Solve the inner function first.

A3.143Practice1 mark

What is the output of this query?

SELECT YEAR('2027-12-01');
Answer

(a) 2027 The date is written as year-month-day.

A3.144Practice1 mark

What is the output of this query?

SELECT LEFT(MONTHNAME('2025-06-03'), 3);
Answer

(c) Jun Solve the inner function first.

A3.145Practice1 mark

In an equi-join, the two tables are joined using

Answer

(d) the = operator on a common column An equi-join matches the common column with =.

A3.146Practice1 mark

What is the output of this query?

SELECT LENGTH(RTRIM('   Matplotlib '));
Answer

(c) 13 TRIM() removes spaces from both ends, LTRIM() from the left end, RTRIM() from the right end. Spaces inside the text stay.

A3.147Practice1 mark

What is the output of this query?

SELECT LCASE('Kendriya');
Answer

(d) kendriya UCASE() and UPPER() give capital letters; LCASE() and LOWER() give small letters.

A3.148Practice1 mark

The column Salary of a table has five rows with the values NULL, 150, 300, 850, 300. What does SELECT MIN(Salary) FROM ... return?

Answer

(a) 150 NULL values are ignored.

A3.149Practice1 mark

What is the output of this query?

SELECT MONTH('2026-10-27');
Answer

(c) 10 The date is written as year-month-day.

A3.150Practice1 mark

Which clause makes groups of rows that have the same value in a column?

Answer

(c) GROUP BY GROUP BY column puts the rows with the same value into one group.

A3.151Practice1 mark

What is the output of this query?

SELECT POWER(3, 3);
Answer

(b) 27 POWER(a, b) is a multiplied by itself b times.

A3.152Practice1 mark

What is the output of this query?

SELECT POWER(2, 4);
Answer

(c) 16 POWER(a, b) is a multiplied by itself b times.

A3.153Practice1 mark

What is the output of this query?

SELECT LEFT(RIGHT('Informatics', 6), 2);
Answer

(a) ma Solve the inner function first.

A3.154Practice1 mark

What is the output of this query?

SELECT MID('Board Exam', 4, 5);
Answer

(b) rd Ex MID(text, start, n) takes n characters; counting starts from 1.

A3.155Practice1 mark

DELETE FROM Book; (with no WHERE clause)

Answer

(a) removes all the rows but keeps the table Without WHERE, DELETE removes every row, but the empty table remains.

A3.156Practice1 mark

What is the output of this query?

SELECT RIGHT('Technology', 6);
Answer

(a) nology RIGHT(text, n) takes the last n characters.

A3.157Practice1 mark

What is the output of this query?

SELECT RIGHT('Shalimar Bagh', 6);
Answer

(b) r Bagh RIGHT(text, n) takes the last n characters.

A3.158Practice1 mark

What is the output of this query?

SELECT INSTR('Vidyalaya', 'a');
Answer

(b) 5 INSTR(text, part) gives the position of the first match; counting starts from 1.

A3.159Practice1 mark

DATE('2026-11-13 10:30:00') returns

Answer

(d) 2026-11-13 DATE() takes out the date part.

A3.160Practice1 mark

Which function returns the remainder of a division?

Answer

(a) MOD() MOD(13, 5) = 3, the remainder.

A3.161Practice1 mark

What is the output of this query?

SELECT MOD(57, 3);
Answer

(d) 0 MOD(a, b) is the remainder when a is divided by b.

A3.162Practice1 mark

Which command removes a table along with its structure?

Answer

(b) DROP TABLE DROP TABLE removes the table itself, with its structure and data.

A3.163Practice1 mark

What is the output of this query?

SELECT LENGTH(LTRIM('   Shalimar Bagh '));
Answer

(a) 14 TRIM() removes spaces from both ends, LTRIM() from the left end, RTRIM() from the right end. Spaces inside the text stay.

A3.164Practice1 mark

What is the output of this query?

SELECT MID('Education', 4, 4);
Answer

(c) cati MID(text, start, n) takes n characters; counting starts from 1.

A3.165Practice1 mark

What is the output of this query?

SELECT LOWER('Software');
Answer

(a) software UCASE() and UPPER() give capital letters; LCASE() and LOWER() give small letters.

A3.166Practice1 mark

Table A has 8 rows and table B has 7 rows. How many rows does SELECT * FROM A, B; give?

Answer

(c) 56 With no join condition, every row of A is paired with every row of B (Cartesian product).

A3.167Practice1 mark

The column Marks of a table has five rows with the values 20, 55, 90, NULL, 35. What does SELECT COUNT(*) FROM ... return?

Answer

(c) 5 COUNT(*) counts all the rows.

A3.168Practice1 mark

What is the output of this query?

SELECT RIGHT('Visualization', 4);
Answer

(a) tion RIGHT(text, n) takes the last n characters.

A4Computer networks MCQ1 mark · 62 questions
A4.1SQP 2026-271 mark

Which device changes digital signals of a computer into analog signals for a telephone line, and back again?

Answer

(c) Modem Modem = MOdulator DEModulator.

A4.2SQP 2026-271 mark

Fill in the blank: putting a website on a web server so that it can be opened through the Internet is called ______.

Answer

(b) web hosting Web hosting stores the website on a server connected to the Internet.

A4.3SQP 2026-271 mark

Small text files that a website saves on the user's computer to remember the user are called

Answer

(a) cookies Cookies remember logins, settings and cart items.

A4.4Practice1 mark

A network of devices around one person, within about 10 metres, is a

Answer

(a) PAN Example: a phone connected to earbuds by Bluetooth.

A4.5Practice1 mark

The computers of one school building are connected. This network is a

Answer

(a) LAN A LAN covers a building or campus.

A4.6Practice1 mark

A cable TV network that covers a whole city is an example of a

Answer

(b) MAN A MAN covers a city.

A4.7Practice1 mark

The Internet is the biggest example of a

Answer

(a) WAN The Internet is a worldwide network of networks.

A4.8Practice1 mark

Which network covers countries and continents?

Answer

(c) WAN A WAN (Wide Area Network) covers countries and continents.

A4.9Practice1 mark

Which device makes a weak signal strong again so that it can travel a longer distance?

Answer

(d) Repeater A repeater regenerates a weak signal.

A4.10Practice1 mark

Which device sends the data it receives to all the computers connected to it?

Answer

(c) Hub A hub broadcasts to all ports.

A4.11Practice1 mark

Which device sends the data only to the computer for which it is meant, inside a LAN?

Answer

(d) Switch A switch sends data only to the destination computer.

A4.12Practice1 mark

Which device connects two different networks and chooses the best path for the data?

Answer

(b) Router A router connects networks and picks the best path.

A4.13Practice1 mark

Which device connects two networks that use different protocols?

Answer

(c) Gateway A gateway translates between networks that use different protocols.

A4.14Practice1 mark

In which topology is every computer connected to a central hub or switch?

Answer

(a) Star In a star topology every computer has its own cable to the central device.

A4.15Practice1 mark

In which topology are all the computers connected to one main cable (backbone)?

Answer

(d) Bus In a bus topology all computers share one backbone cable.

A4.16Practice1 mark

In which topology is every computer connected to every other computer?

Answer

(d) Mesh In a mesh topology every node is linked to every other node.

A4.17Practice1 mark

Which topology is a combination of star and bus topologies and looks like branches?

Answer

(a) Tree Tree topology: star networks joined to a bus backbone, like branches.

A4.18Practice1 mark

In a star topology, if the central device fails,

Answer

(d) the whole network stops working Every computer depends on the central hub/switch, so the whole network stops.

A4.19Practice1 mark

In a bus topology, if the main cable breaks,

Answer

(d) the whole network stops working All computers share the backbone, so a break stops the network.

A4.20Practice1 mark

Which topology needs the most cable?

Answer

(a) Mesh Mesh: every computer is wired to every other one.

A4.21Practice1 mark

The full form of URL is

Answer

(c) Uniform Resource Locator URL = Uniform Resource Locator.

A4.22Practice1 mark

The full form of WWW is

Answer

(c) World Wide Web WWW = World Wide Web.

A4.23Practice1 mark

The full form of VoIP is

Answer

(d) Voice over Internet Protocol VoIP = Voice over Internet Protocol.

A4.24Practice1 mark

Which service lets us make voice calls over the Internet?

Answer

(b) VoIP VoIP carries voice over the Internet (e.g. WhatsApp calls).

A4.25Practice1 mark

The unique address of a web page on the Internet is called its

Answer

(c) URL The URL is the web address of a page.

A4.26Practice1 mark

In the URL https://www.cbse.gov.in/index.html, the part www.cbse.gov.in is the

Answer

(a) domain name The domain name identifies the website.

A4.27Practice1 mark

In the URL https://www.cbse.gov.in/index.html, the part https is the

Answer

(c) protocol https is the protocol used to fetch the page securely.

A4.28Practice1 mark

A program used to open and view web pages is called a

Answer

(a) web browser A web browser (Chrome, Firefox, Edge) opens web pages.

A4.29Practice1 mark

Which of these is a web browser?

Answer

(d) Mozilla Firefox Mozilla Firefox is a web browser.

A4.30Practice1 mark

Which of these is NOT a web browser?

Answer

(d) Gmail Gmail is an e-mail service, not a browser.

A4.31Practice1 mark

A computer that stores websites and sends web pages when a browser asks for them is a

Answer

(d) web server A web server stores websites and sends pages on request.

A4.32Practice1 mark

A collection of related web pages under one domain name is called a

Answer

(d) website A website is a set of linked pages under one domain.

A4.33Practice1 mark

A web page whose content stays the same for every visitor until the developer changes its code is a

Answer

(b) static web page A static page shows the same content to everyone.

A4.34Practice1 mark

A web page whose content changes with the user, the time or the data in a database is a

Answer

(c) dynamic web page A dynamic page is made fresh for each request.

A4.35Practice1 mark

A page that shows live cricket scores is a

Answer

(c) dynamic web page Live scores change all the time, so the page is dynamic.

A4.36Practice1 mark

A small program added to a browser to give it an extra feature, such as an ad blocker, is called an

Answer

(a) add-on (extension) An add-on (extension) adds a feature to the browser.

A4.37Practice1 mark

A program that helps a browser to play content such as some video or PDF formats, which the browser cannot handle on its own, is a

Answer

(b) plug-in A plug-in lets the browser handle content it cannot show by itself.

A4.38Practice1 mark

The first page that opens when a website is visited is called its

Answer

(c) home page The home page is the main page of a website.

A4.39Practice1 mark

The Internet is

Answer

(c) a worldwide network of networks The Internet is a worldwide network of networks.

A4.40Practice1 mark

The World Wide Web is

Answer

(a) a collection of linked web pages that are opened through the Internet The WWW is the system of linked web pages opened through the Internet.

A4.41Practice1 mark

Which service is used to send letters and files to a person's mail address over the Internet?

Answer

(c) E-mail E-mail sends messages and attachments to a mail address.

A4.42Practice1 mark

Talking to another person on the Internet by typing messages that are received at once is called

Answer

(c) chat Chat is real-time text conversation.

A4.43Practice1 mark

In the e-mail address ravi@kvs.ac.in, ravi is the

Answer

(b) user name The part before @ is the user name; after @ is the domain.

A4.44Practice1 mark

Which setting of a browser removes the list of sites you have visited?

Answer

(d) Clear browsing history Clearing the browsing history removes the list of visited sites.

A4.45Practice1 mark

Which browser mode does not keep the browsing history and cookies after the window is closed?

Answer

(a) Private (incognito) mode Private (incognito) mode does not save history and cookies.

A4.46Practice1 mark

The full form of LAN is

Answer

(a) Local Area Network LAN = Local Area Network.

A4.47Practice1 mark

The full form of MAN is

Answer

(b) Metropolitan Area Network MAN = Metropolitan Area Network.

A4.48Practice1 mark

The full form of PAN is

Answer

(c) Personal Area Network PAN = Personal Area Network (e.g. Bluetooth devices around one person).

A4.49Practice1 mark

A group of computers and devices connected to share data and resources is called a

Answer

(c) computer network A computer network connects devices to share data and resources.

A4.50Practice1 mark

Which of these is an advantage of a computer network?

Answer

(d) Sharing of files and printers Networks let us share files, printers and the Internet.

A4.51Practice1 mark

The way in which the computers of a network are arranged and connected is called its

Answer

(d) topology Topology is the layout of a network.

A4.52Practice1 mark

The offices of a bank in Delhi, Mumbai and Chennai are connected. This network is a

Answer

(d) WAN Cities far apart are joined by a WAN.

A4.53Practice1 mark

The distance between two blocks is more than 100 m. Which device should be placed between them?

Answer

(b) Repeater Ethernet signals weaken after about 100 m, so a repeater is placed.

A4.54Practice1 mark

In a network case study, the server is usually placed in the block that has

Answer

(a) the largest number of computers This keeps most of the traffic local and reduces cable cost.

A4.55Practice1 mark

Which device is needed in every block to connect the computers of that block?

Answer

(b) Switch (or hub) A switch (or hub) connects the computers inside a block.

A4.56Practice1 mark

State True or False: A hub is more intelligent than a switch.

Answer

(b) False A hub sends data to every port; a switch sends it only to the right port.

A4.57Practice1 mark

State True or False: A dynamic web page can show different content to different users.

Answer

(a) True Dynamic pages are made for each user and request.

A4.58Practice1 mark

State True or False: Cookies can store the items a user put in a shopping cart.

Answer

(a) True Cookies remember data such as cart items between visits.

A4.59Practice1 mark

State True or False: The Internet and the World Wide Web are the same thing.

Answer

(b) False The Internet is the network. The Web is one service that runs on it.

A4.60Practice1 mark

State True or False: In a star topology, the failure of one computer does not affect the others.

Answer

(a) True Each computer has its own link to the centre, so others keep working.

A4.61Practice1 mark

State True or False: VoIP calls need a traditional telephone exchange line for every call.

Answer

(b) False VoIP sends voice as data packets over the Internet.

A4.62Practice1 mark

State True or False: A website can be opened by others only after it is hosted on a web server.

Answer

(a) True Hosting puts the website on a server reachable through the Internet.

A5Societal impacts MCQ1 mark · 62 questions
A5.1SQP 2026-271 mark

Which Intellectual Property Right protects an invention?

Answer

(d) Patent A patent protects an invention.

A5.2SQP 2026-271 mark

Repairing old electronic goods and selling them again is called

Answer

(c) refurbishing Refurbishing repairs and resells used devices.

A5.3SQP 2026-271 mark

Buying a new gadget only when it is really needed follows which 'R' of e-waste management?

Answer

(b) Reduce Reduce: buy less, so less e-waste is made.

A5.4Practice1 mark

The trail of data that a person leaves behind while using the Internet is called a

Answer

(c) digital footprint Every online action leaves a digital footprint.

A5.5Practice1 mark

A post that you upload yourself on social media is part of your

Answer

(b) active digital footprint You posted it on purpose, so it is an active footprint.

A5.6Practice1 mark

The record of your location kept by an app without your knowledge is part of your

Answer

(c) passive digital footprint Data collected without your knowing is a passive footprint.

A5.7Practice1 mark

The rules of good behaviour on the Internet are called

Answer

(c) netiquette Netiquette is good manners online.

A5.8Practice1 mark

Which of these is good netiquette?

Answer

(c) Being polite in comments and messages Being polite and respectful online is good netiquette.

A5.9Practice1 mark

Writing a full message in capital letters is taken on the Internet as

Answer

(b) shouting ALL CAPS reads as shouting.

A5.10Practice1 mark

Copyright protects

Answer

(d) original works such as books, songs, films and software Copyright protects original creative works such as books, songs, films and software.

A5.11Practice1 mark

A logo or brand name of a company is protected by a

Answer

(c) trademark A trademark protects logos and brand names.

A5.12Practice1 mark

A song writer wants to stop others from copying her new song. Which right protects her?

Answer

(b) Copyright Copyright protects her song.

A5.13Practice1 mark

The full form of IPR is

Answer

(d) Intellectual Property Rights IPR = Intellectual Property Rights.

A5.14Practice1 mark

Using someone else's work or idea as your own, without giving credit, is called

Answer

(d) plagiarism Plagiarism is passing off another's work as your own.

A5.15Practice1 mark

Copying a paragraph from a website into a project without naming the source is

Answer

(a) plagiarism Not naming the source is plagiarism.

A5.16Practice1 mark

The best way to avoid plagiarism is to

Answer

(d) write in your own words and name the source Write in your own words and cite the source.

A5.17Practice1 mark

A legal permission that tells how a software can be used is called a

Answer

(c) licence A licence sets the terms of use.

A5.18Practice1 mark

Software whose source code is available to all, to study, change and share, is called

Answer

(d) open source software Open source software shares its source code.

A5.19Practice1 mark

The full form of FOSS is

Answer

(b) Free and Open Source Software FOSS = Free and Open Source Software.

A5.20Practice1 mark

Which of these is an example of free and open source software?

Answer

(c) LibreOffice LibreOffice is free and open source.

A5.21Practice1 mark

Which of these is proprietary software?

Answer

(d) Microsoft Windows Microsoft Windows is owned by Microsoft and its code is closed.

A5.22Practice1 mark

GPL and Creative Commons are examples of

Answer

(d) public licences They are public licences that let others use works on stated terms.

A5.23Practice1 mark

Any crime done with the help of a computer or the Internet is called

Answer

(a) cyber crime Cyber crime is crime that uses computers or the Internet.

A5.24Practice1 mark

Getting into someone's computer or account without permission is called

Answer

(a) hacking Unauthorised access is hacking.

A5.25Practice1 mark

A fake e-mail that looks like it is from a bank and asks for your password is an example of

Answer

(a) phishing Phishing tricks people into giving passwords.

A5.26Practice1 mark

Sending hurtful or threatening messages to a person again and again on social media is

Answer

(d) cyber bullying Repeated harassment online is cyber bullying.

A5.27Practice1 mark

The Indian law that deals with cyber crime and electronic records is the

Answer

(b) Information Technology Act, 2000 The Information Technology Act, 2000.

A5.28Practice1 mark

In which year was the IT Act of India amended in a major way?

Answer

(d) 2008 The IT (Amendment) Act, 2008 added sections such as 66C and 66D.

A5.29Practice1 mark

Old and discarded electronic items such as phones and computers are called

Answer

(a) e-waste Discarded electronics are e-waste.

A5.30Practice1 mark

Which harmful metal is found in e-waste such as old batteries and monitors?

Answer

(d) Lead Lead (also mercury and cadmium) is found in e-waste.

A5.31Practice1 mark

Burning e-waste in the open mainly causes

Answer

(d) air pollution and breathing problems Toxic fumes pollute the air and cause breathing problems.

A5.32Practice1 mark

Which is the right way to dispose of an old phone?

Answer

(b) Give it to an authorised e-waste recycler An authorised recycler handles e-waste safely.

A5.33Practice1 mark

Giving your old working computer to a needy student is an example of

Answer

(b) reuse Using it again for someone else is reuse.

A5.34Practice1 mark

Breaking old gadgets into parts and using the metals to make new products is called

Answer

(b) recycling Recovering materials to make new products is recycling.

A5.35Practice1 mark

Sitting in front of a screen for long hours without breaks can cause

Answer

(a) eye strain and back pain Long screen time strains the eyes and causes back pain.

A5.36Practice1 mark

Pain in the wrist due to long hours of typing is commonly linked to

Answer

(c) repetitive strain injury Repetitive Strain Injury comes from repeating the same movement.

A5.37Practice1 mark

Which habit protects the eyes while using a computer?

Answer

(a) Looking away from the screen at regular intervals Look away regularly (20-20-20 rule) to rest the eyes.

A5.38Practice1 mark

Which of these is a strong password?

Answer

(b) Kv@Delhi#2027 It mixes capital and small letters, digits and symbols.

A5.39Practice1 mark

Data protection means

Answer

(b) keeping personal data safe from misuse and unauthorised access Data protection keeps personal data safe from misuse and unauthorised access.

A5.40Practice1 mark

Which of these is personal (sensitive) data?

Answer

(a) Aadhaar number An Aadhaar number identifies you and must be kept private.

A5.41Practice1 mark

Before posting a photo of your friend online, you should

Answer

(b) take your friend's permission Take permission; the friend has the right to privacy.

A5.42Practice1 mark

You get a message that you have won a lottery and must share your bank details. You should

Answer

(d) not reply and report it It is a scam; do not reply and report it (1930 / cybercrime.gov.in).

A5.43Practice1 mark

Whom should a child tell first when someone troubles him or her online?

Answer

(a) Parents or a teacher Parents or teachers can help and protect the child.

A5.44Practice1 mark

A person who breaks into computer systems to harm or steal is called a

Answer

(d) cracker (black hat hacker) A cracker (black-hat hacker) breaks in with bad intent.

A5.45Practice1 mark

An expert who is hired to find weak points in a system so that they can be fixed is called

Answer

(c) an ethical hacker An ethical (white-hat) hacker works with permission to improve security.

A5.46Practice1 mark

Which of these is NOT a cyber crime?

Answer

(b) Using a licensed copy of a software Using a licensed copy is legal.

A5.47Practice1 mark

Unwanted bulk e-mails sent to many people are called

Answer

(a) spam Spam is unwanted bulk e-mail.

A5.48Practice1 mark

Which symbol shows that a work is protected by copyright?

Answer

(a) A letter C inside a circle © (C in a circle) is the copyright symbol.

A5.49Practice1 mark

For how long is a patent generally valid?

Answer

(d) 20 years A patent is generally valid for 20 years.

A5.50Practice1 mark

Using a paid software without buying its licence is called

Answer

(a) software piracy That is software piracy.

A5.51Practice1 mark

Which of these helps to keep your account safe?

Answer

(d) Two-step verification (OTP) Two-step verification adds an OTP check after the password.

A5.52Practice1 mark

The data about us that remains online even after we delete a post shows that a digital footprint is

Answer

(c) permanent in nature Copies may remain on servers and with others, so footprints are permanent.

A5.53Practice1 mark

Which of these is a responsible use of social media?

Answer

(b) Checking a news item before sharing it Check facts before sharing to stop fake news.

A5.54Practice1 mark

Software that is free to use but whose source code is not given is called

Answer

(c) freeware Freeware is free but closed source.

A5.55Practice1 mark

Which body part is most affected by listening to loud music on earphones for long hours?

Answer

(b) Ears (hearing loss) Loud sound for long periods damages hearing.

A5.56Practice1 mark

State True or False: A digital footprint can affect a person's admission or job in future.

Answer

(a) True Colleges and employers may check a person's online record.

A5.57Practice1 mark

State True or False: Throwing e-waste with household garbage is safe for the soil and water.

Answer

(b) False Lead, mercury and cadmium from e-waste poison the soil and ground water.

A5.58Practice1 mark

State True or False: Free and open source software can be changed and shared by its users.

Answer

(a) True FOSS gives the freedom to change and share.

A5.59Practice1 mark

State True or False: Copying a friend's project and submitting it with your name is plagiarism.

Answer

(a) True Presenting another's work as yours is plagiarism.

A5.60Practice1 mark

State True or False: It is safe to click a link in an e-mail from an unknown sender.

Answer

(b) False It may be a phishing link.

A5.61Practice1 mark

State True or False: The IT Act, 2000 gives legal recognition to electronic records and digital signatures.

Answer

(a) True The IT Act makes electronic records and digital signatures legally valid.

A5.62Practice1 mark

State True or False: Passive digital footprints are made only when we post something ourselves.

Answer

(b) False Passive footprints are collected without our action, such as the sites we visit.

A6Assertion and Reason1 mark · 48 questions
A6.1SQP 2026-271 mark

Assertion (A): df.drop('Science', axis=0) removes the column 'Science' from the DataFrame df.

Reason (R): In drop(), axis=0 stands for rows and axis=1 stands for columns.

Answer

(d) A is false but R is true. With axis=0 Pandas looks for a row labelled 'Science'. To remove a column, axis=1 is needed.

A6.2SQP 2026-271 mark

Assertion (A): SELECT and select are treated as the same keyword by MySQL.

Reason (R): SQL keywords are case-sensitive.

Answer

(c) A is true but R is false. SQL keywords are not case-sensitive, so the reason is false.

A6.3Practice1 mark

Assertion (A): A Series can hold the marks of five students with their names as labels.

Reason (R): A Series is a one-dimensional labelled array.

Answer

(a) Both A and R are true and R is the correct explanation of A. A Series is a 1-D array with labels (R), so names can be the index (A).

A6.4Practice1 mark

Assertion (A): S1 + S2 gives NaN for a label that is present only in S1.

Reason (R): Pandas adds two Series by matching their index labels.

Answer

(a) Both A and R are true and R is the correct explanation of A. Labels are matched (R); a label missing in S2 has nothing to add to, so the result is NaN (A).

A6.5Practice1 mark

Assertion (A): df.head() shows the first five rows of df.

Reason (R): The default value of n in head() is 5.

Answer

(a) Both A and R are true and R is the correct explanation of A. The default n of head() is 5 (R), so five rows are shown (A).

A6.6Practice1 mark

Assertion (A): The size of a Series cannot be changed after it is created.

Reason (R): The values of a Series can be changed.

Answer

(b) Both A and R are true but R is not the correct explanation of A. Both are true, but one does not explain the other.

A6.7Practice1 mark

Assertion (A): A DataFrame df has the row labels R1, R2, R3, R4 and R5. df.loc['R1':'R3'] returns three rows.

Reason (R): With loc, the end label of a slice is included.

Answer

(a) Both A and R are true and R is the correct explanation of A. With loc the end label is included (R), so R1, R2, R3 are returned (A).

A6.8Practice1 mark

Assertion (A): df.iloc[1:3] returns three rows.

Reason (R): With iloc, the stop position of a slice is not included.

Answer

(d) A is false but R is true. Rows at positions 1 and 2 are returned, so the assertion is false.

A6.9Practice1 mark

Assertion (A): df['Total'] = df['A'] + df['B'] adds a new column to df.

Reason (R): Assigning to a column label that does not exist creates that column.

Answer

(a) Both A and R are true and R is the correct explanation of A. Assigning to a new column label creates it (R), so Total is added (A).

A6.10Practice1 mark

Assertion (A): df.to_csv('m.csv', index=False) writes the row labels to the file.

Reason (R): index=False tells Pandas not to write the row labels.

Answer

(d) A is false but R is true. A is false: index=False means the row labels are NOT written (R is true).

A6.11Practice1 mark

Assertion (A): pd.read_csv('m.csv') returns a DataFrame.

Reason (R): A CSV file stores data in rows, with the values separated by commas.

Answer

(b) Both A and R are true but R is not the correct explanation of A. Both are true, but R only describes a CSV file; it does not explain why read_csv() returns a DataFrame.

A6.12Practice1 mark

Assertion (A): A DataFrame can have a column of names and a column of marks.

Reason (R): All the columns of a DataFrame must have the same data type.

Answer

(c) A is true but R is false. Different columns can have different data types.

A6.13Practice1 mark

Assertion (A): S[S > 40] returns only the elements greater than 40.

Reason (R): A condition on a Series gives a Series of True and False values, which is used to pick the elements.

Answer

(a) Both A and R are true and R is the correct explanation of A. The condition gives True/False for each element (R), and only True ones are kept (A).

A6.14Practice1 mark

Assertion (A): df.shape of a DataFrame with 4 rows and 3 columns is (3, 4).

Reason (R): shape gives the number of rows first and then the number of columns.

Answer

(d) A is false but R is true. The shape is (4, 3).

A6.15Practice1 mark

Assertion (A): del df['Fee'] removes the column 'Fee' from df.

Reason (R): del deletes the column from the DataFrame itself.

Answer

(a) Both A and R are true and R is the correct explanation of A. del deletes the column from df itself (R), so it is removed (A).

A6.16Practice1 mark

Assertion (A): df.rename(columns={'A': 'X'}) changes the row labels.

Reason (R): The columns parameter of rename() is used for column labels.

Answer

(d) A is false but R is true. A is false: columns= renames column labels (R is true); index= would change row labels.

A6.17Practice1 mark

Assertion (A): A Series created from a dictionary has the keys as its index.

Reason (R): A dictionary has key and value pairs.

Answer

(b) Both A and R are true but R is not the correct explanation of A. Both are true, but R only says a dictionary has key-value pairs; it does not explain why keys become the index.

A6.18Practice1 mark

Assertion (A): S.tail(2) returns the first two elements of S.

Reason (R): tail() returns elements from the end of a Series.

Answer

(d) A is false but R is true. A is false: tail() gives the last elements (R is true); head(2) gives the first two.

A6.19Practice1 mark

Assertion (A): pd.Series([10, 20, 30]) has the index 0, 1, 2.

Reason (R): When no index is given, Pandas gives a default index that starts from 0.

Answer

(a) Both A and R are true and R is the correct explanation of A. With no index given, pandas uses 0, 1, 2 ... (R), so A is true.

A6.20Practice1 mark

Assertion (A): A DataFrame made from a list of dictionaries may have NaN values.

Reason (R): If a key is missing in one dictionary, that cell gets NaN.

Answer

(a) Both A and R are true and R is the correct explanation of A. A missing key gives NaN in that cell (R), so NaN can appear (A).

A6.21Practice1 mark

Assertion (A): S * 2 gives an error for a Series of numbers.

Reason (R): Arithmetic operations on a Series are done on every element.

Answer

(d) A is false but R is true. A is false: arithmetic works on every element (R is true), so each value is doubled.

A6.22Practice1 mark

Assertion (A): df.size of a DataFrame with 5 rows and 2 columns is 10.

Reason (R): size gives the number of rows multiplied by the number of columns.

Answer

(a) Both A and R are true and R is the correct explanation of A. size = rows × columns (R) = 5 × 2 = 10 (A).

A6.23Practice1 mark

Assertion (A): df.T changes the rows into columns and the columns into rows.

Reason (R): T stands for transpose.

Answer

(a) Both A and R are true and R is the correct explanation of A. T stands for transpose (R), which swaps rows and columns (A).

A6.24Practice1 mark

Assertion (A): df.drop('R2') removes the row 'R2' from df itself.

Reason (R): drop() returns a new DataFrame and leaves the original as it is.

Answer

(d) A is false but R is true. A is false: drop() returns a new DataFrame (R is true); df stays the same unless inplace=True.

A6.25Practice1 mark

Assertion (A): COUNT(*) and COUNT(Fee) can give different answers on the same table.

Reason (R): COUNT(column) does not count the NULL values of that column.

Answer

(a) Both A and R are true and R is the correct explanation of A. COUNT(Fee) skips NULLs (R) while COUNT(*) counts all rows, so they can differ (A).

A6.26Practice1 mark

Assertion (A): HAVING is used to put a condition on groups.

Reason (R): WHERE cannot be used with aggregate functions.

Answer

(a) Both A and R are true and R is the correct explanation of A. WHERE cannot use aggregate functions (R), so HAVING is used for group conditions (A).

A6.27Practice1 mark

Assertion (A): SELECT Name FROM Emp ORDER BY Salary; shows the lowest salary first.

Reason (R): ORDER BY sorts in ascending order when no order is written.

Answer

(a) Both A and R are true and R is the correct explanation of A. Ascending is the default (R), so the lowest salary comes first (A).

A6.28Practice1 mark

Assertion (A): WHERE Marks BETWEEN 40 AND 60 shows a student who has 60 marks.

Reason (R): BETWEEN includes both the limits.

Answer

(a) Both A and R are true and R is the correct explanation of A. BETWEEN includes both limits (R), so 60 is included (A).

A6.29Practice1 mark

Assertion (A): SELECT UCASE('kv'); returns KV.

Reason (R): UCASE() and UPPER() do the same work.

Answer

(b) Both A and R are true but R is not the correct explanation of A. Both are true, but saying UCASE() and UPPER() are the same does not explain why the result is KV.

A6.30Practice1 mark

Assertion (A): SELECT LENGTH('IP 065'); returns 5.

Reason (R): LENGTH() counts spaces also.

Answer

(d) A is false but R is true. The string has 6 characters including the space.

A6.31Practice1 mark

Assertion (A): SELECT MOD(17, 5); returns 2.

Reason (R): MOD() returns the quotient of a division.

Answer

(c) A is true but R is false. MOD() returns the remainder.

A6.32Practice1 mark

Assertion (A): SELECT ROUND(15.67, 1); returns 15.7.

Reason (R): ROUND() rounds a number to the given number of decimal places.

Answer

(a) Both A and R are true and R is the correct explanation of A. ROUND rounds to 1 decimal place (R): 15.67 becomes 15.7 (A).

A6.33Practice1 mark

Assertion (A): AVG(Fee) leaves out the rows where Fee is NULL.

Reason (R): Aggregate functions ignore NULL values.

Answer

(a) Both A and R are true and R is the correct explanation of A. Aggregate functions ignore NULLs (R), so AVG uses only rows with a Fee (A).

A6.34Practice1 mark

Assertion (A): DELETE FROM Emp; removes the table Emp from the database.

Reason (R): DELETE is a DML command that removes rows.

Answer

(d) A is false but R is true. The rows go, but the empty table stays.

A6.35Practice1 mark

Assertion (A): DROP TABLE is a DDL command.

Reason (R): DROP TABLE removes the rows and also the structure of the table.

Answer

(b) Both A and R are true but R is not the correct explanation of A. Both are true, but R tells what DROP TABLE does, not why it is DDL (it changes the structure/definition).

A6.36Practice1 mark

Assertion (A): WHERE Name LIKE 'A%' shows the name Anil.

Reason (R): In a LIKE pattern, % stands for any number of characters.

Answer

(a) Both A and R are true and R is the correct explanation of A. % means any number of characters (R), so 'A' followed by anything matches Anil (A).

A6.37Practice1 mark

Assertion (A): WHERE Name LIKE '_a%' shows the name Aman.

Reason (R): In a LIKE pattern, _ stands for exactly one character.

Answer

(d) A is false but R is true. The second letter of Aman is m, so it is not shown.

A6.38Practice1 mark

Assertion (A): In an equi-join, a common column is needed in the two tables.

Reason (R): The join condition compares the common column of the two tables with the = sign.

Answer

(a) Both A and R are true and R is the correct explanation of A. The join compares the common column with = (R), so the column is needed (A).

A6.39Practice1 mark

Assertion (A): SELECT City, COUNT(*) FROM Emp GROUP BY City; gives one row for every city.

Reason (R): GROUP BY puts the rows with the same value into one group.

Answer

(a) Both A and R are true and R is the correct explanation of A. GROUP BY makes one group per city (R), so one row per city (A).

A6.40Practice1 mark

Assertion (A): SELECT MONTHNAME('2027-03-15'); returns 3.

Reason (R): MONTH() returns the month number of a date.

Answer

(d) A is false but R is true. MONTHNAME() returns March.

A6.41Practice1 mark

Assertion (A): SELECT INSTR('PANDAS', 'A'); returns 2.

Reason (R): INSTR() returns the position of the first occurrence of a string in another string.

Answer

(a) Both A and R are true and R is the correct explanation of A. INSTR gives the position of the first 'a' (R); in 'pandas' it is position 2 (A).

A6.42Practice1 mark

Assertion (A): SELECT TRIM(' IP '); returns IP without spaces.

Reason (R): LTRIM() removes spaces from the left end only.

Answer

(b) Both A and R are true but R is not the correct explanation of A. Both are true, but R is about LTRIM(); TRIM() removes spaces from both ends.

A6.43Practice1 mark

Assertion (A): SELECT MAX(Marks), Name FROM Student; is the right way to find the name of the topper.

Reason (R): MAX() returns the highest value of a column.

Answer

(d) A is false but R is true. MAX() gives only the highest marks. The name shown beside it need not be of the topper.

A6.44Practice1 mark

Assertion (A): UPDATE Emp SET Salary = Salary + 500; changes the salary of every employee.

Reason (R): When WHERE is not written, UPDATE works on all the rows.

Answer

(a) Both A and R are true and R is the correct explanation of A. Without WHERE, UPDATE works on all rows (R), so every salary changes (A).

A6.45Practice1 mark

Assertion (A): SELECT POWER(2, 5); returns 10.

Reason (R): POWER(a, b) returns a raised to the power b.

Answer

(d) A is false but R is true. 2 raised to 5 is 32.

A6.46Practice1 mark

Assertion (A): SELECT DISTINCT City FROM Emp; may show fewer rows than the table has.

Reason (R): DISTINCT shows each different value only once.

Answer

(a) Both A and R are true and R is the correct explanation of A. DISTINCT shows each value once (R), so repeated cities are removed (A).

A6.47Practice1 mark

Assertion (A): SELECT RIGHT('Informatics', 3); returns ics.

Reason (R): RIGHT() takes characters from the end of a string.

Answer

(a) Both A and R are true and R is the correct explanation of A. RIGHT() takes characters from the end (R): the last 3 are 'ics' (A).

A6.48Practice1 mark

Assertion (A): WHERE SUM(Fee) > 5000 is a valid condition.

Reason (R): Aggregate functions can be used in the HAVING clause.

Answer

(d) A is false but R is true. A is false: aggregates cannot be used in WHERE; they are used in HAVING (R is true).

Section B · 2 marks each

B1Pandas: explain, differentiate, write code2 marks · 106 questions
B1.1SQP 2026-272 marks

What does the head() function of Pandas do? Write a statement to show the first three rows of a DataFrame df.

Answer

head(n) returns the first n rows of a Series or DataFrame. If n is not given, it returns 5 rows.

print(df.head(3))
B1.2SQP 2026-272 marks

What is Boolean indexing in Pandas? Give one example.

Answer

Boolean indexing means picking the rows for which a condition is True. The condition is written inside the square brackets. The statement below shows the rows of df where Marks are more than 80.

print(df[df['Marks'] > 80])
B1.3SQP 2026-272 marks

Which function loads a CSV file into a DataFrame? What is the use of its sep parameter?

Answer

read_csv() reads a CSV file and returns a DataFrame. sep tells which character separates the values in the file, for example a comma, a semicolon or a tab. The default is a comma.

df = pd.read_csv('marks.csv', sep=';')
B1.4Practice2 marks

Write two differences between a Series and a DataFrame.

Answer

(1) A Series is one-dimensional; a DataFrame is two-dimensional (rows and columns). (2) A Series holds values of one data type; the columns of a DataFrame can have different data types. Also, the size of a Series is fixed, but rows and columns can be added to a DataFrame.

B1.5Practice2 marks

Write two differences between loc and iloc.

Answer

(1) loc selects by labels; iloc selects by integer positions. (2) In a slice, loc includes the end label; iloc leaves out the stop position. Example: df.loc['R1':'R3'] gives 3 rows, df.iloc[0:3] also gives 3 rows (positions 0, 1, 2).

B1.6Practice2 marks

Write the difference between head() and tail() with an example of each.

Answer

head(n) returns the first n rows; tail(n) returns the last n rows. Both return 5 rows when n is not given.

print(df.head(2))     # first two rows
print(df.tail(2))     # last two rows
B1.7Practice2 marks

What is the difference between size and shape of a DataFrame?

Answer

size is the total number of values (rows x columns). shape is a tuple of the number of rows and the number of columns. For a DataFrame of 4 rows and 3 columns, df.size is 12 and df.shape is (4, 3).

B1.8Practice2 marks

What is NaN? Write one situation in which a Series gets NaN values.

Answer

NaN means Not a Number. It marks a missing value. Example: when two Series are added and a label is present in only one of them, the result has NaN against that label.

B1.9Practice2 marks

What is a CSV file? Write one advantage of using it.

Answer

CSV means Comma Separated Values. It is a text file in which each line is one row and the values are separated by commas. It is small in size and can be opened in any spreadsheet, text editor or program, so it is easy to move data from one software to another.

B1.10Practice2 marks

Write the use of the parameters header and names of read_csv().

Answer

header=None tells Pandas that the file has no heading row, so the first line is treated as data. names=[...] gives our own column names to the DataFrame.

df = pd.read_csv('emp.csv', header=None, names=['Eno', 'Name', 'Pay'])
B1.11Practice2 marks

Write the use of the parameters index and header of to_csv().

Answer

index=False does not write the row labels to the file. header=False does not write the column names to the file.

df.to_csv('emp.csv', index=False, header=False)
B1.12Practice2 marks

What do axis=0 and axis=1 mean in df.drop()? Give one example of each.

Answer

axis=0 means a row label is given; axis=1 means a column label is given.

df = df.drop('R2', axis=0)       # removes the row R2
df = df.drop('Fee', axis=1)      # removes the column Fee
B1.13Practice2 marks

Write any two ways of creating a Series. Give one statement for each.

Answer

A Series can be created from a list, a dictionary, a NumPy array or a single value.

S1 = pd.Series([10, 20, 30])              # from a list
S2 = pd.Series({'a': 10, 'b': 20})        # from a dictionary
B1.14Practice2 marks

Write any two ways of creating a DataFrame. Give one statement for each.

Answer

A DataFrame can be created from a dictionary of lists, a list of dictionaries, a dictionary of Series or a CSV file.

D1 = pd.DataFrame({'Name': ['Asha', 'Ravi'], 'Marks': [91, 78]})
D2 = pd.DataFrame([{'Name': 'Asha', 'Marks': 91}, {'Name': 'Ravi', 'Marks': 78}])
B1.15Practice2 marks

What is the difference between the attributes index and columns of a DataFrame?

Answer

df.index gives the row labels and df.columns gives the column labels. New labels can also be given through them, for example df.columns = ['A', 'B'].

B1.16Practice2 marks

What are vector operations on a Series? Give one example.

Answer

An arithmetic operation written on a Series is done on every element at one go. No loop is needed. Example: S + 5 adds 5 to every element of S.

B1.17Practice2 marks

Write two differences between del df['A'] and df.drop('A', axis=1).

Answer

(1) del removes the column from df itself; drop() returns a new DataFrame and df stays the same unless the result is stored. (2) del removes one column at a time; drop() can remove many labels, and rows also (axis=0).

B1.18Practice2 marks

A DataFrame df has the columns Name and Marks. Write statements to:

  1. Show its number of rows and columns
  2. Show its column names.
Answer

shape gives (rows, columns) and columns gives the column labels.

print(df.shape)
print(df.columns)
B1.19Practice2 marks

What is the use of the rename() function? Write a statement to change the column label 'Qty' to 'Quantity' in df.

Answer

rename() changes row labels or column labels. A dictionary of old and new labels is given to index (rows) or columns.

df = df.rename(columns={'Qty': 'Quantity'})
B1.20Practice2 marks

How is a Series different from a Python list? Write two points.

Answer

(1) A Series has labels (index) that we can choose; a list has only positions 0, 1, 2 ... (2) Arithmetic on a Series works on every element (S * 2 doubles every value); L * 2 on a list repeats the list.

B1.21Practice2 marks

Explain iterrows() with an example.

Answer

iterrows() is used in a for loop to go through a DataFrame row by row. In every turn it gives the row label and the row as a Series.

for i, row in df.iterrows():
    print(i, row['Name'])
B1.22Practice2 marks

What happens when two Series with different index labels are added? Explain with an example.

Answer

Pandas adds the values that have the same label. A label that is present in only one Series gets NaN. Example: S1 has labels a, b and S2 has labels b, c. S1 + S2 has NaN for a, the sum for b and NaN for c.

B1.23Practice2 marks

Write the difference between df['Marks'] and df[['Marks']].

Answer

df['Marks'] returns the column as a Series. df[['Marks']] (a list inside the brackets) returns a DataFrame with that one column. More columns can be asked in the same way: df[['Name', 'Marks']].

B1.24Practice2 marks

What is the difference between df.loc['R5'] = [...] and df['C5'] = [...]?

Answer

df.loc['R5'] = [...] adds (or changes) a row with the label R5. df['C5'] = [...] adds (or changes) a column with the label C5.

B1.25Practice2 marks

Write statements to:

  1. Import Pandas
  2. Read the file stock.csv into a DataFrame df.
Answer

The file must be in the current folder, or its full path is given.

import pandas as pd
df = pd.read_csv('stock.csv')
B1.26Practice2 marks

Write a statement to save the DataFrame df in the file result.csv without the row labels. Which separator is used by default?

Answer

The default separator is a comma.

df.to_csv('result.csv', index=False)
B1.27Practice2 marks

Write a Python program to create a Series Marks that stores the marks of five students as 49, 69, 89, 51, 85, with the labels Asha, Ravi, Tina, Om, Zoya. Then display the values that are more than 69.

Answer
import pandas as pd
Marks = pd.Series([49, 69, 89, 51, 85], index=['Asha', 'Ravi', 'Tina', 'Om', 'Zoya'])
print(Marks[Marks > 69])

Output:

Tina    89
Zoya    85
dtype: int64
B1.28Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series({'Asha': 49, 'Ravi': 69, 'Tina': 89, 'Om': 51})
print(S.head(2))
print(S.size)
Answer

Output:

Asha    49
Ravi    69
dtype: int64
4
B1.29Practice2 marks

Write a Python program to create a Series Runs that stores the runs scored by five players as 84, 118, 34, 79, 55, with the labels Rohit, Virat, Gill, Rahul, Pant. Then display the values that are more than 79.

Answer
import pandas as pd
Runs = pd.Series([84, 118, 34, 79, 55], index=['Rohit', 'Virat', 'Gill', 'Rahul', 'Pant'])
print(Runs[Runs > 79])

Output:

Rohit     84
Virat    118
dtype: int64
B1.30Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series([84, 118, 34, 79], index=['Rohit', 'Virat', 'Gill', 'Rahul'])
print(S.tail(2))
print(S['Rohit'])
Answer

Output:

Gill     34
Rahul    79
dtype: int64
84
B1.31Practice2 marks

Write a Python program to create a Series Sales that stores the sales (in thousand rupees) of five months as 40, 70, 65, 45, 30, with the labels Jan, Feb, Mar, Apr, May. Then display the values that are more than 45.

Answer
import pandas as pd
Sales = pd.Series([40, 70, 65, 45, 30], index=['Jan', 'Feb', 'Mar', 'Apr', 'May'])
print(Sales[Sales > 45])

Output:

Feb    70
Mar    65
dtype: int64
B1.32Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series({'Jan': 40, 'Feb': 70, 'Mar': 65, 'Apr': 45})
print(S * 2)
Answer

Output:

Jan     80
Feb    140
Mar    130
Apr     90
dtype: int64
B1.33Practice2 marks

Write a Python program to create a Series Price that stores the price of five items as 300, 140, 50, 390, 80, with the labels Pen, Book, Bag, Box, Ink. Then display the values that are more than 140.

Answer
import pandas as pd
Price = pd.Series([300, 140, 50, 390, 80], index=['Pen', 'Book', 'Bag', 'Box', 'Ink'])
print(Price[Price > 140])

Output:

Pen    300
Box    390
dtype: int64
B1.34Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series([300, 140, 50, 390], index=['Pen', 'Book', 'Bag', 'Box'])
print(S[1:3])
print(S.max())
Answer

Output:

Book    140
Bag      50
dtype: int64
390
B1.35Practice2 marks

Write a Python program to create a Series Temp that stores the temperature (in Celsius) of five cities as 6, 17, 19, 30, 26, with the labels Delhi, Pune, Agra, Kochi, Leh. Then display the values that are more than 19.

Answer
import pandas as pd
Temp = pd.Series([6, 17, 19, 30, 26], index=['Delhi', 'Pune', 'Agra', 'Kochi', 'Leh'])
print(Temp[Temp > 19])

Output:

Kochi    30
Leh      26
dtype: int64
B1.36Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series({'Delhi': 6, 'Pune': 17, 'Agra': 19, 'Kochi': 30})
print(S.head(2))
print(S.size)
Answer

Output:

Delhi     6
Pune     17
dtype: int64
4
B1.37Practice2 marks

Write a Python program to create a Series Stock that stores the number of books of five subjects as 70, 60, 75, 20, 15, with the labels Eng, Hin, Maths, Sci, IP. Then display the values that are more than 60.

Answer
import pandas as pd
Stock = pd.Series([70, 60, 75, 20, 15], index=['Eng', 'Hin', 'Maths', 'Sci', 'IP'])
print(Stock[Stock > 60])

Output:

Eng      70
Maths    75
dtype: int64
B1.38Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series([70, 60, 75, 20], index=['Eng', 'Hin', 'Maths', 'Sci'])
print(S.tail(2))
print(S['Eng'])
Answer

Output:

Maths    75
Sci      20
dtype: int64
70
B1.39Practice2 marks

Write a Python program to create a Series Rain that stores the rainfall (in mm) of five months as 240, 300, 170, 20, 190, with the labels Jun, Jul, Aug, Sep, Oct. Then display the values that are more than 190.

Answer
import pandas as pd
Rain = pd.Series([240, 300, 170, 20, 190], index=['Jun', 'Jul', 'Aug', 'Sep', 'Oct'])
print(Rain[Rain > 190])

Output:

Jun    240
Jul    300
dtype: int64
B1.40Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series({'Jun': 240, 'Jul': 300, 'Aug': 170, 'Sep': 20})
print(S * 2)
Answer

Output:

Jun    480
Jul    600
Aug    340
Sep     40
dtype: int64
B1.41Practice2 marks

Write a Python program to create a Series Fee that stores the monthly fee of five hobby classes as 600, 1200, 1400, 900, 1000, with the labels Yoga, Dance, Music, Art, Chess. Then display the values that are more than 1000.

Answer
import pandas as pd
Fee = pd.Series([600, 1200, 1400, 900, 1000], index=['Yoga', 'Dance', 'Music', 'Art', 'Chess'])
print(Fee[Fee > 1000])

Output:

Dance    1200
Music    1400
dtype: int64
B1.42Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series([600, 1200, 1400, 900], index=['Yoga', 'Dance', 'Music', 'Art'])
print(S[1:3])
print(S.max())
Answer

Output:

Dance    1200
Music    1400
dtype: int64
1400
B1.43Practice2 marks

Write a Python program to create a Series Units that stores the electricity units used by five flats as 160, 130, 320, 250, 200, with the labels F1, F2, F3, F4, F5. Then display the values that are more than 200.

Answer
import pandas as pd
Units = pd.Series([160, 130, 320, 250, 200], index=['F1', 'F2', 'F3', 'F4', 'F5'])
print(Units[Units > 200])

Output:

F3    320
F4    250
dtype: int64
B1.44Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series({'F1': 160, 'F2': 130, 'F3': 320, 'F4': 250})
print(S.head(2))
print(S.size)
Answer

Output:

F1    160
F2    130
dtype: int64
4
B1.45Practice2 marks

Write a Python program to create a Series Score that stores the quiz scores of five teams as 26, 24, 38, 44, 12, with the labels Red, Blue, Green, Gold, Pink. Then display the values that are more than 26.

Answer
import pandas as pd
Score = pd.Series([26, 24, 38, 44, 12], index=['Red', 'Blue', 'Green', 'Gold', 'Pink'])
print(Score[Score > 26])

Output:

Green    38
Gold     44
dtype: int64
B1.46Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series([26, 24, 38, 44], index=['Red', 'Blue', 'Green', 'Gold'])
print(S.tail(2))
print(S['Red'])
Answer

Output:

Green    38
Gold     44
dtype: int64
26
B1.47Practice2 marks

Write a Python program to create a Series Wages that stores the daily wages of five workers as 600, 750, 450, 900, 650, with the labels Anil, Bela, Chand, Devi, Esha. Then display the values that are more than 650.

Answer
import pandas as pd
Wages = pd.Series([600, 750, 450, 900, 650], index=['Anil', 'Bela', 'Chand', 'Devi', 'Esha'])
print(Wages[Wages > 650])

Output:

Bela    750
Devi    900
dtype: int64
B1.48Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series({'Anil': 600, 'Bela': 750, 'Chand': 450, 'Devi': 900})
print(S * 2)
Answer

Output:

Anil     1200
Bela     1500
Chand     900
Devi     1800
dtype: int64
B1.49Practice2 marks

Write a Python program to create a Series Likes that stores the likes on five posts as 80, 115, 170, 75, 140, with the labels P1, P2, P3, P4, P5. Then display the values that are more than 115.

Answer
import pandas as pd
Likes = pd.Series([80, 115, 170, 75, 140], index=['P1', 'P2', 'P3', 'P4', 'P5'])
print(Likes[Likes > 115])

Output:

P3    170
P5    140
dtype: int64
B1.50Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series([80, 115, 170, 75], index=['P1', 'P2', 'P3', 'P4'])
print(S[1:3])
print(S.max())
Answer

Output:

P2    115
P3    170
dtype: int64
170
B1.51Practice2 marks

Write a Python program to create a Series Steps that stores the steps (in hundreds) walked on five days as 95, 110, 65, 90, 85, with the labels Mon, Tue, Wed, Thu, Fri. Then display the values that are more than 90.

Answer
import pandas as pd
Steps = pd.Series([95, 110, 65, 90, 85], index=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
print(Steps[Steps > 90])

Output:

Mon     95
Tue    110
dtype: int64
B1.52Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series({'Mon': 95, 'Tue': 110, 'Wed': 65, 'Thu': 90})
print(S.head(2))
print(S.size)
Answer

Output:

Mon     95
Tue    110
dtype: int64
4
B1.53Practice2 marks

Write a Python program to create a Series Seats that stores the seats in five halls as 40, 240, 260, 120, 300, with the labels H1, H2, H3, H4, H5. Then display the values that are more than 240.

Answer
import pandas as pd
Seats = pd.Series([40, 240, 260, 120, 300], index=['H1', 'H2', 'H3', 'H4', 'H5'])
print(Seats[Seats > 240])

Output:

H3    260
H5    300
dtype: int64
B1.54Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series([40, 240, 260, 120], index=['H1', 'H2', 'H3', 'H4'])
print(S.tail(2))
print(S['H1'])
Answer

Output:

H3    260
H4    120
dtype: int64
40
B1.55Practice2 marks

Write a Python program to create a Series Weight that stores the weight (in kg) of five parcels as 17, 38, 8, 23, 5, with the labels A, B, C, D, E. Then display the values that are more than 17.

Answer
import pandas as pd
Weight = pd.Series([17, 38, 8, 23, 5], index=['A', 'B', 'C', 'D', 'E'])
print(Weight[Weight > 17])

Output:

B    38
D    23
dtype: int64
B1.56Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series({'A': 17, 'B': 38, 'C': 8, 'D': 23})
print(S * 2)
Answer

Output:

A    34
B    76
C    16
D    46
dtype: int64
B1.57Practice2 marks

Write a Python program to create a Series Visits that stores the visitors of a museum on five days as 275, 200, 125, 450, 175, with the labels Mon, Tue, Wed, Thu, Fri. Then display the values that are more than 200.

Answer
import pandas as pd
Visits = pd.Series([275, 200, 125, 450, 175], index=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
print(Visits[Visits > 200])

Output:

Mon    275
Thu    450
dtype: int64
B1.58Practice2 marks

Write the output of the following code.

import pandas as pd
S = pd.Series([275, 200, 125, 450], index=['Mon', 'Tue', 'Wed', 'Thu'])
print(S[1:3])
print(S.max())
Answer

Output:

Tue    200
Wed    125
dtype: int64
450
B1.59Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has Item 'Pen', Price 260 and Qty 55. The second has Item 'Notebook' and Price 150 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'Item': 'Pen', 'Price': 260, 'Qty': 55},
     {'Item': 'Notebook', 'Price': 150}]
df = pd.DataFrame(L)
print(df)

Output:

       Item  Price   Qty
0       Pen    260  55.0
1  Notebook    150   NaN

The second dictionary has no key Qty, so NaN is shown there. The column becomes float.

B1.60Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Maths
  2. Display the rows where Eng is more than 63.

DataFrame: df

NameEngMaths
R1Asha8560
R2Ravi6361
R3Tina6773
R4Om6063
Answer
(i)
print(df['Maths'])

Output:

R1    60
R2    61
R3    73
R4    63
Name: Maths, dtype: int64
(ii)
print(df[df['Eng'] > 63])

Output:

    Name  Eng  Maths
R1  Asha   85     60
R3  Tina   67     73
B1.61Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has Player 'Rohit', Fours 36 and Sixes 2. The second has Player 'Virat' and Fours 27 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'Player': 'Rohit', 'Fours': 36, 'Sixes': 2},
     {'Player': 'Virat', 'Fours': 27}]
df = pd.DataFrame(L)
print(df)

Output:

  Player  Fours  Sixes
0  Rohit     36    2.0
1  Virat     27    NaN

The second dictionary has no key Sixes, so NaN is shown there. The column becomes float.

B1.62Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Expense
  2. Display the rows where Income is more than 85.

DataFrame: df

ShopIncomeExpense
S1Alpha8540
S2Bharat8025
S3City11545
S4Deluxe9020
Answer
(i)
print(df['Expense'])

Output:

S1    40
S2    25
S3    45
S4    20
Name: Expense, dtype: int64
(ii)
print(df[df['Income'] > 85])

Output:

      Shop  Income  Expense
S3    City     115       45
S4  Deluxe      90       20
B1.63Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has Class 'IX', Boys 29 and Girls 18. The second has Class 'X' and Boys 28 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'Class': 'IX', 'Boys': 29, 'Girls': 18},
     {'Class': 'X', 'Boys': 28}]
df = pd.DataFrame(L)
print(df)

Output:

  Class  Boys  Girls
0    IX    29   18.0
1     X    28    NaN

The second dictionary has no key Girls, so NaN is shown there. The column becomes float.

B1.64Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Available
  2. Display the rows where Issued is more than 30.

DataFrame: df

SubjectIssuedAvailable
B1English2095
B2Hindi3065
B3Maths75105
B4Science70110
Answer
(i)
print(df['Available'])

Output:

B1     95
B2     65
B3    105
B4    110
Name: Available, dtype: int64
(ii)
print(df[df['Issued'] > 30])

Output:

    Subject  Issued  Available
B3    Maths      75        105
B4  Science      70        110
B1.65Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has RoomType 'Single', Rent 3800 and Days 3. The second has RoomType 'Double' and Rent 2400 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'RoomType': 'Single', 'Rent': 3800, 'Days': 3},
     {'RoomType': 'Double', 'Rent': 2400}]
df = pd.DataFrame(L)
print(df)

Output:

  RoomType  Rent  Days
0   Single  3800   3.0
1   Double  2400   NaN

The second dictionary has no key Days, so NaN is shown there. The column becomes float.

B1.66Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Rice
  2. Display the rows where Wheat is more than 55.

DataFrame: df

VillageWheatRice
V1Rampur5565
V2Sonpur6530
V3Lalganj8550
V4Nayagaon3040
Answer
(i)
print(df['Rice'])

Output:

V1    65
V2    30
V3    50
V4    40
Name: Rice, dtype: int64
(ii)
print(df[df['Wheat'] > 55])

Output:

    Village  Wheat  Rice
V2   Sonpur     65    30
V3  Lalganj     85    50
B1.67Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has House 'Shivaji', Gold 9 and Silver 3. The second has House 'Tagore' and Gold 11 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'House': 'Shivaji', 'Gold': 9, 'Silver': 3},
     {'House': 'Tagore', 'Gold': 11}]
df = pd.DataFrame(L)
print(df)

Output:

     House  Gold  Silver
0  Shivaji     9     3.0
1   Tagore    11     NaN

The second dictionary has no key Silver, so NaN is shown there. The column becomes float.

B1.68Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Qtr2
  2. Display the rows where Qtr1 is more than 36.

DataFrame: df

NameQtr1Qtr2
S1Kabir5456
S2Meera5820
S3Nitin3618
S4Pooja2248
Answer
(i)
print(df['Qtr2'])

Output:

S1    56
S2    20
S3    18
S4    48
Name: Qtr2, dtype: int64
(ii)
print(df[df['Qtr1'] > 36])

Output:

     Name  Qtr1  Qtr2
S1  Kabir    54    56
S2  Meera    58    20
B1.69Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has Vehicle 'Car', Litres 55 and Rate 92. The second has Vehicle 'Bike' and Litres 45 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'Vehicle': 'Car', 'Litres': 55, 'Rate': 92},
     {'Vehicle': 'Bike', 'Litres': 45}]
df = pd.DataFrame(L)
print(df)

Output:

  Vehicle  Litres  Rate
0     Car      55  92.0
1    Bike      45   NaN

The second dictionary has no key Rate, so NaN is shown there. The column becomes float.

B1.70Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Practical
  2. Display the rows where Theory is more than 32.

DataFrame: df

NameTheoryPractical
E1Ishaan3125
E2Jaya5429
E3Kunal3221
E4Lata3422
Answer
(i)
print(df['Practical'])

Output:

E1    25
E2    29
E3    21
E4    22
Name: Practical, dtype: int64
(ii)
print(df[df['Theory'] > 32])

Output:

    Name  Theory  Practical
E2  Jaya      54         29
E4  Lata      34         22
B1.71Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has Name 'Gopal', Basic 20000 and Bonus 3500. The second has Name 'Hema' and Basic 48000 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'Name': 'Gopal', 'Basic': 20000, 'Bonus': 3500},
     {'Name': 'Hema', 'Basic': 48000}]
df = pd.DataFrame(L)
print(df)

Output:

    Name  Basic   Bonus
0  Gopal  20000  3500.0
1   Hema  48000     NaN

The second dictionary has no key Bonus, so NaN is shown there. The column becomes float.

B1.72Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Price
  2. Display the rows where Tickets is more than 60.

DataFrame: df

ShowTicketsPrice
T1Morning40250
T2Noon100200
T3Evening60150
T4Night130300
Answer
(i)
print(df['Price'])

Output:

T1    250
T2    200
T3    150
T4    300
Name: Price, dtype: int64
(ii)
print(df[df['Tickets'] > 60])

Output:

     Show  Tickets  Price
T2   Noon      100    200
T4  Night      130    300
B1.73Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has City 'Delhi', MaxTemp 39 and MinTemp 18. The second has City 'Shimla' and MaxTemp 31 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'City': 'Delhi', 'MaxTemp': 39, 'MinTemp': 18},
     {'City': 'Shimla', 'MaxTemp': 31}]
df = pd.DataFrame(L)
print(df)

Output:

     City  MaxTemp  MinTemp
0   Delhi       39     18.0
1  Shimla       31      NaN

The second dictionary has no key MinTemp, so NaN is shown there. The column becomes float.

B1.74Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Sold
  2. Display the rows where Price is more than 30.

DataFrame: df

ItemPriceSold
C1Samosa20140
C2Tea3020
C3Juice5590
C4Sandwich6060
Answer
(i)
print(df['Sold'])

Output:

C1    140
C2     20
C3     90
C4     60
Name: Sold, dtype: int64
(ii)
print(df[df['Price'] > 30])

Output:

        Item  Price  Sold
C3     Juice     55    90
C4  Sandwich     60    60
B1.75Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has Dept 'Sports', Allotted 190 and Spent 20. The second has Dept 'Library' and Allotted 170 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'Dept': 'Sports', 'Allotted': 190, 'Spent': 20},
     {'Dept': 'Library', 'Allotted': 170}]
df = pd.DataFrame(L)
print(df)

Output:

      Dept  Allotted  Spent
0   Sports       190   20.0
1  Library       170    NaN

The second dictionary has no key Spent, so NaN is shown there. The column becomes float.

B1.76Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Units
  2. Display the rows where Rate is more than 1500.

DataFrame: df

ProductRateUnits
O1Mouse160017
O2Keyboard240011
O3Webcam150018
O4Speaker9006
Answer
(i)
print(df['Units'])

Output:

O1    17
O2    11
O3    18
O4     6
Name: Units, dtype: int64
(ii)
print(df[df['Rate'] > 1500])

Output:

     Product  Rate  Units
O1     Mouse  1600     17
O2  Keyboard  2400     11
B1.77Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has Class 'VI', Students 31 and Teachers 5. The second has Class 'VII' and Students 36 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'Class': 'VI', 'Students': 31, 'Teachers': 5},
     {'Class': 'VII', 'Students': 36}]
df = pd.DataFrame(L)
print(df)

Output:

  Class  Students  Teachers
0    VI        31       5.0
1   VII        36       NaN

The second dictionary has no key Teachers, so NaN is shown there. The column becomes float.

B1.78Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Shrubs
  2. Display the rows where Trees is more than 70.

DataFrame: df

GardenTreesShrubs
G1Rose11070
G2Lotus90120
G3Lily20100
G4Tulip70190
Answer
(i)
print(df['Shrubs'])

Output:

G1     70
G2    120
G3    100
G4    190
Name: Shrubs, dtype: int64
(ii)
print(df[df['Trees'] > 70])

Output:

   Garden  Trees  Shrubs
G1   Rose    110      70
G2  Lotus     90     120
B1.79Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has Customer 'Farah', Deposit 60 and Withdraw 45. The second has Customer 'Girish' and Deposit 180 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'Customer': 'Farah', 'Deposit': 60, 'Withdraw': 45},
     {'Customer': 'Girish', 'Deposit': 180}]
df = pd.DataFrame(L)
print(df)

Output:

  Customer  Deposit  Withdraw
0    Farah       60      45.0
1   Girish      180       NaN

The second dictionary has no key Withdraw, so NaN is shown there. The column becomes float.

B1.80Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Round2
  2. Display the rows where Round1 is more than 32.

DataFrame: df

GamerRound1Round2
G1Neo3242
G2Rex2065
G3Sky5932
G4Max5261
Answer
(i)
print(df['Round2'])

Output:

G1    42
G2    65
G3    32
G4    61
Name: Round2, dtype: int64
(ii)
print(df[df['Round1'] > 32])

Output:

   Gamer  Round1  Round2
G3   Sky      59      32
G4   Max      52      61
B1.81Practice2 marks

Write a Python program to create a DataFrame df from a list of two dictionaries. The first dictionary has Model 'Astra', Price 10000 and Stock 4. The second has Model 'Bolt' and Price 15000 only. Display the DataFrame. What is shown for the missing value?

Answer
import pandas as pd
L = [{'Model': 'Astra', 'Price': 10000, 'Stock': 4},
     {'Model': 'Bolt', 'Price': 15000}]
df = pd.DataFrame(L)
print(df)

Output:

   Model  Price  Stock
0  Astra  10000    4.0
1   Bolt  15000    NaN

The second dictionary has no key Stock, so NaN is shown there. The column becomes float.

B1.82Practice2 marks

Consider the DataFrame df given below. Write statements to:

  1. Display only the column Round2
  2. Display the rows where Round1 is more than 25.

DataFrame: df

TeamRound1Round2
Q1Alpha3050
Q2Beta4010
Q3Gamma1525
Q4Delta2535
Answer
(i)
print(df['Round2'])

Output:

Q1    50
Q2    10
Q3    25
Q4    35
Name: Round2, dtype: int64
(ii)
print(df[df['Round1'] > 25])

Output:

     Team  Round1  Round2
Q1  Alpha      30      50
Q2   Beta      40      10
B1.83Practice2 marks

Write a statement to create a Series S in which the value 10 is stored against each of the labels 'a', 'b' and 'c'. Write its output.

Answer
import pandas as pd
S = pd.Series(10, index=['a', 'b', 'c'])
print(S)

Output:

a    10
b    10
c    10
dtype: int64
B1.84Practice2 marks

Write a program to create a Series S from the NumPy array made by np.arange(10, 50, 10). Write its output.

Answer
import pandas as pd
import numpy as np
S = pd.Series(np.arange(10, 50, 10))
print(S)

Output:

0    10
1    20
2    30
3    40
dtype: int64
B1.85Practice2 marks

Write a program to create a Series of the first five even numbers with the labels 'a' to 'e', and display its last two elements.

Answer
import pandas as pd
S = pd.Series([2, 4, 6, 8, 10], index=['a', 'b', 'c', 'd', 'e'])
print(S.tail(2))

Output:

d     8
e    10
dtype: int64
B1.86Practice2 marks

Write a program to create a Series Cap from the dictionary {'Delhi': 'New Delhi', 'UP': 'Lucknow', 'Bihar': 'Patna'} and display its index.

Answer
import pandas as pd
Cap = pd.Series({'Delhi': 'New Delhi', 'UP': 'Lucknow', 'Bihar': 'Patna'})
print(Cap.index)

Output:

Index(['Delhi', 'UP', 'Bihar'], dtype='object')
B1.87Practice2 marks

Write a program to create an empty DataFrame df and then add a column 'Roll' with the values 1, 2, 3. Display it.

Answer
import pandas as pd
df = pd.DataFrame()
df['Roll'] = [1, 2, 3]
print(df)

Output:

   Roll
0     1
1     2
2     3
B1.88Practice2 marks

A Series S has the values 5, 10, 15, 20 with the default index. Write statements to:

  1. Change the index to 'p', 'q', 'r', 's'
  2. Display the element with the label 'r'.
Answer
import pandas as pd
S = pd.Series([5, 10, 15, 20])
S.index = ['p', 'q', 'r', 's']
print(S['r'])

Output:

15
B1.89Practice2 marks

Write a program to create a Series T of the multiples of 3 from 3 to 15, and display the elements at positions 1 to 3.

Answer
import pandas as pd
T = pd.Series([3, 6, 9, 12, 15])
print(T[1:4])

Output:

1     6
2     9
3    12
dtype: int64
B1.90Practice2 marks

Write a program to create a Series Sq that stores the squares of the numbers 1 to 5, with the numbers as labels. Display it.

Answer
import pandas as pd
Sq = pd.Series([1, 4, 9, 16, 25], index=[1, 2, 3, 4, 5])
print(Sq)

Output:

1     1
2     4
3     9
4    16
5    25
dtype: int64
B1.91Practice2 marks

The DataFrame df is given below. Write a statement to save it in the file stock.csv without the row labels. Show what the file will contain.

DataFrame: df

ItemPriceQty
S1Pen26055
S2Notebook15035
S3Bag17020
Answer
df.to_csv('stock.csv', index=False)

Contents of stock.csv:

Item,Price,Qty
Pen,260,55
Notebook,150,35
Bag,170,20
B1.92Practice2 marks

The file stock.csv has the lines given below. Write a program to read it into a DataFrame df and display the DataFrame and its shape.

File: stock.csv

Item,Price,Qty
Pen,260,55
Notebook,150,35
Bag,170,20
Answer
import pandas as pd
df = pd.read_csv('stock.csv')
print(df)
print(df.shape)

Output:

       Item  Price  Qty
0       Pen    260   55
1  Notebook    150   35
2       Bag    170   20
(3, 3)
B1.93Practice2 marks

The DataFrame df is given below. Write a statement to save it in the file shop.csv without the row labels. Show what the file will contain.

DataFrame: df

ShopIncomeExpense
S1Alpha8540
S2Bharat8025
S3City11545
Answer
df.to_csv('shop.csv', index=False)

Contents of shop.csv:

Shop,Income,Expense
Alpha,85,40
Bharat,80,25
City,115,45
B1.94Practice2 marks

The file shop.csv has the lines given below. Write a program to read it into a DataFrame df and display the DataFrame and its shape.

File: shop.csv

Shop,Income,Expense
Alpha,85,40
Bharat,80,25
City,115,45
Answer
import pandas as pd
df = pd.read_csv('shop.csv')
print(df)
print(df.shape)

Output:

     Shop  Income  Expense
0   Alpha      85       40
1  Bharat      80       25
2    City     115       45
(3, 3)
B1.95Practice2 marks

The DataFrame df is given below. Write a statement to save it in the file hotel.csv without the row labels. Show what the file will contain.

DataFrame: df

RoomTypeRentDays
H1Single38003
H2Double24002
H3Deluxe20005
Answer
df.to_csv('hotel.csv', index=False)

Contents of hotel.csv:

RoomType,Rent,Days
Single,3800,3
Double,2400,2
Deluxe,2000,5
B1.96Practice2 marks

The file hotel.csv has the lines given below. Write a program to read it into a DataFrame df and display the DataFrame and its shape.

File: hotel.csv

RoomType,Rent,Days
Single,3800,3
Double,2400,2
Deluxe,2000,5
Answer
import pandas as pd
df = pd.read_csv('hotel.csv')
print(df)
print(df.shape)

Output:

  RoomType  Rent  Days
0   Single  3800     3
1   Double  2400     2
2   Deluxe  2000     5
(3, 3)
B1.97Practice2 marks

The DataFrame df is given below. Write a statement to save it in the file sales.csv without the row labels. Show what the file will contain.

DataFrame: df

NameQtr1Qtr2
S1Kabir5456
S2Meera5820
S3Nitin3618
Answer
df.to_csv('sales.csv', index=False)

Contents of sales.csv:

Name,Qtr1,Qtr2
Kabir,54,56
Meera,58,20
Nitin,36,18
B1.98Practice2 marks

The file sales.csv has the lines given below. Write a program to read it into a DataFrame df and display the DataFrame and its shape.

File: sales.csv

Name,Qtr1,Qtr2
Kabir,54,56
Meera,58,20
Nitin,36,18
Answer
import pandas as pd
df = pd.read_csv('sales.csv')
print(df)
print(df.shape)

Output:

    Name  Qtr1  Qtr2
0  Kabir    54    56
1  Meera    58    20
2  Nitin    36    18
(3, 3)
B1.99Practice2 marks

The DataFrame df is given below. Write a statement to save it in the file emp.csv without the row labels. Show what the file will contain.

DataFrame: df

NameBasicBonus
E1Gopal200003500
E2Hema480005500
E3Irfan280004000
Answer
df.to_csv('emp.csv', index=False)

Contents of emp.csv:

Name,Basic,Bonus
Gopal,20000,3500
Hema,48000,5500
Irfan,28000,4000
B1.100Practice2 marks

The file emp.csv has the lines given below. Write a program to read it into a DataFrame df and display the DataFrame and its shape.

File: emp.csv

Name,Basic,Bonus
Gopal,20000,3500
Hema,48000,5500
Irfan,28000,4000
Answer
import pandas as pd
df = pd.read_csv('emp.csv')
print(df)
print(df.shape)

Output:

    Name  Basic  Bonus
0  Gopal  20000   3500
1   Hema  48000   5500
2  Irfan  28000   4000
(3, 3)
B1.101Practice2 marks

The DataFrame df is given below. Write a statement to save it in the file canteen.csv without the row labels. Show what the file will contain.

DataFrame: df

ItemPriceSold
C1Samosa20140
C2Tea3020
C3Juice5590
Answer
df.to_csv('canteen.csv', index=False)

Contents of canteen.csv:

Item,Price,Sold
Samosa,20,140
Tea,30,20
Juice,55,90
B1.102Practice2 marks

The file canteen.csv has the lines given below. Write a program to read it into a DataFrame df and display the DataFrame and its shape.

File: canteen.csv

Item,Price,Sold
Samosa,20,140
Tea,30,20
Juice,55,90
Answer
import pandas as pd
df = pd.read_csv('canteen.csv')
print(df)
print(df.shape)

Output:

     Item  Price  Sold
0  Samosa     20   140
1     Tea     30    20
2   Juice     55    90
(3, 3)
B1.103Practice2 marks

The DataFrame df is given below. Write a statement to save it in the file trip.csv without the row labels. Show what the file will contain.

DataFrame: df

ClassStudentsTeachers
T1VI315
T2VII363
T3VIII284
Answer
df.to_csv('trip.csv', index=False)

Contents of trip.csv:

Class,Students,Teachers
VI,31,5
VII,36,3
VIII,28,4
B1.104Practice2 marks

The file trip.csv has the lines given below. Write a program to read it into a DataFrame df and display the DataFrame and its shape.

File: trip.csv

Class,Students,Teachers
VI,31,5
VII,36,3
VIII,28,4
Answer
import pandas as pd
df = pd.read_csv('trip.csv')
print(df)
print(df.shape)

Output:

  Class  Students  Teachers
0    VI        31         5
1   VII        36         3
2  VIII        28         4
(3, 3)
B1.105Practice2 marks

The DataFrame df is given below. Write a statement to save it in the file game.csv without the row labels. Show what the file will contain.

DataFrame: df

GamerRound1Round2
G1Neo3242
G2Rex2065
G3Sky5932
Answer
df.to_csv('game.csv', index=False)

Contents of game.csv:

Gamer,Round1,Round2
Neo,32,42
Rex,20,65
Sky,59,32
B1.106Practice2 marks

The file game.csv has the lines given below. Write a program to read it into a DataFrame df and display the DataFrame and its shape.

File: game.csv

Gamer,Round1,Round2
Neo,32,42
Rex,20,65
Sky,59,32
Answer
import pandas as pd
df = pd.read_csv('game.csv')
print(df)
print(df.shape)

Output:

  Gamer  Round1  Round2
0   Neo      32      42
1   Rex      20      65
2   Sky      59      32
(3, 3)
B2Data visualization short answers2 marks · 24 questions
B2.1SQP 2026-272 marks

What is data visualization? Write its purpose.

Answer

Data visualization is showing data in the form of pictures such as charts and graphs. It helps us to see patterns, trends, variations and relationships in the data quickly, which are hard to see in a table of numbers.

B2.2Practice2 marks

Write two differences between a bar chart and a histogram.

Answer

(1) A bar chart compares separate categories (such as products); a histogram shows how numeric values are spread over continuous intervals. (2) The bars of a bar chart have gaps; the bars of a histogram touch each other.

B2.3Practice2 marks

What is the use of plt.legend()? What must be written in plt.plot() for it to work?

Answer

legend() shows a small box that tells which line or bar stands for which data. Each plot() call must be given a name with the label parameter, for example plt.plot(x, y, label='Sales').

B2.4Practice2 marks

Write the difference between plt.show() and plt.savefig().

Answer

show() displays the chart on the screen. savefig('name.png') saves the chart as a picture file. In a program, savefig() is written before show().

B2.5Practice2 marks

Write the use of the functions title() and xlabel() of pyplot with one example each.

Answer

title() writes a heading on top of the chart. xlabel() writes a label below the X-axis.

plt.title('Monthly Sales')
plt.xlabel('Month')
B2.6Practice2 marks

What is a histogram? What is the use of the bins parameter?

Answer

A histogram shows the frequency distribution of numeric data: the range of values is cut into intervals and a bar shows how many values fall in each interval. bins gives the number of intervals, or the list of interval edges.

B2.7Practice2 marks

Name the chart you will choose in each case:

  1. Rainfall of a city in each month of a year, to see the trend
  2. Number of students in four houses of a school.
Answer

(i) Line chart, because it shows a change over time. (ii) Bar chart, because it compares separate categories.

B2.8Practice2 marks

Write the use of any two of these parameters of plt.plot(): color, linestyle, marker, linewidth.

Answer

color sets the colour of the line ('r', 'g', 'blue'). linestyle sets the kind of line ('-' solid, '--' dashed, ':' dotted). marker puts a symbol on every data point ('o', '*', 's'). linewidth sets the thickness of the line.

B2.9Practice2 marks

Write the statements to import the plotting module and to draw a line chart of the lists x and y.

Answer

pyplot is imported with the short name plt.

import matplotlib.pyplot as plt
plt.plot(x, y)
plt.show()

The chart this code draws (with sample values for x, y)

4060801234
B2.10Practice2 marks

Write the difference between plt.bar() and plt.barh().

Answer

bar(x, height) draws vertical bars: the categories are on the X-axis. barh(y, width) draws horizontal bars: the categories are on the Y-axis.

B2.11Practice2 marks

Why is a chart easier to understand than a table of numbers? Write two points.

Answer

(1) A chart shows the highest, the lowest and the trend at one look. (2) Large data can be compared quickly, and the picture is remembered for a longer time.

B2.12Practice2 marks

What will this code draw? plt.plot([1, 2, 3], [10, 20, 15], 'g--', marker='o')

Answer

A green dashed line that joins the points (1, 10), (2, 20) and (3, 15). A circle is shown on each of the three points.

The chart this code draws

10121416182011.522.53
B2.13Practice2 marks

Write statements to draw a bar chart of the list runs against the list players with red bars and the title 'Runs scored'.

Answer

The first list goes to the X-axis and the second list gives the heights.

plt.bar(players, runs, color='red')
plt.title('Runs scored')
plt.show()

The chart this code draws (with sample values for players, runs)

Runs scored020406080RohitViratGillPant
B2.14Practice2 marks

Write statements to draw a histogram of the list ages with 5 intervals and black borders on the bars.

Answer

bins sets the intervals and edgecolor sets the border colour.

plt.hist(ages, bins=5, edgecolor='black')
plt.show()

The chart this code draws (with sample values for ages)

012312131415161718
B2.15Practice2 marks

How can two lines be shown on the same chart with a legend? Write the statements.

Answer

Call plot() once for each line with a label, then call legend().

plt.plot(months, sales2026, label='2026')
plt.plot(months, sales2027, label='2027')
plt.legend()
plt.show()

The chart this code draws (with sample values for months, sales2026, sales2027)

406080JanFebMarApr20262027
B2.16Practice2 marks

What is the use of plt.grid(True) and plt.xticks()?

Answer

grid(True) draws light horizontal and vertical lines on the chart so that values can be read easily. xticks() sets the positions and the labels of the marks on the X-axis.

B2.17Practice2 marks

A student wrote plt.show() first and plt.savefig('a.png') after it. The saved picture was blank. Why? Write the correct order.

Answer

After show() the chart is cleared, so nothing is left to save. Write plt.savefig('a.png') first and plt.show() after it.

B2.18Practice2 marks

Write any four functions of pyplot that are used to decorate (customise) a chart.

Answer

title() for the heading, xlabel() and ylabel() for the axis labels, legend() for the key, grid() for grid lines. (Any four.)

B2.19Practice2 marks

Name the three kinds of plots in your syllabus and the pyplot function for each.

Answer

Line plot: plot(). Bar graph: bar() (or barh() for horizontal bars). Histogram: hist().

B2.20Practice2 marks

In a histogram of marks with bins=[0, 20, 40, 60, 80, 100], how many bars are drawn? In which bar does the value 40 fall?

Answer

Five bars, one for each interval. The value 40 falls in the third bar (40 to 60), because each interval includes its left edge. Only the last interval includes both edges.

B2.21Practice2 marks

Write the use of the width and color parameters of plt.bar().

Answer

width sets the thickness of the bars (the default is 0.8). color sets the colour of the bars; a list of colours gives a different colour to each bar.

B2.22Practice2 marks

A DataFrame df has the columns Year and Profit. Write statements to draw a line chart of Profit against Year.

Answer

The two columns are given to plot().

plt.plot(df['Year'], df['Profit'])
plt.show()

The chart this code draws (with sample values for df)

4050607020202021202220232024
B2.23Practice2 marks

What is the use of the marker and markersize parameters? Give one example.

Answer

marker puts a symbol on each data point and markersize sets how big the symbol is.

plt.plot(x, y, marker='*', markersize=10)

The chart this code draws (with sample values for x, y)

4060801234★★★★
B2.24Practice2 marks

Which chart will you use to show the heights of 200 students in the ranges 140-150, 150-160 and so on? Give a reason.

Answer

Histogram, because height is continuous numeric data and we want to see how many students fall in each range (frequency distribution).

B3SQL functions: query and output2 marks · 45 questions
B3.1SQP 2026-272 marks
  1. A table EMPLOYEE has a column Ename. Write an SQL query to display the last three characters of each Ename.
  2. Write the output of the query SELECT INSTR('Informatics', 'ma');
Answer
(i)
SELECT RIGHT(Ename, 3) FROM EMPLOYEE;
(ii)

6

B3.2Practice2 marks
  1. The table PATIENT has the columns PNo, PName, Dept, Days, Bill, DOA. Write an SQL query to display the last two characters of each PName.
  2. Write the output of the query SELECT MID('Education', 4, 3);
Answer
(i)
SELECT RIGHT(PName, 2) FROM PATIENT;
(ii)

cat

B3.3Practice2 marks
  1. The table EMPLOYEE has the columns ENo, EName, Dept, Salary, Bonus, DOJ. Write an SQL query to display the first three characters of each EName.
  2. Write the output of the query SELECT MOD(80, 3);
Answer
(i)
SELECT LEFT(EName, 3) FROM EMPLOYEE;
(ii)

2

B3.4Practice2 marks
  1. The table BOOK has the columns BNo, Title, Genre, Pages, Price, DOP. Write an SQL query to display the Title in capital letters.
  2. Write the output of the query SELECT UCASE(DAYNAME('2027-01-01'));
Answer
(i)
SELECT UCASE(Title) FROM BOOK;
(ii)

FRIDAY

B3.5Practice2 marks
  1. The table STUDENT has the columns RNo, SName, Stream, Marks, Fees, DOB. Write an SQL query to display each SName and the number of characters in it.
  2. Write the output of the query SELECT LEFT('Network', 5);
Answer
(i)
SELECT SName, LENGTH(SName) FROM STUDENT;
(ii)

Netwo

B3.6Practice2 marks
  1. The table PRODUCT has the columns PCode, PName, Company, Stock, Price, MfgDate. Write an SQL query to display each PName and the name of the month of MfgDate.
  2. Write the output of the query SELECT POWER(2, 2);
Answer
(i)
SELECT PName, MONTHNAME(MfgDate) FROM PRODUCT;
(ii)

4

B3.7Practice2 marks
  1. The table MEMBER has the columns MNo, MName, Plan, Months, Fee, JoinDate. Write an SQL query to display each MName and its Fee rounded to one decimal place.
  2. Write the output of the query SELECT ROUND(163.769, 1);
Answer
(i)
SELECT MName, ROUND(Fee, 1) FROM MEMBER;
(ii)

163.8

B3.8Practice2 marks
  1. The table TICKET has the columns TNo, Passenger, Dest, Seats, Fare, TravelDate. Write an SQL query to display three characters of each Passenger, starting from the second character.
  2. Write the output of the query SELECT LENGTH('Data Science');
Answer
(i)
SELECT MID(Passenger, 2, 3) FROM TICKET;
(ii)

12

B3.9Practice2 marks
  1. The table MOVIE has the columns MNo, Title, Genre, Minutes, Rating, RelDate. Write an SQL query to display each Title and the name of the week day of RelDate.
  2. Write the output of the query SELECT INSTR('Matplotlib', 'at');
Answer
(i)
SELECT Title, DAYNAME(RelDate) FROM MOVIE;
(ii)

2

B3.10Practice2 marks
  1. The table COURSE has the columns CNo, CName, Mode, Weeks, Fee, StartDate. Write an SQL query to display each CName and its Fee rounded to the nearest whole number.
  2. Write the output of the query SELECT DAYNAME('2024-07-03');
Answer
(i)
SELECT CName, ROUND(Fee) FROM COURSE;
(ii)

Wednesday

B3.11Practice2 marks
  1. The table VEHICLE has the columns VNo, Owner, Type, Km, Tax, RegDate. Write an SQL query to display each Owner and the year of RegDate.
  2. Write the output of the query SELECT LENGTH('Pandas') + INSTR('Pandas', 'n');
Answer
(i)
SELECT Owner, YEAR(RegDate) FROM VEHICLE;
(ii)

9

B3.12Practice2 marks
  1. The table ORDERS has the columns ONo, Customer, City, Qty, Amount, ODate. Write an SQL query to display each Customer and the position of the letter 'a' in it.
  2. Write the output of the query SELECT LENGTH(RTRIM(' Data Science '));
Answer
(i)
SELECT Customer, INSTR(Customer, 'a') FROM ORDERS;
(ii)

14

B3.13Practice2 marks
  1. The table DOCTOR has the columns DNo, DName, Spec, Exp, Fee, DOJ. Write an SQL query to display each DName and the remainder when Exp is divided by 7.
  2. Write the output of the query SELECT RIGHT('Matplotlib', 4);
Answer
(i)
SELECT DName, MOD(Exp, 7) FROM DOCTOR;
(ii)

tlib

B3.14Practice2 marks
  1. The table PLAYER has the columns PNo, PName, Game, Matches, Average, DOB. Write an SQL query to display the last two characters of each PName.
  2. Write the output of the query SELECT SUBSTRING('Programming', 3, 3);
Answer
(i)
SELECT RIGHT(PName, 2) FROM PLAYER;
(ii)

ogr

B3.15Practice2 marks
  1. The table HOSTEL has the columns HNo, SName, Block, Room, Mess, DOA. Write an SQL query to display the first three characters of each SName.
  2. Write the output of the query SELECT MOD(92, 8);
Answer
(i)
SELECT LEFT(SName, 3) FROM HOSTEL;
(ii)

4

B3.16Practice2 marks
  1. The table LOAN has the columns LNo, CName, Type, Years, Rate, StartDate. Write an SQL query to display the CName in capital letters.
  2. Write the output of the query SELECT UCASE(DAYNAME('2025-11-11'));
Answer
(i)
SELECT UCASE(CName) FROM LOAN;
(ii)

TUESDAY

B3.17Practice2 marks
  1. The table STAFF has the columns SNo, SName, Post, Periods, Allowance, DOJ. Write an SQL query to display each SName and the number of characters in it.
  2. Write the output of the query SELECT LEFT('Cyber Safety', 6);
Answer
(i)
SELECT SName, LENGTH(SName) FROM STAFF;
(ii)

Cyber

B3.18Practice2 marks
  1. The table GARMENT has the columns GCode, GName, Fabric, Stock, Price, Launch. Write an SQL query to display each GName and the name of the month of Launch.
  2. Write the output of the query SELECT POWER(7, 2);
Answer
(i)
SELECT GName, MONTHNAME(Launch) FROM GARMENT;
(ii)

49

B3.19Practice2 marks
  1. The table EVENT has the columns ENo, EName, House, Points, Prize, EDate. Write an SQL query to display each EName and its Prize rounded to one decimal place.
  2. Write the output of the query SELECT ROUND(463.804, 1);
Answer
(i)
SELECT EName, ROUND(Prize, 1) FROM EVENT;
(ii)

463.8

B3.20Practice2 marks
  1. The table TRAIN has the columns TNo, TName, Zone, Coaches, Fare, StartDate. Write an SQL query to display three characters of each TName, starting from the second character.
  2. Write the output of the query SELECT LENGTH('Kendriya');
Answer
(i)
SELECT MID(TName, 2, 3) FROM TRAIN;
(ii)

8

B3.21Practice2 marks
  1. The table LAPTOP has the columns LNo, Model, Brand, RAM, Price, Launch. Write an SQL query to display each Model and the name of the week day of Launch.
  2. Write the output of the query SELECT INSTR('Internet', 'rn');
Answer
(i)
SELECT Model, DAYNAME(Launch) FROM LAPTOP;
(ii)

5

B3.22Practice2 marks
  1. The table CLUB has the columns CNo, MName, Activity, Age, Fee, DOJ. Write an SQL query to display each MName and its Fee rounded to the nearest whole number.
  2. Write the output of the query SELECT MONTHNAME('2025-03-17');
Answer
(i)
SELECT MName, ROUND(Fee) FROM CLUB;
(ii)

March

B3.23Practice2 marks
  1. The table FARM has the columns FNo, Farmer, Crop, Acres, Yield, SowDate. Write an SQL query to display each Farmer and the year of SowDate.
  2. Write the output of the query SELECT UPPER(RIGHT('Digital India', 3));
Answer
(i)
SELECT Farmer, YEAR(SowDate) FROM FARM;
(ii)

DIA

B3.24Practice2 marks
  1. The table PATIENT has the columns PNo, PName, Dept, Days, Bill, DOA. Write an SQL query to display each PName and the position of the letter 'a' in it.
  2. Write the output of the query SELECT LENGTH(TRIM(' Sample Paper '));
Answer
(i)
SELECT PName, INSTR(PName, 'a') FROM PATIENT;
(ii)

12

B3.25Practice2 marks
  1. The table EMPLOYEE has the columns ENo, EName, Dept, Salary, Bonus, DOJ. Write an SQL query to display each EName and the remainder when Salary is divided by 7.
  2. Write the output of the query SELECT RIGHT('Data Science', 3);
Answer
(i)
SELECT EName, MOD(Salary, 7) FROM EMPLOYEE;
(ii)

nce

B3.26Practice2 marks
  1. The table BOOK has the columns BNo, Title, Genre, Pages, Price, DOP. Write an SQL query to display the last two characters of each Title.
  2. Write the output of the query SELECT SUBSTRING('Pandas', 2, 4);
Answer
(i)
SELECT RIGHT(Title, 2) FROM BOOK;
(ii)

anda

B3.27Practice2 marks
  1. The table STUDENT has the columns RNo, SName, Stream, Marks, Fees, DOB. Write an SQL query to display the first three characters of each SName.
  2. Write the output of the query SELECT MOD(91, 5);
Answer
(i)
SELECT LEFT(SName, 3) FROM STUDENT;
(ii)

1

B3.28Practice2 marks
  1. The table PRODUCT has the columns PCode, PName, Company, Stock, Price, MfgDate. Write an SQL query to display the PName in capital letters.
  2. Write the output of the query SELECT DAY('2025-03-12') + MONTH('2025-03-12');
Answer
(i)
SELECT UCASE(PName) FROM PRODUCT;
(ii)

15

B3.29Practice2 marks
  1. The table MEMBER has the columns MNo, MName, Plan, Months, Fee, JoinDate. Write an SQL query to display each MName and the number of characters in it.
  2. Write the output of the query SELECT LEFT('Open Source', 9);
Answer
(i)
SELECT MName, LENGTH(MName) FROM MEMBER;
(ii)

Open Sour

B3.30Practice2 marks
  1. The table TICKET has the columns TNo, Passenger, Dest, Seats, Fare, TravelDate. Write an SQL query to display each Passenger and the name of the month of TravelDate.
  2. Write the output of the query SELECT POWER(6, 2);
Answer
(i)
SELECT Passenger, MONTHNAME(TravelDate) FROM TICKET;
(ii)

36

B3.31Practice2 marks
  1. The table MOVIE has the columns MNo, Title, Genre, Minutes, Rating, RelDate. Write an SQL query to display each Title and its Rating rounded to one decimal place.
  2. Write the output of the query SELECT ROUND(94.711, 2);
Answer
(i)
SELECT Title, ROUND(Rating, 1) FROM MOVIE;
(ii)

94.71

B3.32Practice2 marks
  1. The table COURSE has the columns CNo, CName, Mode, Weeks, Fee, StartDate. Write an SQL query to display three characters of each CName, starting from the second character.
  2. Write the output of the query SELECT LENGTH('Cyber Safety');
Answer
(i)
SELECT MID(CName, 2, 3) FROM COURSE;
(ii)

12

B3.33Practice2 marks
  1. The table VEHICLE has the columns VNo, Owner, Type, Km, Tax, RegDate. Write an SQL query to display each Owner and the name of the week day of RegDate.
  2. Write the output of the query SELECT INSTR('Kendriya', 'i');
Answer
(i)
SELECT Owner, DAYNAME(RegDate) FROM VEHICLE;
(ii)

6

B3.34Practice2 marks
  1. The table ORDERS has the columns ONo, Customer, City, Qty, Amount, ODate. Write an SQL query to display each Customer and its Amount rounded to the nearest whole number.
  2. Write the output of the query SELECT MONTH('2027-04-18');
Answer
(i)
SELECT Customer, ROUND(Amount) FROM ORDERS;
(ii)

4

B3.35Practice2 marks
  1. The table DOCTOR has the columns DNo, DName, Spec, Exp, Fee, DOJ. Write an SQL query to display each DName and the year of DOJ.
  2. Write the output of the query SELECT LCASE(LEFT('Programming', 5));
Answer
(i)
SELECT DName, YEAR(DOJ) FROM DOCTOR;
(ii)

progr

B3.36Practice2 marks
  1. The table PLAYER has the columns PNo, PName, Game, Matches, Average, DOB. Write an SQL query to display each PName and the position of the letter 'a' in it.
  2. Write the output of the query SELECT LENGTH(RTRIM(' Digital India '));
Answer
(i)
SELECT PName, INSTR(PName, 'a') FROM PLAYER;
(ii)

14

B3.37Practice2 marks
  1. The table HOSTEL has the columns HNo, SName, Block, Room, Mess, DOA. Write an SQL query to display each SName and the remainder when Room is divided by 7.
  2. Write the output of the query SELECT RIGHT('Network', 2);
Answer
(i)
SELECT SName, MOD(Room, 7) FROM HOSTEL;
(ii)

rk

B3.38Practice2 marks
  1. The table LOAN has the columns LNo, CName, Type, Years, Rate, StartDate. Write an SQL query to display the last two characters of each CName.
  2. Write the output of the query SELECT MID('Network', 3, 4);
Answer
(i)
SELECT RIGHT(CName, 2) FROM LOAN;
(ii)

twor

B3.39Practice2 marks
  1. The table STAFF has the columns SNo, SName, Post, Periods, Allowance, DOJ. Write an SQL query to display the first three characters of each SName.
  2. Write the output of the query SELECT MOD(38, 7);
Answer
(i)
SELECT LEFT(SName, 3) FROM STAFF;
(ii)

3

B3.40Practice2 marks
  1. The table GARMENT has the columns GCode, GName, Fabric, Stock, Price, Launch. Write an SQL query to display the GName in capital letters.
  2. Write the output of the query SELECT MOD(YEAR('2027-04-26'), 100);
Answer
(i)
SELECT UCASE(GName) FROM GARMENT;
(ii)

27

B3.41Practice2 marks
  1. The table EVENT has the columns ENo, EName, House, Points, Prize, EDate. Write an SQL query to display each EName and the number of characters in it.
  2. Write the output of the query SELECT LEFT('Computer', 5);
Answer
(i)
SELECT EName, LENGTH(EName) FROM EVENT;
(ii)

Compu

B3.42Practice2 marks
  1. The table TRAIN has the columns TNo, TName, Zone, Coaches, Fare, StartDate. Write an SQL query to display each TName and the name of the month of StartDate.
  2. Write the output of the query SELECT POWER(2, 4);
Answer
(i)
SELECT TName, MONTHNAME(StartDate) FROM TRAIN;
(ii)

16

B3.43Practice2 marks
  1. The table LAPTOP has the columns LNo, Model, Brand, RAM, Price, Launch. Write an SQL query to display each Model and its Price rounded to one decimal place.
  2. Write the output of the query SELECT ROUND(730.203);
Answer
(i)
SELECT Model, ROUND(Price, 1) FROM LAPTOP;
(ii)

730

B3.44Practice2 marks
  1. The table CLUB has the columns CNo, MName, Activity, Age, Fee, DOJ. Write an SQL query to display three characters of each MName, starting from the second character.
  2. Write the output of the query SELECT LENGTH('Computer');
Answer
(i)
SELECT MID(MName, 2, 3) FROM CLUB;
(ii)

8

B3.45Practice2 marks
  1. The table FARM has the columns FNo, Farmer, Crop, Acres, Yield, SowDate. Write an SQL query to display each Farmer and the name of the week day of SowDate.
  2. Write the output of the query SELECT INSTR('Vidyalaya', 'y');
Answer
(i)
SELECT Farmer, DAYNAME(SowDate) FROM FARM;
(ii)

4

B4Network short answers2 marks · 44 questions
B4.1SQP 2026-272 marks

What is a star topology? Write one advantage of it.

Answer

In a star topology every computer is connected to a central device (hub or switch) with its own cable. Advantage: if one computer or one cable fails, the others keep working; a fault is easy to find.

B4.2SQP 2026-272 marks

What is VoIP? Write one advantage of it.

Answer

VoIP means Voice over Internet Protocol. It lets us make voice calls over the Internet: the voice is changed into data packets. Advantage: calls, even long-distance ones, are very cheap.

B4.3Practice2 marks

Write two differences between a hub and a switch.

Answer

(1) A hub sends the data it receives to all the computers connected to it; a switch sends it only to the computer it is meant for. (2) So a hub causes more traffic and is slower; a switch is faster and safer.

B4.4Practice2 marks

Write two differences between LAN and WAN.

Answer

(1) A LAN covers a small area such as a room, building or campus; a WAN covers countries and continents. (2) A LAN is usually owned by one organisation and is fast; a WAN uses public links such as telephone lines and satellites, and is slower and costlier.

B4.5Practice2 marks

Write two differences between a static web page and a dynamic web page.

Answer

(1) The content of a static page stays the same for every visitor; the content of a dynamic page changes with the user, time or data. (2) A static page is made with HTML only and is quick to load; a dynamic page uses scripts and usually a database (example: a result page).

B4.6Practice2 marks

Write two differences between a website and a web page.

Answer

(1) A web page is one document on the Web; a website is a collection of related web pages. (2) A web page has its own URL; a website has one domain name, and its first page is the home page.

B4.7Practice2 marks

What is a repeater? When is it needed?

Answer

A repeater is a device that receives a weak signal, makes it strong again and sends it forward. It is needed when the cable between two points is long (more than about 100 m), because the signal becomes weak over distance.

B4.8Practice2 marks

What is a modem? Why is it needed?

Answer

Modem means modulator-demodulator. It changes the digital signals of a computer into analog signals for a telephone line (modulation) and changes the incoming analog signals back to digital (demodulation). It is needed to connect a computer to the Internet through such lines.

B4.9Practice2 marks

What is a router? How is it different from a switch?

Answer

A router connects two or more networks and sends data along the best path. A switch connects the computers inside one network; a router connects different networks, for example a home LAN to the Internet.

B4.10Practice2 marks

What is a gateway?

Answer

A gateway is a device that connects two networks which work in different ways (use different protocols). It acts as the entry and exit point of a network, for example between a LAN and the Internet.

B4.11Practice2 marks

Write two differences between star and bus topologies.

Answer

(1) In a star, every computer is connected to a central device; in a bus, all the computers are connected to one main cable. (2) A star needs more cable but a fault is easy to find; a bus needs less cable, but if the main cable breaks the whole network stops.

B4.12Practice2 marks

What is a mesh topology? Write one advantage and one disadvantage.

Answer

In a mesh topology every computer is connected to every other computer. Advantage: if one link fails, data takes another path, so it is very reliable. Disadvantage: it needs a lot of cable, so it is costly.

B4.13Practice2 marks

What is a tree topology?

Answer

A tree topology joins groups of star networks to one main (bus) cable, so it looks like the branches of a tree. It is easy to expand, but if the main cable fails the groups cannot talk to each other.

B4.14Practice2 marks

What is a URL? Name its parts with an example.

Answer

URL means Uniform Resource Locator. It is the unique address of a resource on the Web. In https://www.kvs.ac.in/result.html, https is the protocol, www.kvs.ac.in is the domain name and result.html is the file (page) name.

B4.15Practice2 marks

Write the difference between the Internet and the World Wide Web.

Answer

The Internet is a worldwide network of networks: the cables, devices and connections. The World Wide Web is a service that runs on the Internet: a collection of linked web pages that we open in a browser. E-mail and VoIP are other services of the Internet.

B4.16Practice2 marks

What is a web browser? Name any two.

Answer

A web browser is a program that asks a web server for a web page and shows it on the screen. Examples: Google Chrome, Mozilla Firefox, Microsoft Edge, Safari. (Any two.)

B4.17Practice2 marks

What is a web server?

Answer

A web server is a computer (and its software) that stores websites and sends the web pages to browsers when they ask for them. Example of web server software: Apache.

B4.18Practice2 marks

What is web hosting? Why is it needed?

Answer

Web hosting is a service that gives space on a web server to store the files of a website. It is needed so that the website is connected to the Internet all the time and anyone can open it.

B4.19Practice2 marks

What are cookies? Write one use.

Answer

Cookies are small text files that a website saves on the user's computer through the browser. They remember the user's details, such as login name, language or items in the cart, so that the site can show them on the next visit.

B4.20Practice2 marks

Write the difference between add-ons and plug-ins of a browser.

Answer

An add-on (extension) adds a new feature to the browser itself, such as an ad blocker or a dictionary. A plug-in is a separate program that helps the browser to show content it cannot handle on its own, such as some video or document formats.

B4.21Practice2 marks

Write any two settings of a web browser that a user can change.

Answer

Any two: set the home page; clear the browsing history and cookies; block pop-ups; choose the default search engine; save or remove passwords; turn on private browsing.

B4.22Practice2 marks

What is e-mail? Write two advantages.

Answer

E-mail (electronic mail) is a service to send and receive messages over the Internet. Advantages: it reaches in seconds anywhere in the world; files such as photos and documents can be attached; it costs almost nothing. (Any two.)

B4.23Practice2 marks

Write the difference between e-mail and chat.

Answer

E-mail is like a letter: the message waits in the mailbox and the other person may read it later. Chat is live: both persons are online and the typed messages are received at once.

B4.24Practice2 marks

Expand:

  1. PAN
  2. MAN
  3. URL
  4. WWW.
Answer

(i) Personal Area Network (ii) Metropolitan Area Network (iii) Uniform Resource Locator (iv) World Wide Web.

B4.25Practice2 marks

What is a computer network? Write two advantages.

Answer

A computer network is a group of computers and devices connected to each other to share data and resources. Advantages: files and data are shared quickly; costly devices such as printers are shared; people communicate by e-mail and chat. (Any two.)

B4.26Practice2 marks

Classify each as PAN, LAN, MAN or WAN:

  1. A phone connected to a smart watch
  2. Computers of a school lab
  3. Offices of a company in Delhi and London
  4. A cable TV network in a city.
Answer

(i) PAN (ii) LAN (iii) WAN (iv) MAN.

B4.27Practice2 marks

What is a PAN? Give two examples.

Answer

A Personal Area Network connects the devices of one person within about 10 metres. Examples: a phone connected to earbuds by Bluetooth; a laptop connected to a wireless mouse; a phone sharing its hotspot with a laptop. (Any two.)

B4.28Practice2 marks

What is a MAN? Give one example.

Answer

A Metropolitan Area Network covers a city or a large town. It is bigger than a LAN and smaller than a WAN. Example: a cable TV network, or the network that joins all the branches of a bank in one city.

B4.29Practice2 marks

In a network layout, where should the server be placed and why?

Answer

The server is placed in the block that has the largest number of computers. Most of the data then travels inside that block, so the traffic on the links between blocks and the cable cost are less.

B4.30Practice2 marks

Which device will you use in each case?

  1. To connect all the computers of one block.
  2. Between two blocks that are 150 m apart.
Answer

(i) Switch (or hub), because it connects many computers of a LAN. (ii) Repeater, because the signal becomes weak beyond about 100 m and must be made strong again.

B4.31Practice2 marks

A school wants a website where parents can log in and see the marks of their ward. Should it be static or dynamic? Give a reason.

Answer

Dynamic. The page must show different marks to different parents, taken from a database. A static page shows the same content to everyone.

B4.32Practice2 marks

Write two advantages of the star topology over the bus topology.

Answer

(1) If one computer or cable fails, the rest of the network keeps working. (2) A fault is easy to find and a new computer is easy to add, without stopping the network.

B4.33Practice2 marks

What is the home page of a website?

Answer

The home page is the first (main) page of a website. It opens when we type the address of the site, and it has links to the other pages of the site.

B4.34Practice2 marks

Name the device for each:

  1. Connects networks that use different protocols
  2. Chooses the best path for data between networks.
Answer

(i) Gateway (ii) Router.

B4.35Practice2 marks

What is the use of the World Wide Web? Name any two of its applications.

Answer

The Web lets us open linked pages of text, pictures, sound and video from anywhere. Applications: information search, e-mail on the web, online shopping, online classes, social networking. (Any two.)

B4.36Practice2 marks

Your friend says that cookies are viruses. Is it correct? Explain.

Answer

No. Cookies are plain text files, not programs, so they cannot run or harm the computer. But they store data about the user, so they can affect privacy. They can be deleted from the browser settings.

B4.37Practice2 marks

Write one difference between a domain name and a URL with an example.

Answer

A domain name is the name of a website, such as cbse.gov.in. A URL is the full address of one page or file, including the protocol and the path, such as https://www.cbse.gov.in/newsite/index.html.

B4.38Practice2 marks

Why is a switch preferred to a hub in a school lab? Write two reasons.

Answer

(1) A switch sends the data only to the computer it is meant for, so the network is faster. (2) Other computers do not receive the data, so it is safer.

B4.39Practice2 marks

What is the difference between a web browser and a web server?

Answer

A web browser is a program on the user's computer that asks for web pages and shows them. A web server is a computer on the Internet that stores the pages and sends them to the browser.

B4.40Practice2 marks

What is the role of a modem and a router in a home Internet connection?

Answer

The modem connects the home to the Internet line of the service provider and changes the signals. The router shares this one connection among the phones and computers of the home and sends the data to the right device.

B4.41Practice2 marks

Write any two differences between a LAN and a MAN.

Answer

(1) A LAN covers a building or campus; a MAN covers a city. (2) A LAN is owned by one organisation; a MAN is often run by a service provider and joins many LANs.

B4.42Practice2 marks

What is an add-on? Give two examples.

Answer

An add-on (extension) is a small program that is added to a browser to give it an extra feature. Examples: an ad blocker, a password manager, a grammar checker, a dark-mode extension. (Any two.)

B4.43Practice2 marks

Which application of the Internet will you use for each?

  1. A free voice call to a cousin abroad.
  2. Sending a project file to your teacher.
Answer

(i) VoIP. (ii) E-mail (with the file as an attachment).

B4.44Practice2 marks

What is a bus topology? Write one advantage and one disadvantage.

Answer

All the computers are connected to one main cable called the backbone. Advantage: it needs the least cable and is cheap. Disadvantage: if the main cable breaks, the whole network stops, and a fault is hard to find.

B5Societal impacts short answers2 marks · 44 questions
B5.1SQP 2026-272 marks

Write the difference between an active and a passive digital footprint.

Answer

An active digital footprint is the data we share on purpose, such as posts, comments and e-mails. A passive digital footprint is the data collected without our action, such as the sites we visit, our location and our search history.

B5.2SQP 2026-272 marks

Write any two net etiquettes (netiquettes) that a good Internet user follows.

Answer

(1) Be ethical: do not copy others' work, and share only true information. (2) Be respectful: be polite, respect the privacy and views of others. Also: be responsible; do not feed the trolls. (Any two, with a line on each.)

B5.3Practice2 marks

What is a digital footprint? Why should we be careful about it?

Answer

A digital footprint is the trail of data we leave when we use the Internet. It stays for a very long time and can be seen by others, so a careless post can harm our image, admission or job later.

B5.4Practice2 marks

What is plagiarism? Write two ways to avoid it.

Answer

Plagiarism is using someone else's work or ideas as our own without giving credit. To avoid it: (1) write in your own words, (2) name the source (cite it), and put copied lines in quotation marks.

B5.5Practice2 marks

Write the difference between copyright and patent.

Answer

Copyright protects original creative work such as books, music, films and software; it is given to the creator automatically. A patent protects an invention; it must be applied for and is given for a fixed period (20 years).

B5.6Practice2 marks

Write the difference between copyright and trademark.

Answer

Copyright protects creative work such as a book, a song or a program. A trademark protects the name, logo or symbol by which the goods of a company are known.

B5.7Practice2 marks

What are Intellectual Property Rights? Name any two.

Answer

They are the legal rights of a person over the things created by his or her mind, such as inventions, writings, designs and brand names. Examples: copyright, patent, trademark. (Any two.)

B5.8Practice2 marks

What is FOSS? Give two examples.

Answer

FOSS means Free and Open Source Software. Its source code is given to everyone, and users are free to use, study, change and share it. Examples: Linux, LibreOffice, Python, Mozilla Firefox. (Any two.)

B5.9Practice2 marks

Write two differences between open source software and proprietary software.

Answer

(1) The source code of open source software is available to all; the source code of proprietary software is kept secret by the company. (2) Open source software can be changed and shared freely; proprietary software needs a paid licence and cannot be changed or shared.

B5.10Practice2 marks

What is a software licence? Name any two public licences.

Answer

A licence is a legal permission that tells how a software or work may be used, copied and shared. Public licences: GNU General Public License (GPL), Creative Commons (CC), Apache licence. (Any two.)

B5.11Practice2 marks

What is hacking? How is an ethical hacker different from a cracker?

Answer

Hacking is getting into a computer or network without permission. An ethical hacker does it with permission to find weak points so that they can be fixed. A cracker does it to steal or damage, which is a crime.

B5.12Practice2 marks

What is phishing? Write two ways to stay safe from it.

Answer

Phishing is cheating a person through a fake e-mail, message or website that looks real, to get passwords or bank details. Safety: (1) do not click on unknown links; check the address of the site, (2) never share OTP, PIN or password with anyone.

B5.13Practice2 marks

What is cyber bullying? What should a student do if it happens?

Answer

Cyber bullying is troubling, threatening or insulting a person again and again through the Internet or phone. The student should not reply, should keep the proof (screenshots), block the person and tell parents or a teacher. It can be reported on the cyber crime portal.

B5.14Practice2 marks

What is the Information Technology Act, 2000? Write its two purposes.

Answer

It is the main cyber law of India (amended in 2008). (1) It gives legal recognition to electronic records and digital signatures. (2) It defines cyber crimes such as hacking and identity theft and fixes the punishment for them.

B5.15Practice2 marks

What is e-waste? Write two harmful effects of it.

Answer

E-waste is old or discarded electrical and electronic items such as phones, computers and batteries. (1) It has lead, mercury and cadmium, which poison the soil and water. (2) Burning it pollutes the air and causes breathing and skin diseases.

B5.16Practice2 marks

Write any two ways of managing e-waste.

Answer

(1) Reduce: buy a new gadget only when needed and use it for a longer time. (2) Reuse or refurbish: donate or repair and use old gadgets. (3) Recycle: give the waste to an authorised recycler who recovers the useful metals. (Any two.)

B5.17Practice2 marks

Write two health problems caused by the over-use of technology and one way to prevent each.

Answer

(1) Eye strain: look away from the screen at regular intervals and keep the screen at arm's length. (2) Back, neck and wrist pain: sit straight on a proper chair and take short breaks.

B5.18Practice2 marks

What is data protection? Write two ways to protect your personal data online.

Answer

Data protection means keeping personal data safe from misuse. Ways: use strong and different passwords with two-step verification; do not share personal details on unknown sites; check the privacy settings of apps. (Any two.)

B5.19Practice2 marks

What is identity theft? Give one example.

Answer

Identity theft is stealing someone's personal details and using them to pretend to be that person. Example: making a fake social media profile with a person's name and photo, or using stolen card details for shopping.

B5.20Practice2 marks

What is software piracy? Why is it wrong?

Answer

Software piracy is copying, using or selling a software without buying its licence. It is illegal, it takes away the earning of the people who made the software, and pirated copies may carry viruses.

B5.21Practice2 marks

Write two differences between freeware and free and open source software.

Answer

(1) Freeware costs nothing but its source code is not given; FOSS gives the source code. (2) Freeware cannot be changed by the user; FOSS can be changed and shared.

B5.22Practice2 marks

What is the difference between recycling and refurbishing of e-waste?

Answer

Recycling breaks the old item into parts and materials such as metal, plastic and glass, which are used to make new products. Refurbishing repairs the old item so that the same item can be used again.

B5.23Practice2 marks

Write any two points you will keep in mind while using social media.

Answer

(1) Do not share personal details such as address, phone number and passwords. (2) Think before posting: a post stays for ever. (3) Do not accept requests from strangers. (4) Check a message before forwarding it. (Any two.)

B5.24Practice2 marks

What is a strong password? Write two points.

Answer

(1) It is long (8 or more characters) and has capital letters, small letters, digits and symbols. (2) It does not have a name, date of birth or a common word, and it is different for every account.

B5.25Practice2 marks

What is copyright infringement? Give one example.

Answer

It is using a copyrighted work without the permission of its owner. Example: downloading a new film from an illegal site, or using a photograph from the Internet in an advertisement without permission.

B5.26Practice2 marks

Rohan copied the code of a classmate's project and submitted it as his own. Name this act. Write one thing he should have done.

Answer

Plagiarism. He should have written his own code, or taken permission and clearly given credit to the classmate.

B5.27Practice2 marks

Why is it said that the digital footprint is permanent?

Answer

Once something is posted, copies of it are saved on servers and may be shared or saved by other users. Even if we delete it from our account, it can remain elsewhere on the Internet.

B5.28Practice2 marks

Write two ways in which a school can reduce its e-waste.

Answer

(1) Repair and upgrade old computers and use them for a longer time. (2) Donate working machines and give the dead ones only to an authorised e-waste recycler.

B5.29Practice2 marks

What is ergonomics in computer use? Write one example.

Answer

Ergonomics means arranging the work place so that the body is comfortable and safe. Example: keeping the top of the screen at eye level and the feet flat on the floor while working.

B5.30Practice2 marks

Mention two do's for safe online transactions.

Answer

(1) Use only trusted sites and apps; check for https and the lock sign. (2) Never share OTP, PIN or CVV; log out after the work, and do not use public Wi-Fi for payments.

B5.31Practice2 marks

What is a Creative Commons licence?

Answer

It is a public licence that lets a creator give others the right to use, share and sometimes change the work for free, under conditions chosen by the creator, such as giving credit to the creator.

B5.32Practice2 marks

Write the difference between hacking and phishing.

Answer

In hacking, a person breaks into a computer or account without permission using technical tricks. In phishing, the person is fooled by a fake message or website into giving the password or bank details himself.

B5.33Practice2 marks

Why should we not connect to any free public Wi-Fi for banking work?

Answer

Public Wi-Fi is often not secured. Others on the same network may read the data we send, such as passwords and card numbers, and misuse them.

B5.34Practice2 marks

What does 'be responsible' mean as a net etiquette? Give two points.

Answer

(1) Do not share personal information of yourself or of others. (2) Think before you post or forward, and avoid cyber bullying.

B5.35Practice2 marks

What does 'be ethical' mean as a net etiquette? Give two points.

Answer

(1) Do not use copyrighted material without permission (no piracy, no plagiarism). (2) Share only knowledge and information that is true and useful.

B5.36Practice2 marks

Write two harmful materials present in e-waste and the harm each causes.

Answer

Lead (in batteries and monitors) damages the brain and kidneys. Mercury (in switches and screens) harms the nervous system. Cadmium (in batteries) damages the kidneys and bones. (Any two.)

B5.37Practice2 marks

What is the role of the cyber crime portal of India? What kind of complaints can be made there?

Answer

The National Cyber Crime Reporting Portal lets citizens report cyber crimes online. Complaints of online cheating, cyber bullying, fake profiles, hacking and crimes against women and children can be made there.

B5.38Practice2 marks

Your phone is slow, so you plan to throw it in the dustbin. Write two better options.

Answer

(1) Get it repaired or reset and keep using it, or give it to someone who needs it. (2) If it cannot be used, give it to an authorised e-waste collection centre or the company's take-back scheme.

B5.39Practice2 marks

Write two points of difference between a patent and a trademark.

Answer

(1) A patent protects an invention; a trademark protects a brand name, logo or symbol. (2) A patent is valid for a fixed period (20 years); a trademark can be renewed again and again.

B5.40Practice2 marks

How does excessive use of social media affect a student? Write two points.

Answer

(1) It wastes study and sleep time and reduces concentration. (2) It can cause stress, loneliness and a habit that is hard to break. Limited and planned use avoids this.

B5.41Practice2 marks

What is meant by 'digital property rights'? Give one example.

Answer

They are the rights of a person over the digital things he or she has created, such as a website, a software, an e-book or a digital photo. Example: a photographer's right over the photos she uploads.

B5.42Practice2 marks

Which Intellectual Property Right will protect each of these?

  1. A new kind of water purifier.
  2. The logo of a shoe company.
Answer

(i) Patent (ii) Trademark.

B5.43Practice2 marks

Write two effects of long hours of gaming on a child's health.

Answer

(1) Eye strain, headache and poor sleep. (2) Less physical activity, which leads to weight gain and back or neck pain.

B5.44Practice2 marks

What should you check before you download a picture from the Internet for your school magazine?

Answer

Check whether the picture is copyrighted and under which licence it is shared. Use it only if the licence allows it (for example Creative Commons) or after taking permission, and give credit to the owner.

Section C · 3 marks each

C1Societal impacts: three situations3 marks · 24 questions
C1.1SQP 2026-273 marks

Read the three situations and answer.

  1. Meena gets an e-mail that looks like it is from her bank. It asks her to click a link and enter her ATM PIN. Name this cyber crime.
  2. A group of classmates keeps posting insulting comments on Arun's photos every day. Name this act.
  3. Write one net etiquette that tells us to share only verified information in polite language.
Answer
  1. Phishing.
  2. Cyber bullying.
  3. Be credible / be polite: share only verified information and use polite language.
C1.2Practice3 marks

Ravi downloaded a paid game from an illegal website and shared it with his friends.

  1. Name the wrong act done by Ravi.
  2. Which right of the game company is violated?
  3. Write one legal way in which Ravi can get games.
Answer
  1. Software piracy.
  2. Copyright (an Intellectual Property Right).
  3. Buy the game from the official store, or use free and open source games.
C1.3Practice3 marks

A company throws its old computers in an open ground outside the city.

  1. What is such waste called?
  2. Write one harm it causes to the environment.
  3. Suggest one correct way to dispose of it.
Answer
  1. E-waste.
  2. Metals such as lead and mercury mix with the soil and ground water and poison them.
  3. Give it to an authorised e-waste recycler (or donate the working computers).
C1.4Practice3 marks

Sana copied three pages from a website into her project report and did not mention the source.

  1. Name this act.
  2. Is it ethical? Give a reason.
  3. Write one way in which she can use the material correctly.
Answer
  1. Plagiarism.
  2. No. She is showing another person's work as her own.
  3. Write it in her own words and mention the source (citation); put copied lines in quotes.
C1.5Practice3 marks

Karan uses the same password 'karan123' for his e-mail, his bank and his social media.

  1. Write one risk of this habit.
  2. Write two features of a strong password.
  3. Name one more step that makes an account safer.
Answer
  1. If one account is hacked, all his accounts can be opened.
  2. It is long, and it mixes capital letters, small letters, digits and symbols.
  3. Two-step verification (OTP).
C1.6Practice3 marks

Anita's photo and name are used by an unknown person to make a fake profile and send messages to her friends.

  1. Name this cyber crime.
  2. Under which Act of India can action be taken?
  3. Write one step Anita should take at once.
Answer
  1. Identity theft.
  2. The Information Technology Act, 2000.
  3. Report the profile to the site, tell her parents, and complain on the cyber crime portal or to the police.
C1.7Practice3 marks

A scientist has made a new low-cost machine that cleans river water.

  1. Which Intellectual Property Right should she apply for?
  2. She has also designed a logo for her company. Which right protects it?
  3. Why are such rights given?
Answer
  1. Patent.
  2. Trademark.
  3. So that the creator gets credit and money for the work, and others cannot copy it without permission. This encourages new inventions.
C1.8Practice3 marks

Dev plays games on his phone for six hours every day.

  1. Write two health problems he may face.
  2. Write one bad effect on his studies or behaviour.
  3. Suggest two good habits for him.
Answer
  1. Eye strain and headache; neck and back pain; poor sleep. (Any two.)
  2. Less time and attention for studies; he may become irritable and stay away from family and friends.
  3. Fix a time limit for the screen; take breaks and play outdoor games.
C1.9Practice3 marks

A school wants to install software on 60 computers but has a small budget.

  1. Which kind of software should it choose: proprietary or free and open source?
  2. Write one reason.
  3. Name one such operating system and one office package.
Answer
  1. Free and open source software.
  2. It costs nothing, can be installed on any number of computers legally, and can be changed as needed.
  3. Linux (for example Ubuntu); LibreOffice.
C1.10Practice3 marks

Neha posts her daily location and photos of her house on a public social media account.

  1. Which kind of digital footprint is she creating?
  2. Write one danger of this habit.
  3. Write one setting or habit that will make her safer.
Answer
  1. Active digital footprint.
  2. Strangers come to know where she lives and when the house is empty; the photos can be misused.
  3. Keep the account private and do not share location and personal details.
C1.11Practice3 marks

Mohan received a call saying that his electricity will be cut tonight unless he installs an app and shares the OTP.

  1. What kind of act is this?
  2. What should Mohan do?
  3. Where can he report it?
Answer
  1. Online fraud (a phishing or vishing attempt).
  2. He should not install the app or share the OTP, and should cut the call.
  3. On the National Cyber Crime Reporting Portal or the helpline 1930, or at the nearest police station.
C1.12Practice3 marks

An author finds that her e-book is being sold on another website without her permission.

  1. Which right of the author is violated?
  2. What is this violation called?
  3. Name the licence she could use if she wants people to share her book freely with credit to her.
Answer
  1. Copyright.
  2. Copyright infringement.
  3. A Creative Commons licence.
C1.13Practice3 marks

A shopkeeper repairs old laptops, puts new batteries in them and sells them at a low price.

  1. What is this process called?
  2. Which 'R' of e-waste management does a buyer of such a laptop follow?
  3. Write one benefit of this to the environment.
Answer
  1. Refurbishing.
  2. Reuse.
  3. Less e-waste is thrown away and fewer new raw materials are needed.
C1.14Practice3 marks

During an online class, some students type rude jokes in the chat box and share the meeting link with outsiders.

  1. Which rules of behaviour are they breaking?
  2. Write two such rules for an online class.
  3. What can be the result of sharing the link?
Answer
  1. Net etiquettes (netiquette).
  2. Be polite and respectful in chat; keep the microphone muted when not speaking; do not disturb the class. (Any two.)
  3. Unknown persons can enter the class, disturb it and misuse the names and pictures of the students.
C1.15Practice3 marks

A website asks Tina to accept cookies.

  1. What are cookies?
  2. Write one benefit of cookies to Tina.
  3. Write one privacy concern about cookies.
Answer
  1. Small text files that a website saves on the user's computer through the browser.
  2. The site remembers her login, language and cart items, so she need not enter them again.
  3. They record her browsing habits, which can be used to track her and show targeted advertisements.
C1.16Practice3 marks

Arjun got the admin password of his school website by watching the teacher type it. He then changed the notices on the site as a joke.

  1. Name the cyber crime.
  2. Is it punishable in India? Name the law.
  3. What should a responsible student have done?
Answer
  1. Hacking (unauthorised access).
  2. Yes, under the Information Technology Act, 2000.
  3. He should not have used the password, and should have told the teacher to change it.
C1.17Practice3 marks

Priya writes a blog. She wants to use a song and some pictures made by others in it.

  1. What should she check first?
  2. What must she do if the work is copyrighted?
  3. What must she do even if the work is free to use?
Answer
  1. Whether the work is copyrighted, and under which licence it is shared.
  2. Take permission from the owner (or pay for the licence).
  3. Give credit to the creator, as the licence asks.
C1.18Practice3 marks

An office worker types for eight hours a day and now has pain in the wrists and neck.

  1. Name the health problem linked to such repeated work.
  2. Write two changes in the sitting arrangement that will help.
  3. Write one habit that reduces eye strain.
Answer
  1. Repetitive strain injury.
  2. Keep the keyboard at elbow height with the wrists straight; keep the screen at eye level and sit with back support.
  3. Look at a far object for a few seconds at regular intervals and blink often.
C1.19Practice3 marks

A social media app collects the contact list and location of its users without telling them clearly.

  1. Which kind of digital footprint is being made for the users?
  2. Which right of the users is affected?
  3. Write one step a user can take.
Answer
  1. Passive digital footprint.
  2. Right to privacy (protection of personal data).
  3. Check the app permissions and turn off the ones that are not needed; read the privacy policy.
C1.20Practice3 marks

Raj forwards every message he receives, including a false message about a medicine.

  1. Which net etiquette is he not following?
  2. Write one harm such forwards can cause.
  3. What should he do before forwarding a message?
Answer
  1. Be credible / be responsible: share only true information.
  2. People may believe the false message and harm their health; it spreads fear and rumours.
  3. Check the message from a trusted source; if not sure, do not forward it.
C1.21Practice3 marks

A college student builds a useful app. She wants everyone to see, improve and share its code.

  1. Which kind of software should she release it as?
  2. Name one licence she can use.
  3. Write one benefit to other programmers.
Answer
  1. Free and open source software.
  2. GNU General Public License (GPL), or the Apache licence.
  3. They can study the code, learn from it, fix errors and add new features.
C1.22Practice3 marks

Sumit's old phone has a swollen battery and does not start.

  1. Should he throw it in the dustbin? Give a reason.
  2. Name one harmful substance in it.
  3. Where should he give it?
Answer
  1. No. It can catch fire, and its chemicals pollute the soil and water.
  2. Lead, cadmium or lithium. (Any one.)
  3. At an authorised e-waste collection centre or the company's take-back counter.
C1.23Practice3 marks

A stranger whom Riya met in an online game asks for her school name and photo.

  1. Should she share them? Give a reason.
  2. Write one safe step she should take.
  3. Write one rule for making friends online.
Answer
  1. No. The stranger may not be who he says he is and can misuse the details.
  2. Block and report the player, and tell her parents.
  3. Do not share personal details or meet a person known only online.
C1.24Practice3 marks

A shop prints the logo of a famous sports brand on its own cheap shoes and sells them.

  1. Which Intellectual Property Right is violated?
  2. Who is harmed by this?
  3. How long can the brand keep this right?
Answer
  1. Trademark.
  2. The company (loss of sales and name) and the buyers, who are cheated with fake goods.
  3. As long as it keeps renewing the registration.
C2Series and DataFrame: code and output3 marks · 52 questions
C2.1Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Asha': 49, 'Ravi': 69, 'Tina': 89} and a Series S2 from the dictionary {'Ravi': 78, 'Tina': 62, 'Om': 40}. Display S1 + S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Asha': 49, 'Ravi': 69, 'Tina': 89})
S2 = pd.Series({'Ravi': 78, 'Tina': 62, 'Om': 40})
print(S1 + S2)

Output:

Asha      NaN
Om        NaN
Ravi    147.0
Tina    151.0
dtype: float64

The labels Asha and Om are present in only one Series, so they get NaN. The result becomes float.

C2.2Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Rohit': 84, 'Virat': 118, 'Gill': 34} and a Series S2 from the dictionary {'Virat': 61, 'Gill': 90, 'Rahul': 112}. Display S1 - S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Rohit': 84, 'Virat': 118, 'Gill': 34})
S2 = pd.Series({'Virat': 61, 'Gill': 90, 'Rahul': 112})
print(S1 - S2)

Output:

Gill    -56.0
Rahul     NaN
Rohit     NaN
Virat    57.0
dtype: float64

The labels Rohit and Rahul are present in only one Series, so they get NaN. The result becomes float.

C2.3Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Jan': 40, 'Feb': 70, 'Mar': 65} and a Series S2 from the dictionary {'Feb': 85, 'Mar': 55, 'Apr': 35}. Display S1 * S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Jan': 40, 'Feb': 70, 'Mar': 65})
S2 = pd.Series({'Feb': 85, 'Mar': 55, 'Apr': 35})
print(S1 * S2)

Output:

Apr       NaN
Feb    5950.0
Jan       NaN
Mar    3575.0
dtype: float64

The labels Jan and Apr are present in only one Series, so they get NaN. The result becomes float.

C2.4Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Pen': 300, 'Book': 140, 'Bag': 50} and a Series S2 from the dictionary {'Book': 30, 'Bag': 160, 'Box': 130}. Display S1 - S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Pen': 300, 'Book': 140, 'Bag': 50})
S2 = pd.Series({'Book': 30, 'Bag': 160, 'Box': 130})
print(S1 - S2)

Output:

Bag    -110.0
Book    110.0
Box       NaN
Pen       NaN
dtype: float64

The labels Pen and Box are present in only one Series, so they get NaN. The result becomes float.

C2.5Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Delhi': 6, 'Pune': 17, 'Agra': 19} and a Series S2 from the dictionary {'Pune': 13, 'Agra': 18, 'Kochi': 32}. Display S1 - S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Delhi': 6, 'Pune': 17, 'Agra': 19})
S2 = pd.Series({'Pune': 13, 'Agra': 18, 'Kochi': 32})
print(S1 - S2)

Output:

Agra     1.0
Delhi    NaN
Kochi    NaN
Pune     4.0
dtype: float64

The labels Delhi and Kochi are present in only one Series, so they get NaN. The result becomes float.

C2.6Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Eng': 70, 'Hin': 60, 'Maths': 75} and a Series S2 from the dictionary {'Hin': 40, 'Maths': 60, 'Sci': 85}. Display S1 * S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Eng': 70, 'Hin': 60, 'Maths': 75})
S2 = pd.Series({'Hin': 40, 'Maths': 60, 'Sci': 85})
print(S1 * S2)

Output:

Eng         NaN
Hin      2400.0
Maths    4500.0
Sci         NaN
dtype: float64

The labels Eng and Sci are present in only one Series, so they get NaN. The result becomes float.

C2.7Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Jun': 240, 'Jul': 300, 'Aug': 170} and a Series S2 from the dictionary {'Jul': 150, 'Aug': 180, 'Sep': 270}. Display S1 + S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Jun': 240, 'Jul': 300, 'Aug': 170})
S2 = pd.Series({'Jul': 150, 'Aug': 180, 'Sep': 270})
print(S1 + S2)

Output:

Aug    350.0
Jul    450.0
Jun      NaN
Sep      NaN
dtype: float64

The labels Jun and Sep are present in only one Series, so they get NaN. The result becomes float.

C2.8Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Yoga': 600, 'Dance': 1200, 'Music': 1400} and a Series S2 from the dictionary {'Dance': 1300, 'Music': 1100, 'Art': 700}. Display S1 - S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Yoga': 600, 'Dance': 1200, 'Music': 1400})
S2 = pd.Series({'Dance': 1300, 'Music': 1100, 'Art': 700})
print(S1 - S2)

Output:

Art        NaN
Dance   -100.0
Music    300.0
Yoga       NaN
dtype: float64

The labels Yoga and Art are present in only one Series, so they get NaN. The result becomes float.

C2.9Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'F1': 160, 'F2': 130, 'F3': 320} and a Series S2 from the dictionary {'F2': 190, 'F3': 170, 'F4': 330}. Display S1 + S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'F1': 160, 'F2': 130, 'F3': 320})
S2 = pd.Series({'F2': 190, 'F3': 170, 'F4': 330})
print(S1 + S2)

Output:

F1      NaN
F2    320.0
F3    490.0
F4      NaN
dtype: float64

The labels F1 and F4 are present in only one Series, so they get NaN. The result becomes float.

C2.10Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Red': 26, 'Blue': 24, 'Green': 38} and a Series S2 from the dictionary {'Blue': 14, 'Green': 28, 'Gold': 10}. Display S1 + S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Red': 26, 'Blue': 24, 'Green': 38})
S2 = pd.Series({'Blue': 14, 'Green': 28, 'Gold': 10})
print(S1 + S2)

Output:

Blue     38.0
Gold      NaN
Green    66.0
Red       NaN
dtype: float64

The labels Red and Gold are present in only one Series, so they get NaN. The result becomes float.

C2.11Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Anil': 600, 'Bela': 750, 'Chand': 450} and a Series S2 from the dictionary {'Bela': 700, 'Chand': 350, 'Devi': 450}. Display S1 + S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Anil': 600, 'Bela': 750, 'Chand': 450})
S2 = pd.Series({'Bela': 700, 'Chand': 350, 'Devi': 450})
print(S1 + S2)

Output:

Anil        NaN
Bela     1450.0
Chand     800.0
Devi        NaN
dtype: float64

The labels Anil and Devi are present in only one Series, so they get NaN. The result becomes float.

C2.12Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'P1': 80, 'P2': 115, 'P3': 170} and a Series S2 from the dictionary {'P2': 95, 'P3': 245, 'P4': 35}. Display S1 - S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'P1': 80, 'P2': 115, 'P3': 170})
S2 = pd.Series({'P2': 95, 'P3': 245, 'P4': 35})
print(S1 - S2)

Output:

P1     NaN
P2    20.0
P3   -75.0
P4     NaN
dtype: float64

The labels P1 and P4 are present in only one Series, so they get NaN. The result becomes float.

C2.13Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Mon': 95, 'Tue': 110, 'Wed': 65} and a Series S2 from the dictionary {'Tue': 120, 'Wed': 40, 'Thu': 80}. Display S1 + S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Mon': 95, 'Tue': 110, 'Wed': 65})
S2 = pd.Series({'Tue': 120, 'Wed': 40, 'Thu': 80})
print(S1 + S2)

Output:

Mon      NaN
Thu      NaN
Tue    230.0
Wed    105.0
dtype: float64

The labels Mon and Thu are present in only one Series, so they get NaN. The result becomes float.

C2.14Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'H1': 40, 'H2': 240, 'H3': 260} and a Series S2 from the dictionary {'H2': 220, 'H3': 80, 'H4': 240}. Display S1 - S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'H1': 40, 'H2': 240, 'H3': 260})
S2 = pd.Series({'H2': 220, 'H3': 80, 'H4': 240})
print(S1 - S2)

Output:

H1      NaN
H2     20.0
H3    180.0
H4      NaN
dtype: float64

The labels H1 and H4 are present in only one Series, so they get NaN. The result becomes float.

C2.15Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'A': 17, 'B': 38, 'C': 8} and a Series S2 from the dictionary {'B': 14, 'C': 31, 'D': 9}. Display S1 * S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'A': 17, 'B': 38, 'C': 8})
S2 = pd.Series({'B': 14, 'C': 31, 'D': 9})
print(S1 * S2)

Output:

A      NaN
B    532.0
C    248.0
D      NaN
dtype: float64

The labels A and D are present in only one Series, so they get NaN. The result becomes float.

C2.16Practice3 marks

Write a Python program to create a Series S1 from the dictionary {'Mon': 275, 'Tue': 200, 'Wed': 125} and a Series S2 from the dictionary {'Tue': 375, 'Wed': 500, 'Thu': 300}. Display S1 - S2. Also write the output.

Answer
import pandas as pd
S1 = pd.Series({'Mon': 275, 'Tue': 200, 'Wed': 125})
S2 = pd.Series({'Tue': 375, 'Wed': 500, 'Thu': 300})
print(S1 - S2)

Output:

Mon      NaN
Thu      NaN
Tue   -175.0
Wed   -375.0
dtype: float64

The labels Mon and Thu are present in only one Series, so they get NaN. The result becomes float.

C2.17Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Total that is Round1 plus Round2
  2. Change the column label Team to TeamName
  3. Delete the column Round2.

DataFrame: df

TeamRound1Round2
Q1Alpha3050
Q2Beta4010
Q3Gamma1525
Q4Delta2535
Answer
(i)
df['Total'] = df['Round1'] + df['Round2']
(ii)
df = df.rename(columns={'Team': 'TeamName'})
(iii)
df = df.drop('Round2', axis=1)

The DataFrame after the three statements:

   TeamName  Round1  Total
Q1    Alpha      30     80
Q2     Beta      40     50
Q3    Gamma      15     40
Q4    Delta      25     60
C2.18Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Value that is Price multiplied by Stock
  2. Change the column label Model to ModelName
  3. Delete the row with the label M2.

DataFrame: df

ModelPriceStock
M1Astra100004
M2Bolt1500013
M3Comet200003
M4Dyna2700010
Answer
(i)
df['Value'] = df['Price'] * df['Stock']
(ii)
df = df.rename(columns={'Model': 'ModelName'})
(iii)
df = df.drop('M2', axis=0)

The DataFrame after the three statements:

   ModelName  Price  Stock   Value
M1     Astra  10000      4   40000
M3     Comet  20000      3   60000
M4      Dyna  27000     10  270000
C2.19Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Total that is Round1 plus Round2
  2. Change the column label Gamer to GamerName
  3. Change the Round1 of the row G3 to 72.

DataFrame: df

GamerRound1Round2
G1Neo3242
G2Rex2065
G3Sky5932
G4Max5261
Answer
(i)
df['Total'] = df['Round1'] + df['Round2']
(ii)
df = df.rename(columns={'Gamer': 'GamerName'})
(iii)
df.loc['G3', 'Round1'] = 72

The DataFrame after the three statements:

   GamerName  Round1  Round2  Total
G1       Neo      32      42     74
G2       Rex      20      65     85
G3       Sky      72      32     91
G4       Max      52      61    113
C2.20Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Balance that is Deposit minus Withdraw
  2. Change the column label Customer to CustomerName
  3. Delete the column Withdraw.

DataFrame: df

CustomerDepositWithdraw
A1Farah6045
A2Girish18040
A3Harsh12050
A4Indu16015
Answer
(i)
df['Balance'] = df['Deposit'] - df['Withdraw']
(ii)
df = df.rename(columns={'Customer': 'CustomerName'})
(iii)
df = df.drop('Withdraw', axis=1)

The DataFrame after the three statements:

   CustomerName  Deposit  Balance
A1        Farah       60       15
A2       Girish      180      140
A3        Harsh      120       70
A4         Indu      160      145
C2.21Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Plants that is Trees plus Shrubs
  2. Change the column label Garden to GardenName
  3. Delete the row with the label G2.

DataFrame: df

GardenTreesShrubs
G1Rose11070
G2Lotus90120
G3Lily20100
G4Tulip70190
Answer
(i)
df['Plants'] = df['Trees'] + df['Shrubs']
(ii)
df = df.rename(columns={'Garden': 'GardenName'})
(iii)
df = df.drop('G2', axis=0)

The DataFrame after the three statements:

   GardenName  Trees  Shrubs  Plants
G1       Rose    110      70     180
G3       Lily     20     100     120
G4      Tulip     70     190     260
C2.22Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Persons that is Students plus Teachers
  2. Change the column label Class to ClassName
  3. Change the Students of the row T3 to 45.

DataFrame: df

ClassStudentsTeachers
T1VI315
T2VII363
T3VIII284
T4IX386
Answer
(i)
df['Persons'] = df['Students'] + df['Teachers']
(ii)
df = df.rename(columns={'Class': 'ClassName'})
(iii)
df.loc['T3', 'Students'] = 45

The DataFrame after the three statements:

   ClassName  Students  Teachers  Persons
T1        VI        31         5       36
T2       VII        36         3       39
T3      VIII        45         4       32
T4        IX        38         6       44
C2.23Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Value that is Rate multiplied by Units
  2. Change the column label Product to ProductName
  3. Delete the column Units.

DataFrame: df

ProductRateUnits
O1Mouse160017
O2Keyboard240011
O3Webcam150018
O4Speaker9006
Answer
(i)
df['Value'] = df['Rate'] * df['Units']
(ii)
df = df.rename(columns={'Product': 'ProductName'})
(iii)
df = df.drop('Units', axis=1)

The DataFrame after the three statements:

   ProductName  Rate  Value
O1       Mouse  1600  27200
O2    Keyboard  2400  26400
O3      Webcam  1500  27000
O4     Speaker   900   5400
C2.24Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Balance that is Allotted minus Spent
  2. Change the column label Dept to DeptName
  3. Delete the row with the label D2.

DataFrame: df

DeptAllottedSpent
D1Sports19020
D2Library17025
D3Lab9030
D4Music14055
Answer
(i)
df['Balance'] = df['Allotted'] - df['Spent']
(ii)
df = df.rename(columns={'Dept': 'DeptName'})
(iii)
df = df.drop('D2', axis=0)

The DataFrame after the three statements:

   DeptName  Allotted  Spent  Balance
D1   Sports       190     20      170
D3      Lab        90     30       60
D4    Music       140     55       85
C2.25Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Amount that is Price multiplied by Sold
  2. Change the column label Item to Product
  3. Change the Price of the row C3 to 10.

DataFrame: df

ItemPriceSold
C1Samosa20140
C2Tea3020
C3Juice5590
C4Sandwich6060
Answer
(i)
df['Amount'] = df['Price'] * df['Sold']
(ii)
df = df.rename(columns={'Item': 'Product'})
(iii)
df.loc['C3', 'Price'] = 10

The DataFrame after the three statements:

     Product  Price  Sold  Amount
C1    Samosa     20   140    2800
C2       Tea     30    20     600
C3     Juice     10    90    4950
C4  Sandwich     60    60    3600
C2.26Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Range that is MaxTemp minus MinTemp
  2. Change the column label City to CityName
  3. Delete the column MinTemp.

DataFrame: df

CityMaxTempMinTemp
W1Delhi3918
W2Shimla3116
W3Jaipur3424
W4Kochi3013
Answer
(i)
df['Range'] = df['MaxTemp'] - df['MinTemp']
(ii)
df = df.rename(columns={'City': 'CityName'})
(iii)
df = df.drop('MinTemp', axis=1)

The DataFrame after the three statements:

   CityName  MaxTemp  Range
W1    Delhi       39     21
W2   Shimla       31     15
W3   Jaipur       34     10
W4    Kochi       30     17
C2.27Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Collection that is Tickets multiplied by Price
  2. Change the column label Show to ShowName
  3. Delete the row with the label T2.

DataFrame: df

ShowTicketsPrice
T1Morning40250
T2Noon100200
T3Evening60150
T4Night130300
Answer
(i)
df['Collection'] = df['Tickets'] * df['Price']
(ii)
df = df.rename(columns={'Show': 'ShowName'})
(iii)
df = df.drop('T2', axis=0)

The DataFrame after the three statements:

   ShowName  Tickets  Price  Collection
T1  Morning       40    250       10000
T3  Evening       60    150        9000
T4    Night      130    300       39000
C2.28Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Gross that is Basic plus Bonus
  2. Change the column label Name to Student
  3. Change the Basic of the row E3 to 46000.

DataFrame: df

NameBasicBonus
E1Gopal200003500
E2Hema480005500
E3Irfan280004000
E4Jyoti400002000
Answer
(i)
df['Gross'] = df['Basic'] + df['Bonus']
(ii)
df = df.rename(columns={'Name': 'Student'})
(iii)
df.loc['E3', 'Basic'] = 46000

The DataFrame after the three statements:

   Student  Basic  Bonus  Gross
E1   Gopal  20000   3500  23500
E2    Hema  48000   5500  53500
E3   Irfan  46000   4000  32000
E4   Jyoti  40000   2000  42000
C2.29Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Total that is Theory plus Practical
  2. Change the column label Name to Student
  3. Delete the column Practical.

DataFrame: df

NameTheoryPractical
E1Ishaan3125
E2Jaya5429
E3Kunal3221
E4Lata3422
Answer
(i)
df['Total'] = df['Theory'] + df['Practical']
(ii)
df = df.rename(columns={'Name': 'Student'})
(iii)
df = df.drop('Practical', axis=1)

The DataFrame after the three statements:

   Student  Theory  Total
E1  Ishaan      31     56
E2    Jaya      54     83
E3   Kunal      32     53
E4    Lata      34     56
C2.30Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Cost that is Litres multiplied by Rate
  2. Change the column label Vehicle to VehicleName
  3. Delete the row with the label V2.

DataFrame: df

VehicleLitresRate
V1Car5592
V2Bike45106
V3Bus25104
V4Van35100
Answer
(i)
df['Cost'] = df['Litres'] * df['Rate']
(ii)
df = df.rename(columns={'Vehicle': 'VehicleName'})
(iii)
df = df.drop('V2', axis=0)

The DataFrame after the three statements:

   VehicleName  Litres  Rate  Cost
V1         Car      55    92  5060
V3         Bus      25   104  2600
V4         Van      35   100  3500
C2.31Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Total that is Qtr1 plus Qtr2
  2. Change the column label Name to Student
  3. Change the Qtr1 of the row S3 to 20.

DataFrame: df

NameQtr1Qtr2
S1Kabir5456
S2Meera5820
S3Nitin3618
S4Pooja2248
Answer
(i)
df['Total'] = df['Qtr1'] + df['Qtr2']
(ii)
df = df.rename(columns={'Name': 'Student'})
(iii)
df.loc['S3', 'Qtr1'] = 20

The DataFrame after the three statements:

   Student  Qtr1  Qtr2  Total
S1   Kabir    54    56    110
S2   Meera    58    20     78
S3   Nitin    20    18     54
S4   Pooja    22    48     70
C2.32Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Total that is Gold plus Silver
  2. Change the column label House to HouseName
  3. Delete the column Silver.

DataFrame: df

HouseGoldSilver
H1Shivaji93
H2Tagore116
H3Raman77
H4Ashoka812
Answer
(i)
df['Total'] = df['Gold'] + df['Silver']
(ii)
df = df.rename(columns={'House': 'HouseName'})
(iii)
df = df.drop('Silver', axis=1)

The DataFrame after the three statements:

   HouseName  Gold  Total
H1   Shivaji     9     12
H2    Tagore    11     17
H3     Raman     7     14
H4    Ashoka     8     20
C2.33Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Total that is Wheat plus Rice
  2. Change the column label Village to VillageName
  3. Delete the row with the label V2.

DataFrame: df

VillageWheatRice
V1Rampur5565
V2Sonpur6530
V3Lalganj8550
V4Nayagaon3040
Answer
(i)
df['Total'] = df['Wheat'] + df['Rice']
(ii)
df = df.rename(columns={'Village': 'VillageName'})
(iii)
df = df.drop('V2', axis=0)

The DataFrame after the three statements:

   VillageName  Wheat  Rice  Total
V1      Rampur     55    65    120
V3     Lalganj     85    50    135
V4    Nayagaon     30    40     70
C2.34Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Bill that is Rent multiplied by Days
  2. Change the column label RoomType to RoomTypeName
  3. Change the Rent of the row H3 to 3600.

DataFrame: df

RoomTypeRentDays
H1Single38003
H2Double24002
H3Deluxe20005
H4Suite26006
Answer
(i)
df['Bill'] = df['Rent'] * df['Days']
(ii)
df = df.rename(columns={'RoomType': 'RoomTypeName'})
(iii)
df.loc['H3', 'Rent'] = 3600

The DataFrame after the three statements:

   RoomTypeName  Rent  Days   Bill
H1       Single  3800     3  11400
H2       Double  2400     2   4800
H3       Deluxe  3600     5  10000
H4        Suite  2600     6  15600
C2.35Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Total that is Issued plus Available
  2. Change the column label Subject to SubjectName
  3. Delete the column Available.

DataFrame: df

SubjectIssuedAvailable
B1English2095
B2Hindi3065
B3Maths75105
B4Science70110
Answer
(i)
df['Total'] = df['Issued'] + df['Available']
(ii)
df = df.rename(columns={'Subject': 'SubjectName'})
(iii)
df = df.drop('Available', axis=1)

The DataFrame after the three statements:

   SubjectName  Issued  Total
B1     English      20    115
B2       Hindi      30     95
B3       Maths      75    180
B4     Science      70    180
C2.36Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Total that is Boys plus Girls
  2. Change the column label Class to ClassName
  3. Delete the row with the label C2.

DataFrame: df

ClassBoysGirls
C1IX2918
C2X2813
C3XI2414
C4XII2026
Answer
(i)
df['Total'] = df['Boys'] + df['Girls']
(ii)
df = df.rename(columns={'Class': 'ClassName'})
(iii)
df = df.drop('C2', axis=0)

The DataFrame after the three statements:

   ClassName  Boys  Girls  Total
C1        IX    29     18     47
C3        XI    24     14     38
C4       XII    20     26     46
C2.37Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Profit that is Income minus Expense
  2. Change the column label Shop to ShopName
  3. Change the Income of the row S3 to 135.

DataFrame: df

ShopIncomeExpense
S1Alpha8540
S2Bharat8025
S3City11545
S4Deluxe9020
Answer
(i)
df['Profit'] = df['Income'] - df['Expense']
(ii)
df = df.rename(columns={'Shop': 'ShopName'})
(iii)
df.loc['S3', 'Income'] = 135

The DataFrame after the three statements:

   ShopName  Income  Expense  Profit
S1    Alpha      85       40      45
S2   Bharat      80       25      55
S3     City     135       45      70
S4   Deluxe      90       20      70
C2.38Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Boundaries that is Fours plus Sixes
  2. Change the column label Player to PlayerName
  3. Delete the column Sixes.

DataFrame: df

PlayerFoursSixes
P1Rohit362
P2Virat2713
P3Gill1417
P4Pant263
Answer
(i)
df['Boundaries'] = df['Fours'] + df['Sixes']
(ii)
df = df.rename(columns={'Player': 'PlayerName'})
(iii)
df = df.drop('Sixes', axis=1)

The DataFrame after the three statements:

   PlayerName  Fours  Boundaries
P1      Rohit     36          38
P2      Virat     27          40
P3       Gill     14          31
P4       Pant     26          29
C2.39Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Total that is Eng plus Maths
  2. Change the column label Name to Student
  3. Delete the row with the label R2.

DataFrame: df

NameEngMaths
R1Asha8560
R2Ravi6361
R3Tina6773
R4Om6063
Answer
(i)
df['Total'] = df['Eng'] + df['Maths']
(ii)
df = df.rename(columns={'Name': 'Student'})
(iii)
df = df.drop('R2', axis=0)

The DataFrame after the three statements:

   Student  Eng  Maths  Total
R1    Asha   85     60    145
R3    Tina   67     73    140
R4      Om   60     63    123
C2.40Practice3 marks

Consider the DataFrame df given below. Write statements to:

  1. Add a column Amount that is Price multiplied by Qty
  2. Change the column label Item to Product
  3. Change the Price of the row S3 to 90.

DataFrame: df

ItemPriceQty
S1Pen26055
S2Notebook15035
S3Bag17020
S4Stapler19010
Answer
(i)
df['Amount'] = df['Price'] * df['Qty']
(ii)
df = df.rename(columns={'Item': 'Product'})
(iii)
df.loc['S3', 'Price'] = 90

The DataFrame after the three statements:

     Product  Price  Qty  Amount
S1       Pen    260   55   14300
S2  Notebook    150   35    5250
S3       Bag     90   20    3400
S4   Stapler    190   10    1900
C2.41Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Player': ['Rohit', 'Virat', 'Gill', 'Pant'],
                   'Fours': [36, 27, 14, 26],
                   'Sixes': [2, 13, 17, 3]},
                  index=['P1', 'P2', 'P3', 'P4'])
print(df.shape)
print(df.loc['P2', 'Fours'])
print(df['Sixes'].max())
Answer

Output:

(4, 3)
27
17
C2.42Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Village': ['Rampur', 'Sonpur', 'Lalganj', 'Nayagaon'],
                   'Wheat': [55, 65, 85, 30],
                   'Rice': [65, 30, 50, 40]},
                  index=['V1', 'V2', 'V3', 'V4'])
print(df.head(2))
print(df.size)
Answer

Output:

   Village  Wheat  Rice
V1  Rampur     55    65
V2  Sonpur     65    30
12
C2.43Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Name': ['Gopal', 'Hema', 'Irfan', 'Jyoti'],
                   'Basic': [20000, 48000, 28000, 40000],
                   'Bonus': [3500, 5500, 4000, 2000]},
                  index=['E1', 'E2', 'E3', 'E4'])
print(df.iloc[1:3])
print(len(df))
Answer

Output:

     Name  Basic  Bonus
E2   Hema  48000   5500
E3  Irfan  28000   4000
4
C2.44Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Product': ['Mouse', 'Keyboard', 'Webcam', 'Speaker'],
                   'Rate': [1600, 2400, 1500, 900],
                   'Units': [17, 11, 18, 6]},
                  index=['O1', 'O2', 'O3', 'O4'])
print(df[['Product', 'Units']].tail(2))
print(df['Rate'].sum())
Answer

Output:

    Product  Units
O3   Webcam     18
O4  Speaker      6
6400
C2.45Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Model': ['Astra', 'Bolt', 'Comet', 'Dyna'],
                   'Price': [10000, 15000, 20000, 27000],
                   'Stock': [4, 13, 3, 10]},
                  index=['M1', 'M2', 'M3', 'M4'])
print(df.shape)
print(df.loc['M2', 'Price'])
print(df['Stock'].max())
Answer

Output:

(4, 3)
15000
13
C2.46Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Shop': ['Alpha', 'Bharat', 'City', 'Deluxe'],
                   'Income': [85, 80, 115, 90],
                   'Expense': [40, 25, 45, 20]},
                  index=['S1', 'S2', 'S3', 'S4'])
print(df.head(2))
print(df.size)
Answer

Output:

      Shop  Income  Expense
S1   Alpha      85       40
S2  Bharat      80       25
12
C2.47Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'House': ['Shivaji', 'Tagore', 'Raman', 'Ashoka'],
                   'Gold': [9, 11, 7, 8],
                   'Silver': [3, 6, 7, 12]},
                  index=['H1', 'H2', 'H3', 'H4'])
print(df.iloc[1:3])
print(len(df))
Answer

Output:

     House  Gold  Silver
H2  Tagore    11       6
H3   Raman     7       7
4
C2.48Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Show': ['Morning', 'Noon', 'Evening', 'Night'],
                   'Tickets': [40, 100, 60, 130],
                   'Price': [250, 200, 150, 300]},
                  index=['T1', 'T2', 'T3', 'T4'])
print(df[['Show', 'Price']].tail(2))
print(df['Tickets'].sum())
Answer

Output:

       Show  Price
T3  Evening    150
T4    Night    300
330
C2.49Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Class': ['VI', 'VII', 'VIII', 'IX'],
                   'Students': [31, 36, 28, 38],
                   'Teachers': [5, 3, 4, 6]},
                  index=['T1', 'T2', 'T3', 'T4'])
print(df.shape)
print(df.loc['T2', 'Students'])
print(df['Teachers'].max())
Answer

Output:

(4, 3)
36
6
C2.50Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Team': ['Alpha', 'Beta', 'Gamma', 'Delta'],
                   'Round1': [30, 40, 15, 25],
                   'Round2': [50, 10, 25, 35]},
                  index=['Q1', 'Q2', 'Q3', 'Q4'])
print(df.head(2))
print(df.size)
Answer

Output:

     Team  Round1  Round2
Q1  Alpha      30      50
Q2   Beta      40      10
12
C2.51Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Class': ['IX', 'X', 'XI', 'XII'],
                   'Boys': [29, 28, 24, 20],
                   'Girls': [18, 13, 14, 26]},
                  index=['C1', 'C2', 'C3', 'C4'])
print(df.iloc[1:3])
print(len(df))
Answer

Output:

   Class  Boys  Girls
C2     X    28     13
C3    XI    24     14
4
C2.52Practice3 marks

Write the output of the following code.

import pandas as pd
df = pd.DataFrame({'Name': ['Kabir', 'Meera', 'Nitin', 'Pooja'],
                   'Qtr1': [54, 58, 36, 22],
                   'Qtr2': [56, 20, 18, 48]},
                  index=['S1', 'S2', 'S3', 'S4'])
print(df[['Name', 'Qtr2']].tail(2))
print(df['Qtr1'].sum())
Answer

Output:

     Name  Qtr2
S3  Nitin    18
S4  Pooja    48
170
C3SQL queries using functions3 marks · 44 questions
C3.1Practice3 marks

Consider the table PATIENT given below. Write SQL queries to display:

  1. The PName in small letters, of the rows where Dept is 'Cardiology'
  2. Each PName and the name of the week day of DOA
  3. All the PName in alphabetical order.

Table: PATIENT

PNoPNameDeptDaysBillDOA
101YashCardiology25000.322026-03-11
102ChetanCardiology155983.682026-03-01
103ZeenatCardiology48922.892026-07-02
104SwatiOrtho76492.812026-04-01
105PankajENT148701.772026-03-13
106MohitENT135473.262026-02-19
Answer
(i)
SELECT LOWER(PName) FROM PATIENT WHERE Dept = 'Cardiology';
LOWER(PName)
yash
chetan
zeenat

Explanation: WHERE keeps only the rows where Dept is 'Cardiology': 3 of the 6 rows match (Yash, Chetan, Zeenat). The function LOWER is worked out for every row that is shown.

(ii)
SELECT PName, DAYNAME(DOA) FROM PATIENT;
PNameDAYNAME(DOA)
YashWednesday
ChetanSunday
ZeenatThursday
SwatiWednesday
PankajFriday
MohitThursday

Explanation: The function DAYNAME is worked out for every row that is shown.

(iii)
SELECT PName FROM PATIENT ORDER BY PName;
PName
Chetan
Mohit
Pankaj
Swati
Yash
Zeenat

Explanation: ORDER BY PName arranges the result in ascending (smallest first) order.

C3.2Practice3 marks

Consider the table PATIENT given below. Write SQL queries to display:

  1. The last two characters of each PName
  2. Each PName and the year of DOA
  3. Each PName and the remainder when Days is divided by 7.

Table: PATIENT

PNoPNameDeptDaysBillDOA
101YashCardiology25000.322026-03-11
102ChetanCardiology155983.682026-03-01
103ZeenatCardiology48922.892026-07-02
104SwatiOrtho76492.812026-04-01
105PankajENT148701.772026-03-13
106MohitENT135473.262026-02-19
Answer
(i)
SELECT RIGHT(PName, 2) FROM PATIENT;
RIGHT(PName, 2)
sh
an
at
ti
aj
it

Explanation: The function RIGHT is worked out for every row that is shown.

(ii)
SELECT PName, YEAR(DOA) FROM PATIENT;
PNameYEAR(DOA)
Yash2026
Chetan2026
Zeenat2026
Swati2026
Pankaj2026
Mohit2026

Explanation: The function YEAR is worked out for every row that is shown.

(iii)
SELECT PName, MOD(Days, 7) FROM PATIENT;
PNameMOD(Days, 7)
Yash2
Chetan1
Zeenat4
Swati0
Pankaj0
Mohit6

Explanation: The function MOD is worked out for every row that is shown.

C3.3Practice3 marks

Consider the table EMPLOYEE given below. Write SQL queries to display:

  1. The EName in capital letters
  2. Each EName and the name of the month of DOJ
  3. The EName and Salary in descending order of Salary.

Table: EMPLOYEE

ENoENameDeptSalaryBonusDOJ
11IshaHR430003522.372023-02-02
12YashSales400001725.022025-08-02
13SumanHR440003550.142019-09-25
14JatinSales450001269.742025-03-19
15NikhilSales250003263.382022-09-09
16SachinAccounts310003064.282021-05-17
Answer
(i)
SELECT UCASE(EName) FROM EMPLOYEE;
UCASE(EName)
ISHA
YASH
SUMAN
JATIN
NIKHIL
SACHIN

Explanation: The function UCASE is worked out for every row that is shown.

(ii)
SELECT EName, MONTHNAME(DOJ) FROM EMPLOYEE;
ENameMONTHNAME(DOJ)
IshaFebruary
YashAugust
SumanSeptember
JatinMarch
NikhilSeptember
SachinMay

Explanation: The function MONTHNAME is worked out for every row that is shown.

(iii)
SELECT EName, Salary FROM EMPLOYEE ORDER BY Salary DESC;
ENameSalary
Jatin45000
Suman44000
Isha43000
Yash40000
Sachin31000
Nikhil25000

Explanation: ORDER BY Salary arranges the result in descending (largest first) order.

C3.4Practice3 marks

Consider the table EMPLOYEE given below. Write SQL queries to display:

  1. Each EName and the number of characters in it
  2. The EName of the rows where the month of DOJ is 2
  3. The EName that end with the letter 'h'.

Table: EMPLOYEE

ENoENameDeptSalaryBonusDOJ
11IshaHR430003522.372023-02-02
12YashSales400001725.022025-08-02
13SumanHR440003550.142019-09-25
14JatinSales450001269.742025-03-19
15NikhilSales250003263.382022-09-09
16SachinAccounts310003064.282021-05-17
Answer
(i)
SELECT EName, LENGTH(EName) FROM EMPLOYEE;
ENameLENGTH(EName)
Isha4
Yash4
Suman5
Jatin5
Nikhil6
Sachin6

Explanation: The function LENGTH is worked out for every row that is shown.

(ii)
SELECT EName FROM EMPLOYEE WHERE MONTH(DOJ) = 2;
EName
Isha

Explanation: WHERE keeps only the rows where MONTH(DOJ) is 2: 1 of the 6 rows matches (Isha).

(iii)
SELECT EName FROM EMPLOYEE WHERE EName LIKE '%h';
EName
Yash

Explanation: WHERE keeps only the rows where EName matches the pattern '%h': 1 of the 6 rows matches (Yash). '%h' means the value ends with 'h'.

C3.5Practice3 marks

Consider the table BOOK given below. Write SQL queries to display:

  1. The first three characters of each Title
  2. Each Title and the year of DOP
  3. Each Title and its Price rounded to one decimal place.

Table: BOOK

BNoTitleGenrePagesPriceDOP
1Wings of FireFiction120342.442022-06-18
2Malgudi DaysFiction290337.032025-06-20
3PanchatantraBiography150339.912021-07-27
4GodanPoetry320195.342024-05-13
5GitanjaliBiography440520.872024-10-12
6Train to PakistanFiction330359.452021-10-21
Answer
(i)
SELECT LEFT(Title, 3) FROM BOOK;
LEFT(Title, 3)
Win
Mal
Pan
God
Git
Tra

Explanation: The function LEFT is worked out for every row that is shown.

(ii)
SELECT Title, YEAR(DOP) FROM BOOK;
TitleYEAR(DOP)
Wings of Fire2022
Malgudi Days2025
Panchatantra2021
Godan2024
Gitanjali2024
Train to Pakistan2021

Explanation: The function YEAR is worked out for every row that is shown.

(iii)
SELECT Title, ROUND(Price, 1) FROM BOOK;
TitleROUND(Price, 1)
Wings of Fire342.4
Malgudi Days337.0
Panchatantra339.9
Godan195.3
Gitanjali520.9
Train to Pakistan359.5

Explanation: The function ROUND is worked out for every row that is shown.

C3.6Practice3 marks

Consider the table BOOK given below. Write SQL queries to display:

  1. Three characters of each Title, starting from the second character
  2. The Title and DOP of the rows where the year of DOP is 2022 or later
  3. All the Title in alphabetical order.

Table: BOOK

BNoTitleGenrePagesPriceDOP
1Wings of FireFiction120342.442022-06-18
2Malgudi DaysFiction290337.032025-06-20
3PanchatantraBiography150339.912021-07-27
4GodanPoetry320195.342024-05-13
5GitanjaliBiography440520.872024-10-12
6Train to PakistanFiction330359.452021-10-21
Answer
(i)
SELECT MID(Title, 2, 3) FROM BOOK;
MID(Title, 2, 3)
ing
alg
anc
oda
ita
rai

Explanation: The function MID is worked out for every row that is shown.

(ii)
SELECT Title, DOP FROM BOOK WHERE YEAR(DOP) >= 2022;
TitleDOP
Wings of Fire2022-06-18
Malgudi Days2025-06-20
Godan2024-05-13
Gitanjali2024-10-12

Explanation: WHERE keeps only the rows where YEAR(DOP) is at least 2022: 4 of the 6 rows match (Wings of Fire, Malgudi Days, Godan, Gitanjali).

(iii)
SELECT Title FROM BOOK ORDER BY Title;
Title
Gitanjali
Godan
Malgudi Days
Panchatantra
Train to Pakistan
Wings of Fire

Explanation: ORDER BY Title arranges the result in ascending (smallest first) order.

C3.7Practice3 marks

Consider the table STUDENT given below. Write SQL queries to display:

  1. The last two characters of each SName
  2. The SName of the rows where the month of DOB is 8
  3. Each SName and its Fees rounded to the nearest whole number.

Table: STUDENT

RNoSNameStreamMarksFeesDOB
1IshaScience716193.932008-08-26
2DeepakScience603799.372008-11-04
3GeetaScience883372.652010-03-11
4TanviHumanities764392.132009-02-04
5RohanCommerce633443.292008-05-08
6UmeshCommerce852597.322010-06-25
Answer
(i)
SELECT RIGHT(SName, 2) FROM STUDENT;
RIGHT(SName, 2)
ha
ak
ta
vi
an
sh

Explanation: The function RIGHT is worked out for every row that is shown.

(ii)
SELECT SName FROM STUDENT WHERE MONTH(DOB) = 8;
SName
Isha

Explanation: WHERE keeps only the rows where MONTH(DOB) is 8: 1 of the 6 rows matches (Isha).

(iii)
SELECT SName, ROUND(Fees) FROM STUDENT;
SNameROUND(Fees)
Isha6194
Deepak3799
Geeta3373
Tanvi4392
Rohan3443
Umesh2597

Explanation: The function ROUND is worked out for every row that is shown.

C3.8Practice3 marks

Consider the table STUDENT given below. Write SQL queries to display:

  1. Each SName and the position of the letter 'a' in it
  2. Each SName and the name of the week day of DOB
  3. The SName and Marks in descending order of Marks.

Table: STUDENT

RNoSNameStreamMarksFeesDOB
1IshaScience716193.932008-08-26
2DeepakScience603799.372008-11-04
3GeetaScience883372.652010-03-11
4TanviHumanities764392.132009-02-04
5RohanCommerce633443.292008-05-08
6UmeshCommerce852597.322010-06-25
Answer
(i)
SELECT SName, INSTR(SName, 'a') FROM STUDENT;
SNameINSTR(SName, "a")
Isha4
Deepak5
Geeta5
Tanvi2
Rohan4
Umesh0

Explanation: The function INSTR is worked out for every row that is shown.

(ii)
SELECT SName, DAYNAME(DOB) FROM STUDENT;
SNameDAYNAME(DOB)
IshaTuesday
DeepakTuesday
GeetaThursday
TanviWednesday
RohanThursday
UmeshFriday

Explanation: The function DAYNAME is worked out for every row that is shown.

(iii)
SELECT SName, Marks FROM STUDENT ORDER BY Marks DESC;
SNameMarks
Geeta88
Umesh85
Tanvi76
Isha71
Rohan63
Deepak60

Explanation: ORDER BY Marks arranges the result in descending (largest first) order.

C3.9Practice3 marks

Consider the table PRODUCT given below. Write SQL queries to display:

  1. Each PName and the number of characters in it
  2. The PName and MfgDate of the rows where the year of MfgDate is 2026 or later
  3. Each PName and the remainder when Stock is divided by 7.

Table: PRODUCT

PCodePNameCompanyStockPriceMfgDate
501SoapNeha Foods130114.822026-04-27
502ShampooSai Mart40387.162026-05-15
503BiscuitNeha Foods110187.062026-07-05
504ToothpasteOm Traders30275.282026-11-16
505JuiceNeha Foods120111.882026-11-04
506ButterOm Traders180293.322026-04-27
Answer
(i)
SELECT PName, LENGTH(PName) FROM PRODUCT;
PNameLENGTH(PName)
Soap4
Shampoo7
Biscuit7
Toothpaste10
Juice5
Butter6

Explanation: The function LENGTH is worked out for every row that is shown.

(ii)
SELECT PName, MfgDate FROM PRODUCT WHERE YEAR(MfgDate) >= 2026;
PNameMfgDate
Soap2026-04-27
Shampoo2026-05-15
Biscuit2026-07-05
Toothpaste2026-11-16
Juice2026-11-04
Butter2026-04-27

Explanation: WHERE keeps only the rows where YEAR(MfgDate) is at least 2026: 6 of the 6 rows match (Soap, Shampoo, Biscuit, Toothpaste, Juice, Butter).

(iii)
SELECT PName, MOD(Stock, 7) FROM PRODUCT;
PNameMOD(Stock, 7)
Soap4
Shampoo5
Biscuit5
Toothpaste2
Juice1
Butter5

Explanation: The function MOD is worked out for every row that is shown.

C3.10Practice3 marks

Consider the table PRODUCT given below. Write SQL queries to display:

  1. The PName in small letters, of the rows where Company is 'Neha Foods'
  2. Each PName and the name of the month of MfgDate
  3. Each PName and its Price rounded to one decimal place.

Table: PRODUCT

PCodePNameCompanyStockPriceMfgDate
501SoapNeha Foods130114.822026-04-27
502ShampooSai Mart40387.162026-05-15
503BiscuitNeha Foods110187.062026-07-05
504ToothpasteOm Traders30275.282026-11-16
505JuiceNeha Foods120111.882026-11-04
506ButterOm Traders180293.322026-04-27
Answer
(i)
SELECT LOWER(PName) FROM PRODUCT WHERE Company = 'Neha Foods';
LOWER(PName)
soap
biscuit
juice

Explanation: WHERE keeps only the rows where Company is 'Neha Foods': 3 of the 6 rows match (Soap, Biscuit, Juice). The function LOWER is worked out for every row that is shown.

(ii)
SELECT PName, MONTHNAME(MfgDate) FROM PRODUCT;
PNameMONTHNAME(MfgDate)
SoapApril
ShampooMay
BiscuitJuly
ToothpasteNovember
JuiceNovember
ButterApril

Explanation: The function MONTHNAME is worked out for every row that is shown.

(iii)
SELECT PName, ROUND(Price, 1) FROM PRODUCT;
PNameROUND(Price, 1)
Soap114.8
Shampoo387.2
Biscuit187.1
Toothpaste275.3
Juice111.9
Butter293.3

Explanation: The function ROUND is worked out for every row that is shown.

C3.11Practice3 marks

Consider the table MEMBER given below. Write SQL queries to display:

  1. Three characters of each MName, starting from the second character
  2. Each MName and the name of the week day of JoinDate
  3. The MName that end with the letter 's'.

Table: MEMBER

MNoMNamePlanMonthsFeeJoinDate
1MohitGold32755.292026-07-09
2VikasGold91680.762025-04-25
3TanviSilver122149.512025-01-03
4PallaviGold41398.782026-05-02
5DivyaSilver62568.092025-06-13
6AmanBasic82546.012026-06-19
Answer
(i)
SELECT MID(MName, 2, 3) FROM MEMBER;
MID(MName, 2, 3)
ohi
ika
anv
all
ivy
man

Explanation: The function MID is worked out for every row that is shown.

(ii)
SELECT MName, DAYNAME(JoinDate) FROM MEMBER;
MNameDAYNAME(JoinDate)
MohitThursday
VikasFriday
TanviFriday
PallaviSaturday
DivyaFriday
AmanFriday

Explanation: The function DAYNAME is worked out for every row that is shown.

(iii)
SELECT MName FROM MEMBER WHERE MName LIKE '%s';
MName
Vikas

Explanation: WHERE keeps only the rows where MName matches the pattern '%s': 1 of the 6 rows matches (Vikas). '%s' means the value ends with 's'.

C3.12Practice3 marks

Consider the table MEMBER given below. Write SQL queries to display:

  1. The MName in capital letters
  2. Each MName and the year of JoinDate
  3. Each MName and its Fee rounded to the nearest whole number.

Table: MEMBER

MNoMNamePlanMonthsFeeJoinDate
1MohitGold32755.292026-07-09
2VikasGold91680.762025-04-25
3TanviSilver122149.512025-01-03
4PallaviGold41398.782026-05-02
5DivyaSilver62568.092025-06-13
6AmanBasic82546.012026-06-19
Answer
(i)
SELECT UCASE(MName) FROM MEMBER;
UCASE(MName)
MOHIT
VIKAS
TANVI
PALLAVI
DIVYA
AMAN

Explanation: The function UCASE is worked out for every row that is shown.

(ii)
SELECT MName, YEAR(JoinDate) FROM MEMBER;
MNameYEAR(JoinDate)
Mohit2026
Vikas2025
Tanvi2025
Pallavi2026
Divya2025
Aman2026

Explanation: The function YEAR is worked out for every row that is shown.

(iii)
SELECT MName, ROUND(Fee) FROM MEMBER;
MNameROUND(Fee)
Mohit2755
Vikas1681
Tanvi2150
Pallavi1399
Divya2568
Aman2546

Explanation: The function ROUND is worked out for every row that is shown.

C3.13Practice3 marks

Consider the table TICKET given below. Write SQL queries to display:

  1. Each Passenger and the position of the letter 'a' in it
  2. Each Passenger and the name of the month of TravelDate
  3. All the Passenger in alphabetical order.

Table: TICKET

TNoPassengerDestSeatsFareTravelDate
301AnitaGoa39384.042026-01-28
302BhavnaGoa36828.462026-03-11
303SimranKochi68802.732026-04-28
304AmanKochi46806.372026-10-14
305JatinGoa24173.892027-05-03
306SonalLeh59385.632026-12-18
Answer
(i)
SELECT Passenger, INSTR(Passenger, 'a') FROM TICKET;
PassengerINSTR(Passenger, "a")
Anita5
Bhavna3
Simran5
Aman3
Jatin2
Sonal4

Explanation: The function INSTR is worked out for every row that is shown.

(ii)
SELECT Passenger, MONTHNAME(TravelDate) FROM TICKET;
PassengerMONTHNAME(TravelDate)
AnitaJanuary
BhavnaMarch
SimranApril
AmanOctober
JatinMay
SonalDecember

Explanation: The function MONTHNAME is worked out for every row that is shown.

(iii)
SELECT Passenger FROM TICKET ORDER BY Passenger;
Passenger
Aman
Anita
Bhavna
Jatin
Simran
Sonal

Explanation: ORDER BY Passenger arranges the result in ascending (smallest first) order.

C3.14Practice3 marks

Consider the table TICKET given below. Write SQL queries to display:

  1. The first three characters of each Passenger
  2. The Passenger of the rows where the month of TravelDate is 1
  3. Each Passenger and the remainder when Seats is divided by 7.

Table: TICKET

TNoPassengerDestSeatsFareTravelDate
301AnitaGoa39384.042026-01-28
302BhavnaGoa36828.462026-03-11
303SimranKochi68802.732026-04-28
304AmanKochi46806.372026-10-14
305JatinGoa24173.892027-05-03
306SonalLeh59385.632026-12-18
Answer
(i)
SELECT LEFT(Passenger, 3) FROM TICKET;
LEFT(Passenger, 3)
Ani
Bha
Sim
Ama
Jat
Son

Explanation: The function LEFT is worked out for every row that is shown.

(ii)
SELECT Passenger FROM TICKET WHERE MONTH(TravelDate) = 1;
Passenger
Anita

Explanation: WHERE keeps only the rows where MONTH(TravelDate) is 1: 1 of the 6 rows matches (Anita).

(iii)
SELECT Passenger, MOD(Seats, 7) FROM TICKET;
PassengerMOD(Seats, 7)
Anita3
Bhavna3
Simran6
Aman4
Jatin2
Sonal5

Explanation: The function MOD is worked out for every row that is shown.

C3.15Practice3 marks

Consider the table MOVIE given below. Write SQL queries to display:

  1. The Title in small letters, of the rows where Genre is 'Comedy'
  2. Each Title and the year of RelDate
  3. The Title and Minutes in descending order of Minutes.

Table: MOVIE

MNoTitleGenreMinutesRatingRelDate
1UdaanComedy1708.542026-03-24
2SafarComedy1457.522024-08-10
3DostiDrama1256.872023-12-27
4RangoliComedy1305.112023-10-16
5KhelAction1056.832024-12-18
6SapnaAction1155.332024-12-07
Answer
(i)
SELECT LOWER(Title) FROM MOVIE WHERE Genre = 'Comedy';
LOWER(Title)
udaan
safar
rangoli

Explanation: WHERE keeps only the rows where Genre is 'Comedy': 3 of the 6 rows match (Udaan, Safar, Rangoli). The function LOWER is worked out for every row that is shown.

(ii)
SELECT Title, YEAR(RelDate) FROM MOVIE;
TitleYEAR(RelDate)
Udaan2026
Safar2024
Dosti2023
Rangoli2023
Khel2024
Sapna2024

Explanation: The function YEAR is worked out for every row that is shown.

(iii)
SELECT Title, Minutes FROM MOVIE ORDER BY Minutes DESC;
TitleMinutes
Udaan170
Safar145
Rangoli130
Dosti125
Sapna115
Khel105

Explanation: ORDER BY Minutes arranges the result in descending (largest first) order.

C3.16Practice3 marks

Consider the table MOVIE given below. Write SQL queries to display:

  1. The last two characters of each Title
  2. The Title and RelDate of the rows where the year of RelDate is 2024 or later
  3. The Title that end with the letter 'r'.

Table: MOVIE

MNoTitleGenreMinutesRatingRelDate
1UdaanComedy1708.542026-03-24
2SafarComedy1457.522024-08-10
3DostiDrama1256.872023-12-27
4RangoliComedy1305.112023-10-16
5KhelAction1056.832024-12-18
6SapnaAction1155.332024-12-07
Answer
(i)
SELECT RIGHT(Title, 2) FROM MOVIE;
RIGHT(Title, 2)
an
ar
ti
li
el
na

Explanation: The function RIGHT is worked out for every row that is shown.

(ii)
SELECT Title, RelDate FROM MOVIE WHERE YEAR(RelDate) >= 2024;
TitleRelDate
Udaan2026-03-24
Safar2024-08-10
Khel2024-12-18
Sapna2024-12-07

Explanation: WHERE keeps only the rows where YEAR(RelDate) is at least 2024: 4 of the 6 rows match (Udaan, Safar, Khel, Sapna).

(iii)
SELECT Title FROM MOVIE WHERE Title LIKE '%r';
Title
Safar

Explanation: WHERE keeps only the rows where Title matches the pattern '%r': 1 of the 6 rows matches (Safar). '%r' means the value ends with 'r'.

C3.17Practice3 marks

Consider the table COURSE given below. Write SQL queries to display:

  1. The CName in capital letters
  2. The CName of the rows where the month of StartDate is 6
  3. Each CName and its Fee rounded to one decimal place.

Table: COURSE

CNoCNameModeWeeksFeeStartDate
21PythonOnline68375.412026-06-06
22Web DesignOffline83020.132026-10-13
23TallyOnline104826.352027-03-23
24AnimationHybrid228778.762026-11-11
25RoboticsHybrid46911.582026-09-27
26Data EntryOnline249871.532027-11-05
Answer
(i)
SELECT UCASE(CName) FROM COURSE;
UCASE(CName)
PYTHON
WEB DESIGN
TALLY
ANIMATION
ROBOTICS
DATA ENTRY

Explanation: The function UCASE is worked out for every row that is shown.

(ii)
SELECT CName FROM COURSE WHERE MONTH(StartDate) = 6;
CName
Python

Explanation: WHERE keeps only the rows where MONTH(StartDate) is 6: 1 of the 6 rows matches (Python).

(iii)
SELECT CName, ROUND(Fee, 1) FROM COURSE;
CNameROUND(Fee, 1)
Python8375.4
Web Design3020.1
Tally4826.4
Animation8778.8
Robotics6911.6
Data Entry9871.5

Explanation: The function ROUND is worked out for every row that is shown.

C3.18Practice3 marks

Consider the table COURSE given below. Write SQL queries to display:

  1. Each CName and the number of characters in it
  2. Each CName and the name of the week day of StartDate
  3. All the CName in alphabetical order.

Table: COURSE

CNoCNameModeWeeksFeeStartDate
21PythonOnline68375.412026-06-06
22Web DesignOffline83020.132026-10-13
23TallyOnline104826.352027-03-23
24AnimationHybrid228778.762026-11-11
25RoboticsHybrid46911.582026-09-27
26Data EntryOnline249871.532027-11-05
Answer
(i)
SELECT CName, LENGTH(CName) FROM COURSE;
CNameLENGTH(CName)
Python6
Web Design10
Tally5
Animation9
Robotics8
Data Entry10

Explanation: The function LENGTH is worked out for every row that is shown.

(ii)
SELECT CName, DAYNAME(StartDate) FROM COURSE;
CNameDAYNAME(StartDate)
PythonSaturday
Web DesignTuesday
TallyTuesday
AnimationWednesday
RoboticsSunday
Data EntryFriday

Explanation: The function DAYNAME is worked out for every row that is shown.

(iii)
SELECT CName FROM COURSE ORDER BY CName;
CName
Animation
Data Entry
Python
Robotics
Tally
Web Design

Explanation: ORDER BY CName arranges the result in ascending (smallest first) order.

C3.19Practice3 marks

Consider the table VEHICLE given below. Write SQL queries to display:

  1. The first three characters of each Owner
  2. The Owner and RegDate of the rows where the year of RegDate is 2019 or later
  3. Each Owner and its Tax rounded to the nearest whole number.

Table: VEHICLE

VNoOwnerTypeKmTaxRegDate
701YashBike145002852.032019-01-09
702ShreyaVan590002222.072023-01-21
703SimranCar275002206.182018-07-13
704SwatiVan255001253.912020-12-12
705SandeepCar540002275.812025-01-14
706AmanCar155001981.682018-12-01
Answer
(i)
SELECT LEFT(Owner, 3) FROM VEHICLE;
LEFT(Owner, 3)
Yas
Shr
Sim
Swa
San
Ama

Explanation: The function LEFT is worked out for every row that is shown.

(ii)
SELECT Owner, RegDate FROM VEHICLE WHERE YEAR(RegDate) >= 2019;
OwnerRegDate
Yash2019-01-09
Shreya2023-01-21
Swati2020-12-12
Sandeep2025-01-14

Explanation: WHERE keeps only the rows where YEAR(RegDate) is at least 2019: 4 of the 6 rows match (Yash, Shreya, Swati, Sandeep).

(iii)
SELECT Owner, ROUND(Tax) FROM VEHICLE;
OwnerROUND(Tax)
Yash2852
Shreya2222
Simran2206
Swati1254
Sandeep2276
Aman1982

Explanation: The function ROUND is worked out for every row that is shown.

C3.20Practice3 marks

Consider the table VEHICLE given below. Write SQL queries to display:

  1. Three characters of each Owner, starting from the second character
  2. Each Owner and the name of the month of RegDate
  3. The Owner and Km in descending order of Km.

Table: VEHICLE

VNoOwnerTypeKmTaxRegDate
701YashBike145002852.032019-01-09
702ShreyaVan590002222.072023-01-21
703SimranCar275002206.182018-07-13
704SwatiVan255001253.912020-12-12
705SandeepCar540002275.812025-01-14
706AmanCar155001981.682018-12-01
Answer
(i)
SELECT MID(Owner, 2, 3) FROM VEHICLE;
MID(Owner, 2, 3)
ash
hre
imr
wat
and
man

Explanation: The function MID is worked out for every row that is shown.

(ii)
SELECT Owner, MONTHNAME(RegDate) FROM VEHICLE;
OwnerMONTHNAME(RegDate)
YashJanuary
ShreyaJanuary
SimranJuly
SwatiDecember
SandeepJanuary
AmanDecember

Explanation: The function MONTHNAME is worked out for every row that is shown.

(iii)
SELECT Owner, Km FROM VEHICLE ORDER BY Km DESC;
OwnerKm
Shreya59000
Sandeep54000
Simran27500
Swati25500
Aman15500
Yash14500

Explanation: ORDER BY Km arranges the result in descending (largest first) order.

C3.21Practice3 marks

Consider the table ORDERS given below. Write SQL queries to display:

  1. The last two characters of each Customer
  2. Each Customer and the name of the week day of ODate
  3. Each Customer and the remainder when Qty is divided by 7.

Table: ORDERS

ONoCustomerCityQtyAmountODate
9001HarishDelhi56729.592026-06-22
9002PallaviAgra37662.032026-10-28
9003YashPune11561.132026-11-22
9004ArjunPune124746.242026-04-01
9005NikhilDelhi133876.232026-04-20
9006FarhanDelhi66568.182026-03-14
Answer
(i)
SELECT RIGHT(Customer, 2) FROM ORDERS;
RIGHT(Customer, 2)
sh
vi
sh
un
il
an

Explanation: The function RIGHT is worked out for every row that is shown.

(ii)
SELECT Customer, DAYNAME(ODate) FROM ORDERS;
CustomerDAYNAME(ODate)
HarishMonday
PallaviWednesday
YashSunday
ArjunWednesday
NikhilMonday
FarhanSaturday

Explanation: The function DAYNAME is worked out for every row that is shown.

(iii)
SELECT Customer, MOD(Qty, 7) FROM ORDERS;
CustomerMOD(Qty, 7)
Harish5
Pallavi3
Yash4
Arjun5
Nikhil6
Farhan6

Explanation: The function MOD is worked out for every row that is shown.

C3.22Practice3 marks

Consider the table ORDERS given below. Write SQL queries to display:

  1. Each Customer and the position of the letter 'a' in it
  2. Each Customer and the year of ODate
  3. Each Customer and its Amount rounded to one decimal place.

Table: ORDERS

ONoCustomerCityQtyAmountODate
9001HarishDelhi56729.592026-06-22
9002PallaviAgra37662.032026-10-28
9003YashPune11561.132026-11-22
9004ArjunPune124746.242026-04-01
9005NikhilDelhi133876.232026-04-20
9006FarhanDelhi66568.182026-03-14
Answer
(i)
SELECT Customer, INSTR(Customer, 'a') FROM ORDERS;
CustomerINSTR(Customer, "a")
Harish2
Pallavi2
Yash2
Arjun0
Nikhil0
Farhan2

Explanation: The function INSTR is worked out for every row that is shown.

(ii)
SELECT Customer, YEAR(ODate) FROM ORDERS;
CustomerYEAR(ODate)
Harish2026
Pallavi2026
Yash2026
Arjun2026
Nikhil2026
Farhan2026

Explanation: The function YEAR is worked out for every row that is shown.

(iii)
SELECT Customer, ROUND(Amount, 1) FROM ORDERS;
CustomerROUND(Amount, 1)
Harish6729.6
Pallavi7662.0
Yash561.1
Arjun4746.2
Nikhil3876.2
Farhan6568.2

Explanation: The function ROUND is worked out for every row that is shown.

C3.23Practice3 marks

Consider the table DOCTOR given below. Write SQL queries to display:

  1. Each DName and the number of characters in it
  2. Each DName and the name of the month of DOJ
  3. The DName that end with the letter 'i'.

Table: DOCTOR

DNoDNameSpecExpFeeDOJ
1AnitaDental5436.842022-09-22
2OjasviSkin231051.092012-07-22
3NikhilEye21178.342021-05-22
4MeenalSkin141100.172020-08-28
5NaveenDental121207.472014-01-06
6VikasSkin6435.162017-06-04
Answer
(i)
SELECT DName, LENGTH(DName) FROM DOCTOR;
DNameLENGTH(DName)
Anita5
Ojasvi6
Nikhil6
Meenal6
Naveen6
Vikas5

Explanation: The function LENGTH is worked out for every row that is shown.

(ii)
SELECT DName, MONTHNAME(DOJ) FROM DOCTOR;
DNameMONTHNAME(DOJ)
AnitaSeptember
OjasviJuly
NikhilMay
MeenalAugust
NaveenJanuary
VikasJune

Explanation: The function MONTHNAME is worked out for every row that is shown.

(iii)
SELECT DName FROM DOCTOR WHERE DName LIKE '%i';
DName
Ojasvi

Explanation: WHERE keeps only the rows where DName matches the pattern '%i': 1 of the 6 rows matches (Ojasvi). '%i' means the value ends with 'i'.

C3.24Practice3 marks

Consider the table DOCTOR given below. Write SQL queries to display:

  1. The DName in small letters, of the rows where Spec is 'Dental'
  2. The DName of the rows where the month of DOJ is 9
  3. Each DName and its Fee rounded to the nearest whole number.

Table: DOCTOR

DNoDNameSpecExpFeeDOJ
1AnitaDental5436.842022-09-22
2OjasviSkin231051.092012-07-22
3NikhilEye21178.342021-05-22
4MeenalSkin141100.172020-08-28
5NaveenDental121207.472014-01-06
6VikasSkin6435.162017-06-04
Answer
(i)
SELECT LOWER(DName) FROM DOCTOR WHERE Spec = 'Dental';
LOWER(DName)
anita
naveen

Explanation: WHERE keeps only the rows where Spec is 'Dental': 2 of the 6 rows match (Anita, Naveen). The function LOWER is worked out for every row that is shown.

(ii)
SELECT DName FROM DOCTOR WHERE MONTH(DOJ) = 9;
DName
Anita

Explanation: WHERE keeps only the rows where MONTH(DOJ) is 9: 1 of the 6 rows matches (Anita).

(iii)
SELECT DName, ROUND(Fee) FROM DOCTOR;
DNameROUND(Fee)
Anita437
Ojasvi1051
Nikhil1178
Meenal1100
Naveen1207
Vikas435

Explanation: The function ROUND is worked out for every row that is shown.

C3.25Practice3 marks

Consider the table PLAYER given below. Write SQL queries to display:

  1. Three characters of each PName, starting from the second character
  2. Each PName and the year of DOB
  3. All the PName in alphabetical order.

Table: PLAYER

PNoPNameGameMatchesAverageDOB
1NishaCricket3539.932007-12-23
2RachnaChess4448.492009-10-21
3MeenalCricket1962.942010-04-10
4NikhilCricket5140.512006-12-17
5HarishHockey2431.152010-08-13
6ZeenatHockey3629.332009-07-23
Answer
(i)
SELECT MID(PName, 2, 3) FROM PLAYER;
MID(PName, 2, 3)
ish
ach
een
ikh
ari
een

Explanation: The function MID is worked out for every row that is shown.

(ii)
SELECT PName, YEAR(DOB) FROM PLAYER;
PNameYEAR(DOB)
Nisha2007
Rachna2009
Meenal2010
Nikhil2006
Harish2010
Zeenat2009

Explanation: The function YEAR is worked out for every row that is shown.

(iii)
SELECT PName FROM PLAYER ORDER BY PName;
PName
Harish
Meenal
Nikhil
Nisha
Rachna
Zeenat

Explanation: ORDER BY PName arranges the result in ascending (smallest first) order.

C3.26Practice3 marks

Consider the table PLAYER given below. Write SQL queries to display:

  1. The PName in capital letters
  2. The PName and DOB of the rows where the year of DOB is 2009 or later
  3. Each PName and the remainder when Matches is divided by 7.

Table: PLAYER

PNoPNameGameMatchesAverageDOB
1NishaCricket3539.932007-12-23
2RachnaChess4448.492009-10-21
3MeenalCricket1962.942010-04-10
4NikhilCricket5140.512006-12-17
5HarishHockey2431.152010-08-13
6ZeenatHockey3629.332009-07-23
Answer
(i)
SELECT UCASE(PName) FROM PLAYER;
UCASE(PName)
NISHA
RACHNA
MEENAL
NIKHIL
HARISH
ZEENAT

Explanation: The function UCASE is worked out for every row that is shown.

(ii)
SELECT PName, DOB FROM PLAYER WHERE YEAR(DOB) >= 2009;
PNameDOB
Rachna2009-10-21
Meenal2010-04-10
Harish2010-08-13
Zeenat2009-07-23

Explanation: WHERE keeps only the rows where YEAR(DOB) is at least 2009: 4 of the 6 rows match (Rachna, Meenal, Harish, Zeenat).

(iii)
SELECT PName, MOD(Matches, 7) FROM PLAYER;
PNameMOD(Matches, 7)
Nisha0
Rachna2
Meenal5
Nikhil2
Harish3
Zeenat1

Explanation: The function MOD is worked out for every row that is shown.

C3.27Practice3 marks

Consider the table HOSTEL given below. Write SQL queries to display:

  1. Each SName and the position of the letter 'a' in it
  2. The SName of the rows where the month of DOA is 6
  3. The SName and Room in descending order of Room.

Table: HOSTEL

HNoSNameBlockRoomMessDOA
1ChetanYamuna1643027.922026-06-19
2RohanGanga1342314.262026-12-15
3SwatiKaveri2792306.822025-09-22
4HarishGanga2501867.612025-10-10
5NaveenYamuna1112282.332025-06-13
6AmanGanga1012423.742026-07-10
Answer
(i)
SELECT SName, INSTR(SName, 'a') FROM HOSTEL;
SNameINSTR(SName, "a")
Chetan5
Rohan4
Swati3
Harish2
Naveen2
Aman3

Explanation: The function INSTR is worked out for every row that is shown.

(ii)
SELECT SName FROM HOSTEL WHERE MONTH(DOA) = 6;
SName
Chetan
Naveen

Explanation: WHERE keeps only the rows where MONTH(DOA) is 6: 2 of the 6 rows match (Chetan, Naveen).

(iii)
SELECT SName, Room FROM HOSTEL ORDER BY Room DESC;
SNameRoom
Swati279
Harish250
Chetan164
Rohan134
Naveen111
Aman101

Explanation: ORDER BY Room arranges the result in descending (largest first) order.

C3.28Practice3 marks

Consider the table HOSTEL given below. Write SQL queries to display:

  1. The first three characters of each SName
  2. Each SName and the name of the week day of DOA
  3. The SName that end with the letter 'n'.

Table: HOSTEL

HNoSNameBlockRoomMessDOA
1ChetanYamuna1643027.922026-06-19
2RohanGanga1342314.262026-12-15
3SwatiKaveri2792306.822025-09-22
4HarishGanga2501867.612025-10-10
5NaveenYamuna1112282.332025-06-13
6AmanGanga1012423.742026-07-10
Answer
(i)
SELECT LEFT(SName, 3) FROM HOSTEL;
LEFT(SName, 3)
Che
Roh
Swa
Har
Nav
Ama

Explanation: The function LEFT is worked out for every row that is shown.

(ii)
SELECT SName, DAYNAME(DOA) FROM HOSTEL;
SNameDAYNAME(DOA)
ChetanFriday
RohanTuesday
SwatiMonday
HarishFriday
NaveenFriday
AmanFriday

Explanation: The function DAYNAME is worked out for every row that is shown.

(iii)
SELECT SName FROM HOSTEL WHERE SName LIKE '%n';
SName
Chetan
Rohan
Naveen
Aman

Explanation: WHERE keeps only the rows where SName matches the pattern '%n': 4 of the 6 rows match (Chetan, Rohan, Naveen, Aman). '%n' means the value ends with 'n'.

C3.29Practice3 marks

Consider the table LOAN given below. Write SQL queries to display:

  1. The CName in small letters, of the rows where Type is 'Education'
  2. The CName and StartDate of the rows where the year of StartDate is 2022 or later
  3. Each CName and its Rate rounded to one decimal place.

Table: LOAN

LNoCNameTypeYearsRateStartDate
1DivyaEducation1911.172020-11-18
2SachinHome39.022022-04-01
3NaveenCar129.462023-07-07
4SandeepCar29.922026-03-01
5UmeshHome1010.252021-02-05
6RituHome178.622025-08-06
Answer
(i)
SELECT LOWER(CName) FROM LOAN WHERE Type = 'Education';
LOWER(CName)
divya

Explanation: WHERE keeps only the rows where Type is 'Education': 1 of the 6 rows matches (Divya). The function LOWER is worked out for every row that is shown.

(ii)
SELECT CName, StartDate FROM LOAN WHERE YEAR(StartDate) >= 2022;
CNameStartDate
Sachin2022-04-01
Naveen2023-07-07
Sandeep2026-03-01
Ritu2025-08-06

Explanation: WHERE keeps only the rows where YEAR(StartDate) is at least 2022: 4 of the 6 rows match (Sachin, Naveen, Sandeep, Ritu).

(iii)
SELECT CName, ROUND(Rate, 1) FROM LOAN;
CNameROUND(Rate, 1)
Divya11.2
Sachin9.0
Naveen9.5
Sandeep9.9
Umesh10.3
Ritu8.6

Explanation: The function ROUND is worked out for every row that is shown.

C3.30Practice3 marks

Consider the table LOAN given below. Write SQL queries to display:

  1. The last two characters of each CName
  2. Each CName and the name of the month of StartDate
  3. All the CName in alphabetical order.

Table: LOAN

LNoCNameTypeYearsRateStartDate
1DivyaEducation1911.172020-11-18
2SachinHome39.022022-04-01
3NaveenCar129.462023-07-07
4SandeepCar29.922026-03-01
5UmeshHome1010.252021-02-05
6RituHome178.622025-08-06
Answer
(i)
SELECT RIGHT(CName, 2) FROM LOAN;
RIGHT(CName, 2)
ya
in
en
ep
sh
tu

Explanation: The function RIGHT is worked out for every row that is shown.

(ii)
SELECT CName, MONTHNAME(StartDate) FROM LOAN;
CNameMONTHNAME(StartDate)
DivyaNovember
SachinApril
NaveenJuly
SandeepMarch
UmeshFebruary
RituAugust

Explanation: The function MONTHNAME is worked out for every row that is shown.

(iii)
SELECT CName FROM LOAN ORDER BY CName;
CName
Divya
Naveen
Ritu
Sachin
Sandeep
Umesh

Explanation: ORDER BY CName arranges the result in ascending (smallest first) order.

C3.31Practice3 marks

Consider the table STAFF given below. Write SQL queries to display:

  1. The SName in capital letters
  2. Each SName and the name of the week day of DOJ
  3. Each SName and its Allowance rounded to the nearest whole number.

Table: STAFF

SNoSNamePostPeriodsAllowanceDOJ
1RachnaTGT216326.052023-07-03
2MeenalPGT315316.672023-02-03
3SandeepPGT183601.572015-03-06
4YashPGT256358.032011-05-26
5RituPRT305793.032022-08-12
6FarhanTGT335942.382014-11-17
Answer
(i)
SELECT UCASE(SName) FROM STAFF;
UCASE(SName)
RACHNA
MEENAL
SANDEEP
YASH
RITU
FARHAN

Explanation: The function UCASE is worked out for every row that is shown.

(ii)
SELECT SName, DAYNAME(DOJ) FROM STAFF;
SNameDAYNAME(DOJ)
RachnaMonday
MeenalFriday
SandeepFriday
YashThursday
RituFriday
FarhanMonday

Explanation: The function DAYNAME is worked out for every row that is shown.

(iii)
SELECT SName, ROUND(Allowance) FROM STAFF;
SNameROUND(Allowance)
Rachna6326
Meenal5317
Sandeep3602
Yash6358
Ritu5793
Farhan5942

Explanation: The function ROUND is worked out for every row that is shown.

C3.32Practice3 marks

Consider the table STAFF given below. Write SQL queries to display:

  1. Each SName and the number of characters in it
  2. Each SName and the year of DOJ
  3. The SName and Periods in descending order of Periods.

Table: STAFF

SNoSNamePostPeriodsAllowanceDOJ
1RachnaTGT216326.052023-07-03
2MeenalPGT315316.672023-02-03
3SandeepPGT183601.572015-03-06
4YashPGT256358.032011-05-26
5RituPRT305793.032022-08-12
6FarhanTGT335942.382014-11-17
Answer
(i)
SELECT SName, LENGTH(SName) FROM STAFF;
SNameLENGTH(SName)
Rachna6
Meenal6
Sandeep7
Yash4
Ritu4
Farhan6

Explanation: The function LENGTH is worked out for every row that is shown.

(ii)
SELECT SName, YEAR(DOJ) FROM STAFF;
SNameYEAR(DOJ)
Rachna2023
Meenal2023
Sandeep2015
Yash2011
Ritu2022
Farhan2014

Explanation: The function YEAR is worked out for every row that is shown.

(iii)
SELECT SName, Periods FROM STAFF ORDER BY Periods DESC;
SNamePeriods
Farhan33
Meenal31
Ritu30
Yash25
Rachna21
Sandeep18

Explanation: ORDER BY Periods arranges the result in descending (largest first) order.

C3.33Practice3 marks

Consider the table GARMENT given below. Write SQL queries to display:

  1. The first three characters of each GName
  2. Each GName and the name of the month of Launch
  3. Each GName and the remainder when Stock is divided by 7.

Table: GARMENT

GCodeGNameFabricStockPriceLaunch
10ShirtCotton151434.772025-06-21
11JeansSilk253035.632025-11-15
12KurtaDenim52149.332026-03-28
13JacketCotton101170.282025-10-06
14SareeDenim35787.832025-11-07
15FrockCotton451436.342025-09-11
Answer
(i)
SELECT LEFT(GName, 3) FROM GARMENT;
LEFT(GName, 3)
Shi
Jea
Kur
Jac
Sar
Fro

Explanation: The function LEFT is worked out for every row that is shown.

(ii)
SELECT GName, MONTHNAME(Launch) FROM GARMENT;
GNameMONTHNAME(Launch)
ShirtJune
JeansNovember
KurtaMarch
JacketOctober
SareeNovember
FrockSeptember

Explanation: The function MONTHNAME is worked out for every row that is shown.

(iii)
SELECT GName, MOD(Stock, 7) FROM GARMENT;
GNameMOD(Stock, 7)
Shirt1
Jeans4
Kurta5
Jacket3
Saree0
Frock3

Explanation: The function MOD is worked out for every row that is shown.

C3.34Practice3 marks

Consider the table GARMENT given below. Write SQL queries to display:

  1. Three characters of each GName, starting from the second character
  2. The GName of the rows where the month of Launch is 6
  3. Each GName and its Price rounded to one decimal place.

Table: GARMENT

GCodeGNameFabricStockPriceLaunch
10ShirtCotton151434.772025-06-21
11JeansSilk253035.632025-11-15
12KurtaDenim52149.332026-03-28
13JacketCotton101170.282025-10-06
14SareeDenim35787.832025-11-07
15FrockCotton451436.342025-09-11
Answer
(i)
SELECT MID(GName, 2, 3) FROM GARMENT;
MID(GName, 2, 3)
hir
ean
urt
ack
are
roc

Explanation: The function MID is worked out for every row that is shown.

(ii)
SELECT GName FROM GARMENT WHERE MONTH(Launch) = 6;
GName
Shirt

Explanation: WHERE keeps only the rows where MONTH(Launch) is 6: 1 of the 6 rows matches (Shirt).

(iii)
SELECT GName, ROUND(Price, 1) FROM GARMENT;
GNameROUND(Price, 1)
Shirt1434.8
Jeans3035.6
Kurta2149.3
Jacket1170.3
Saree787.8
Frock1436.3

Explanation: The function ROUND is worked out for every row that is shown.

C3.35Practice3 marks

Consider the table EVENT given below. Write SQL queries to display:

  1. The last two characters of each EName
  2. Each EName and the year of EDate
  3. The EName that end with the letter 'z'.

Table: EVENT

ENoENameHousePointsPrizeEDate
1DebateShivaji302874.632026-07-02
2QuizRaman1002924.742026-07-15
3DanceShivaji602767.112026-02-14
4DramaRaman552300.042026-12-19
5PaintingShivaji954017.092026-08-25
6SingingTagore751901.592026-10-04
Answer
(i)
SELECT RIGHT(EName, 2) FROM EVENT;
RIGHT(EName, 2)
te
iz
ce
ma
ng
ng

Explanation: The function RIGHT is worked out for every row that is shown.

(ii)
SELECT EName, YEAR(EDate) FROM EVENT;
ENameYEAR(EDate)
Debate2026
Quiz2026
Dance2026
Drama2026
Painting2026
Singing2026

Explanation: The function YEAR is worked out for every row that is shown.

(iii)
SELECT EName FROM EVENT WHERE EName LIKE '%z';
EName
Quiz

Explanation: WHERE keeps only the rows where EName matches the pattern '%z': 1 of the 6 rows matches (Quiz). '%z' means the value ends with 'z'.

C3.36Practice3 marks

Consider the table EVENT given below. Write SQL queries to display:

  1. Each EName and the position of the letter 'a' in it
  2. The EName and EDate of the rows where the year of EDate is 2026 or later
  3. Each EName and its Prize rounded to the nearest whole number.

Table: EVENT

ENoENameHousePointsPrizeEDate
1DebateShivaji302874.632026-07-02
2QuizRaman1002924.742026-07-15
3DanceShivaji602767.112026-02-14
4DramaRaman552300.042026-12-19
5PaintingShivaji954017.092026-08-25
6SingingTagore751901.592026-10-04
Answer
(i)
SELECT EName, INSTR(EName, 'a') FROM EVENT;
ENameINSTR(EName, "a")
Debate4
Quiz0
Dance2
Drama3
Painting2
Singing0

Explanation: The function INSTR is worked out for every row that is shown.

(ii)
SELECT EName, EDate FROM EVENT WHERE YEAR(EDate) >= 2026;
ENameEDate
Debate2026-07-02
Quiz2026-07-15
Dance2026-02-14
Drama2026-12-19
Painting2026-08-25
Singing2026-10-04

Explanation: WHERE keeps only the rows where YEAR(EDate) is at least 2026: 6 of the 6 rows match (Debate, Quiz, Dance, Drama, Painting, Singing).

(iii)
SELECT EName, ROUND(Prize) FROM EVENT;
ENameROUND(Prize)
Debate2875
Quiz2925
Dance2767
Drama2300
Painting4017
Singing1902

Explanation: The function ROUND is worked out for every row that is shown.

C3.37Practice3 marks

Consider the table TRAIN given below. Write SQL queries to display:

  1. Each TName and the number of characters in it
  2. The TName of the rows where the month of StartDate is 2
  3. All the TName in alphabetical order.

Table: TRAIN

TNoTNameZoneCoachesFareStartDate
12001RajdhaniNorthern172750.732017-02-22
12002ShatabdiSouthern242125.092024-03-03
12003DurontoNorthern132277.832024-03-16
12004Garib RathSouthern103012.732021-04-10
12005TejasWestern182091.892015-02-17
12006Vande BharatNorthern201399.692020-04-10
Answer
(i)
SELECT TName, LENGTH(TName) FROM TRAIN;
TNameLENGTH(TName)
Rajdhani8
Shatabdi8
Duronto7
Garib Rath10
Tejas5
Vande Bharat12

Explanation: The function LENGTH is worked out for every row that is shown.

(ii)
SELECT TName FROM TRAIN WHERE MONTH(StartDate) = 2;
TName
Rajdhani
Tejas

Explanation: WHERE keeps only the rows where MONTH(StartDate) is 2: 2 of the 6 rows match (Rajdhani, Tejas).

(iii)
SELECT TName FROM TRAIN ORDER BY TName;
TName
Duronto
Garib Rath
Rajdhani
Shatabdi
Tejas
Vande Bharat

Explanation: ORDER BY TName arranges the result in ascending (smallest first) order.

C3.38Practice3 marks

Consider the table TRAIN given below. Write SQL queries to display:

  1. The TName in small letters, of the rows where Zone is 'Northern'
  2. Each TName and the name of the week day of StartDate
  3. Each TName and the remainder when Coaches is divided by 7.

Table: TRAIN

TNoTNameZoneCoachesFareStartDate
12001RajdhaniNorthern172750.732017-02-22
12002ShatabdiSouthern242125.092024-03-03
12003DurontoNorthern132277.832024-03-16
12004Garib RathSouthern103012.732021-04-10
12005TejasWestern182091.892015-02-17
12006Vande BharatNorthern201399.692020-04-10
Answer
(i)
SELECT LOWER(TName) FROM TRAIN WHERE Zone = 'Northern';
LOWER(TName)
rajdhani
duronto
vande bharat

Explanation: WHERE keeps only the rows where Zone is 'Northern': 3 of the 6 rows match (Rajdhani, Duronto, Vande Bharat). The function LOWER is worked out for every row that is shown.

(ii)
SELECT TName, DAYNAME(StartDate) FROM TRAIN;
TNameDAYNAME(StartDate)
RajdhaniWednesday
ShatabdiSunday
DurontoSaturday
Garib RathSaturday
TejasTuesday
Vande BharatFriday

Explanation: The function DAYNAME is worked out for every row that is shown.

(iii)
SELECT TName, MOD(Coaches, 7) FROM TRAIN;
TNameMOD(Coaches, 7)
Rajdhani3
Shatabdi3
Duronto6
Garib Rath3
Tejas4
Vande Bharat6

Explanation: The function MOD is worked out for every row that is shown.

C3.39Practice3 marks

Consider the table LAPTOP given below. Write SQL queries to display:

  1. Three characters of each Model, starting from the second character
  2. The Model and Launch of the rows where the year of Launch is 2026 or later
  3. The Model and RAM in descending order of RAM.

Table: LAPTOP

LNoModelBrandRAMPriceLaunch
1Astra 5Orbit1686696.752026-11-10
2Bolt XZenit2884541.932025-10-22
3Comet ProZenit3284965.492026-03-21
4Dyna AirZenit2470706.772025-05-13
5Eon LiteOrbit1241551.162026-07-03
6Flex 14Nova442044.122026-11-12
Answer
(i)
SELECT MID(Model, 2, 3) FROM LAPTOP;
MID(Model, 2, 3)
str
olt
ome
yna
on
lex

Explanation: The function MID is worked out for every row that is shown.

(ii)
SELECT Model, Launch FROM LAPTOP WHERE YEAR(Launch) >= 2026;
ModelLaunch
Astra 52026-11-10
Comet Pro2026-03-21
Eon Lite2026-07-03
Flex 142026-11-12

Explanation: WHERE keeps only the rows where YEAR(Launch) is at least 2026: 4 of the 6 rows match (Astra 5, Comet Pro, Eon Lite, Flex 14).

(iii)
SELECT Model, RAM FROM LAPTOP ORDER BY RAM DESC;
ModelRAM
Comet Pro32
Bolt X28
Dyna Air24
Astra 516
Eon Lite12
Flex 144

Explanation: ORDER BY RAM arranges the result in descending (largest first) order.

C3.40Practice3 marks

Consider the table LAPTOP given below. Write SQL queries to display:

  1. The Model in capital letters
  2. Each Model and the name of the month of Launch
  3. The Model that end with the letter 'X'.

Table: LAPTOP

LNoModelBrandRAMPriceLaunch
1Astra 5Orbit1686696.752026-11-10
2Bolt XZenit2884541.932025-10-22
3Comet ProZenit3284965.492026-03-21
4Dyna AirZenit2470706.772025-05-13
5Eon LiteOrbit1241551.162026-07-03
6Flex 14Nova442044.122026-11-12
Answer
(i)
SELECT UCASE(Model) FROM LAPTOP;
UCASE(Model)
ASTRA 5
BOLT X
COMET PRO
DYNA AIR
EON LITE
FLEX 14

Explanation: The function UCASE is worked out for every row that is shown.

(ii)
SELECT Model, MONTHNAME(Launch) FROM LAPTOP;
ModelMONTHNAME(Launch)
Astra 5November
Bolt XOctober
Comet ProMarch
Dyna AirMay
Eon LiteJuly
Flex 14November

Explanation: The function MONTHNAME is worked out for every row that is shown.

(iii)
SELECT Model FROM LAPTOP WHERE Model LIKE '%X';
Model
Bolt X

Explanation: WHERE keeps only the rows where Model matches the pattern '%X': 1 of the 6 rows matches (Bolt X). '%X' means the value ends with 'X'.

C3.41Practice3 marks

Consider the table CLUB given below. Write SQL queries to display:

  1. Each MName and the position of the letter 'a' in it
  2. Each MName and the name of the week day of DOJ
  3. Each MName and its Fee rounded to one decimal place.

Table: CLUB

CNoMNameActivityAgeFeeDOJ
1FarhanTennis271058.822026-12-05
2BhavnaSwimming422296.532023-02-14
3LokeshYoga16805.042023-11-02
4SimranYoga361759.992026-03-27
5SachinTennis173396.682026-04-14
6MohitYoga561552.632023-06-09
Answer
(i)
SELECT MName, INSTR(MName, 'a') FROM CLUB;
MNameINSTR(MName, "a")
Farhan2
Bhavna3
Lokesh0
Simran5
Sachin2
Mohit0

Explanation: The function INSTR is worked out for every row that is shown.

(ii)
SELECT MName, DAYNAME(DOJ) FROM CLUB;
MNameDAYNAME(DOJ)
FarhanSaturday
BhavnaTuesday
LokeshThursday
SimranFriday
SachinTuesday
MohitFriday

Explanation: The function DAYNAME is worked out for every row that is shown.

(iii)
SELECT MName, ROUND(Fee, 1) FROM CLUB;
MNameROUND(Fee, 1)
Farhan1058.8
Bhavna2296.5
Lokesh805.0
Simran1760.0
Sachin3396.7
Mohit1552.6

Explanation: The function ROUND is worked out for every row that is shown.

C3.42Practice3 marks

Consider the table CLUB given below. Write SQL queries to display:

  1. The first three characters of each MName
  2. Each MName and the year of DOJ
  3. All the MName in alphabetical order.

Table: CLUB

CNoMNameActivityAgeFeeDOJ
1FarhanTennis271058.822026-12-05
2BhavnaSwimming422296.532023-02-14
3LokeshYoga16805.042023-11-02
4SimranYoga361759.992026-03-27
5SachinTennis173396.682026-04-14
6MohitYoga561552.632023-06-09
Answer
(i)
SELECT LEFT(MName, 3) FROM CLUB;
LEFT(MName, 3)
Far
Bha
Lok
Sim
Sac
Moh

Explanation: The function LEFT is worked out for every row that is shown.

(ii)
SELECT MName, YEAR(DOJ) FROM CLUB;
MNameYEAR(DOJ)
Farhan2026
Bhavna2023
Lokesh2023
Simran2026
Sachin2026
Mohit2023

Explanation: The function YEAR is worked out for every row that is shown.

(iii)
SELECT MName FROM CLUB ORDER BY MName;
MName
Bhavna
Farhan
Lokesh
Mohit
Sachin
Simran

Explanation: ORDER BY MName arranges the result in ascending (smallest first) order.

C3.43Practice3 marks

Consider the table FARM given below. Write SQL queries to display:

  1. The Farmer in small letters, of the rows where Crop is 'Maize'
  2. Each Farmer and the name of the month of SowDate
  3. Each Farmer and its Yield rounded to the nearest whole number.

Table: FARM

FNoFarmerCropAcresYieldSowDate
1ArjunMaize3934.422026-12-19
2AnitaWheat940.162025-07-19
3IshaRice1124.932026-02-23
4SonalWheat1646.042025-06-25
5VandanaRice641.022026-10-11
6HarishWheat2323.822025-11-28
Answer
(i)
SELECT LOWER(Farmer) FROM FARM WHERE Crop = 'Maize';
LOWER(Farmer)
arjun

Explanation: WHERE keeps only the rows where Crop is 'Maize': 1 of the 6 rows matches (Arjun). The function LOWER is worked out for every row that is shown.

(ii)
SELECT Farmer, MONTHNAME(SowDate) FROM FARM;
FarmerMONTHNAME(SowDate)
ArjunDecember
AnitaJuly
IshaFebruary
SonalJune
VandanaOctober
HarishNovember

Explanation: The function MONTHNAME is worked out for every row that is shown.

(iii)
SELECT Farmer, ROUND(Yield) FROM FARM;
FarmerROUND(Yield)
Arjun34
Anita40
Isha25
Sonal46
Vandana41
Harish24

Explanation: The function ROUND is worked out for every row that is shown.

C3.44Practice3 marks

Consider the table FARM given below. Write SQL queries to display:

  1. The last two characters of each Farmer
  2. The Farmer of the rows where the month of SowDate is 12
  3. The Farmer and Acres in descending order of Acres.

Table: FARM

FNoFarmerCropAcresYieldSowDate
1ArjunMaize3934.422026-12-19
2AnitaWheat940.162025-07-19
3IshaRice1124.932026-02-23
4SonalWheat1646.042025-06-25
5VandanaRice641.022026-10-11
6HarishWheat2323.822025-11-28
Answer
(i)
SELECT RIGHT(Farmer, 2) FROM FARM;
RIGHT(Farmer, 2)
un
ta
ha
al
na
sh

Explanation: The function RIGHT is worked out for every row that is shown.

(ii)
SELECT Farmer FROM FARM WHERE MONTH(SowDate) = 12;
Farmer
Arjun

Explanation: WHERE keeps only the rows where MONTH(SowDate) is 12: 1 of the 6 rows matches (Arjun).

(iii)
SELECT Farmer, Acres FROM FARM ORDER BY Acres DESC;
FarmerAcres
Arjun39
Harish23
Sonal16
Isha11
Anita9
Vandana6

Explanation: ORDER BY Acres arranges the result in descending (largest first) order.

C4Output of SQL functions3 marks · 49 questions
C4.1SQP 2026-273 marks

Write the output of the following SQL queries.

(i) SELECT POWER(MOD(13, 5), 2);
(ii) SELECT UCASE(MID("Digital India", 9, 5));
(iii) SELECT LENGTH(TRIM(" Informatics "));
Answer
(i)
SELECT POWER(MOD(13, 5), 2);

Output: 9

Explanation: Working: MOD(13, 5) = 3 → POWER(3, 2) = 9.

(ii)
SELECT UCASE(MID('Digital India', 9, 5));

Output: INDIA

Explanation: Working: MID('Digital India', 9, 5) = 'India' → UCASE('India') = 'INDIA'.

(iii)
SELECT LENGTH(TRIM(' Informatics '));

Output: 11

Explanation: Working: TRIM(' Informatics ') = 'Informatics' → LENGTH('Informatics') = 11.

C4.2Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(26, 7) + POWER(2, 2);
(ii) SELECT LENGTH('New Delhi') + INSTR('New Delhi', 'l');
(iii) SELECT LENGTH(TRIM('   Data Science  '));
Answer
(i)
SELECT MOD(26, 7) + POWER(2, 2);

Output: 9

Explanation: Working: MOD(26, 7) = 5 → POWER(2, 2) = 4.

(ii)
SELECT LENGTH('New Delhi') + INSTR('New Delhi', 'l');

Output: 16

Explanation: Working: LENGTH('New Delhi') = 9 → INSTR('New Delhi', 'l') = 7.

(iii)
SELECT LENGTH(TRIM('   Data Science  '));

Output: 12

Explanation: Working: TRIM(' Data Science ') = 'Data Science' → LENGTH('Data Science') = 12.

C4.3Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(278.945, 1);
(ii) SELECT MID('Histogram', 2, 2);
(iii) SELECT DAY('2025-05-09');
Answer
(i)
SELECT ROUND(278.945, 1);

Output: 278.9

Explanation: Working: ROUND(278.945, 1) = 278.9.

(ii)
SELECT MID('Histogram', 2, 2);

Output: is

Explanation: Working: MID('Histogram', 2, 2) = 'is'.

(iii)
SELECT DAY('2025-05-09');

Output: 9

Explanation: Working: DAY('2025-05-09') = 9.

C4.4Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(94, 8);
(ii) SELECT UPPER('Practices');
(iii) SELECT LENGTH(MONTHNAME('2027-03-05'));
Answer
(i)
SELECT MOD(94, 8);

Output: 6

Explanation: Working: MOD(94, 8) = 6.

(ii)
SELECT UPPER('Practices');

Output: PRACTICES

Explanation: Working: UPPER('Practices') = 'PRACTICES'.

(iii)
SELECT LENGTH(MONTHNAME('2027-03-05'));

Output: 5

Explanation: Working: MONTHNAME('2027-03-05') = 'March' → LENGTH('March') = 5.

C4.5Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(4, 4);
(ii) SELECT INSTR('Welcome', 'el');
(iii) SELECT RIGHT('Board Exam', 2);
Answer
(i)
SELECT POWER(4, 4);

Output: 256

Explanation: Working: POWER(4, 4) = 256.

(ii)
SELECT INSTR('Welcome', 'el');

Output: 2

Explanation: Working: INSTR('Welcome', 'el') = 2.

(iii)
SELECT RIGHT('Board Exam', 2);

Output: am

Explanation: Working: RIGHT('Board Exam', 2) = 'am'.

C4.6Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(92.728, 1);
(ii) SELECT UPPER(RIGHT('Education', 3));
(iii) SELECT DAY('2025-01-04');
Answer
(i)
SELECT ROUND(92.728, 1);

Output: 92.7

Explanation: Working: ROUND(92.728, 1) = 92.7.

(ii)
SELECT UPPER(RIGHT('Education', 3));

Output: ION

Explanation: Working: RIGHT('Education', 3) = 'ion' → UPPER('ion') = 'ION'.

(iii)
SELECT DAY('2025-01-04');

Output: 4

Explanation: Working: DAY('2025-01-04') = 4.

C4.7Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(38, 6) + POWER(3, 2);
(ii) SELECT LEFT('Practices', 7);
(iii) SELECT LENGTH('Histogram');
Answer
(i)
SELECT MOD(38, 6) + POWER(3, 2);

Output: 11

Explanation: Working: MOD(38, 6) = 2 → POWER(3, 2) = 9.

(ii)
SELECT LEFT('Practices', 7);

Output: Practic

Explanation: Working: LEFT('Practices', 7) = 'Practic'.

(iii)
SELECT LENGTH('Histogram');

Output: 9

Explanation: Working: LENGTH('Histogram') = 9.

C4.8Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(63, 9);
(ii) SELECT LCASE(LEFT('DataFrame', 3));
(iii) SELECT MOD(YEAR('2025-06-07'), 100);
Answer
(i)
SELECT MOD(63, 9);

Output: 0

Explanation: Working: MOD(63, 9) = 0.

(ii)
SELECT LCASE(LEFT('DataFrame', 3));

Output: dat

Explanation: Working: LEFT('DataFrame', 3) = 'Dat' → LCASE('Dat') = 'dat'.

(iii)
SELECT MOD(YEAR('2025-06-07'), 100);

Output: 25

Explanation: Working: YEAR('2025-06-07') = 2025 → MOD(2025, 100) = 25.

C4.9Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(463.276);
(ii) SELECT RIGHT('Informatics', 6);
(iii) SELECT LENGTH(LTRIM(' Network '));
Answer
(i)
SELECT ROUND(463.276);

Output: 463

Explanation: Working: ROUND(463.276) = 463.

(ii)
SELECT RIGHT('Informatics', 6);

Output: matics

Explanation: Working: RIGHT('Informatics', 6) = 'matics'.

(iii)
SELECT LENGTH(LTRIM(' Network '));

Output: 8

Explanation: Working: LTRIM(' Network ') = 'Network ' → LENGTH('Network ') = 8.

C4.10Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(POWER(3, 3), 7);
(ii) SELECT UCASE(MID('Data Science', 4, 4));
(iii) SELECT LENGTH(LTRIM('   Digital India '));
Answer
(i)
SELECT MOD(POWER(3, 3), 7);

Output: 6

Explanation: Working: POWER(3, 3) = 27 → MOD(27, 7) = 6.

(ii)
SELECT UCASE(MID('Data Science', 4, 4));

Output: A SC

Explanation: Working: MID('Data Science', 4, 4) = 'a Sc' → UCASE('a Sc') = 'A SC'.

(iii)
SELECT LENGTH(LTRIM('   Digital India '));

Output: 14

Explanation: Working: LTRIM(' Digital India ') = 'Digital India ' → LENGTH('Digital India ') = 14.

C4.11Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(230.832, -1);
(ii) SELECT SUBSTRING('Computer', 4, 4);
(iii) SELECT MONTHNAME('2026-12-16');
Answer
(i)
SELECT ROUND(230.832, -1);

Output: 230

Explanation: Working: ROUND(230.832, -1) = 230.

(ii)
SELECT SUBSTRING('Computer', 4, 4);

Output: pute

Explanation: Working: SUBSTRING('Computer', 4, 4) = 'pute'.

(iii)
SELECT MONTHNAME('2026-12-16');

Output: December

Explanation: Working: MONTHNAME('2026-12-16') = 'December'.

C4.12Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(65, 8);
(ii) SELECT LCASE('New Delhi');
(iii) SELECT YEAR('2024-11-04') - 2002;
Answer
(i)
SELECT MOD(65, 8);

Output: 1

Explanation: Working: MOD(65, 8) = 1.

(ii)
SELECT LCASE('New Delhi');

Output: new delhi

Explanation: Working: LCASE('New Delhi') = 'new delhi'.

(iii)
SELECT YEAR('2024-11-04') - 2002;

Output: 22

Explanation: Working: YEAR('2024-11-04') = 2024.

C4.13Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(2, 3);
(ii) SELECT INSTR('Vidyalaya', 'y');
(iii) SELECT RIGHT('DataFrame', 4);
Answer
(i)
SELECT POWER(2, 3);

Output: 8

Explanation: Working: POWER(2, 3) = 8.

(ii)
SELECT INSTR('Vidyalaya', 'y');

Output: 4

Explanation: Working: INSTR('Vidyalaya', 'y') = 4.

(iii)
SELECT RIGHT('DataFrame', 4);

Output: rame

Explanation: Working: RIGHT('DataFrame', 4) = 'rame'.

C4.14Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(327.827, 1);
(ii) SELECT LCASE(LEFT('Matplotlib', 4));
(iii) SELECT DAYNAME('2026-07-08');
Answer
(i)
SELECT ROUND(327.827, 1);

Output: 327.8

Explanation: Working: ROUND(327.827, 1) = 327.8.

(ii)
SELECT LCASE(LEFT('Matplotlib', 4));

Output: matp

Explanation: Working: LEFT('Matplotlib', 4) = 'Matp' → LCASE('Matp') = 'matp'.

(iii)
SELECT DAYNAME('2026-07-08');

Output: Wednesday

Explanation: Working: DAYNAME('2026-07-08') = 'Wednesday'.

C4.15Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(POWER(3, 2), 5);
(ii) SELECT LEFT('Structured', 3);
(iii) SELECT LENGTH('Database');
Answer
(i)
SELECT MOD(POWER(3, 2), 5);

Output: 4

Explanation: Working: POWER(3, 2) = 9 → MOD(9, 5) = 4.

(ii)
SELECT LEFT('Structured', 3);

Output: Str

Explanation: Working: LEFT('Structured', 3) = 'Str'.

(iii)
SELECT LENGTH('Database');

Output: 8

Explanation: Working: LENGTH('Database') = 8.

C4.16Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(66, 5);
(ii) SELECT LEFT(RIGHT('Python', 6), 2);
(iii) SELECT MOD(YEAR('2024-01-22'), 100);
Answer
(i)
SELECT MOD(66, 5);

Output: 1

Explanation: Working: MOD(66, 5) = 1.

(ii)
SELECT LEFT(RIGHT('Python', 6), 2);

Output: Py

Explanation: Working: RIGHT('Python', 6) = 'Python' → LEFT('Python', 2) = 'Py'.

(iii)
SELECT MOD(YEAR('2024-01-22'), 100);

Output: 24

Explanation: Working: YEAR('2024-01-22') = 2024 → MOD(2024, 100) = 24.

C4.17Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(669.557, 1);
(ii) SELECT RIGHT('Sample Paper', 10);
(iii) SELECT LENGTH(LTRIM(' New Delhi '));
Answer
(i)
SELECT ROUND(669.557, 1);

Output: 669.6

Explanation: Working: ROUND(669.557, 1) = 669.6.

(ii)
SELECT RIGHT('Sample Paper', 10);

Output: mple Paper

Explanation: Working: RIGHT('Sample Paper', 10) = 'mple Paper'.

(iii)
SELECT LENGTH(LTRIM(' New Delhi '));

Output: 10

Explanation: Working: LTRIM(' New Delhi ') = 'New Delhi ' → LENGTH('New Delhi ') = 10.

C4.18Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(MOD(39, 8), 3);
(ii) SELECT UCASE(MID('New Delhi', 2, 2));
(iii) SELECT LENGTH(TRIM('  Open Source '));
Answer
(i)
SELECT POWER(MOD(39, 8), 3);

Output: 343

Explanation: Working: MOD(39, 8) = 7 → POWER(7, 3) = 343.

(ii)
SELECT UCASE(MID('New Delhi', 2, 2));

Output: EW

Explanation: Working: MID('New Delhi', 2, 2) = 'ew' → UCASE('ew') = 'EW'.

(iii)
SELECT LENGTH(TRIM('  Open Source '));

Output: 11

Explanation: Working: TRIM(' Open Source ') = 'Open Source' → LENGTH('Open Source') = 11.

C4.19Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(403.465, 1);
(ii) SELECT SUBSTR('Web Server', 4, 5);
(iii) SELECT MONTHNAME('2027-11-11');
Answer
(i)
SELECT ROUND(403.465, 1);

Output: 403.5

Explanation: Working: ROUND(403.465, 1) = 403.5.

(ii)
SELECT SUBSTR('Web Server', 4, 5);

Output: Serv

Explanation: Working: SUBSTR('Web Server', 4, 5) = ' Serv'.

(iii)
SELECT MONTHNAME('2027-11-11');

Output: November

Explanation: Working: MONTHNAME('2027-11-11') = 'November'.

C4.20Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(92, 9);
(ii) SELECT LCASE('Knowledge');
(iii) SELECT LEFT(MONTHNAME('2024-10-06'), 3);
Answer
(i)
SELECT MOD(92, 9);

Output: 2

Explanation: Working: MOD(92, 9) = 2.

(ii)
SELECT LCASE('Knowledge');

Output: knowledge

Explanation: Working: LCASE('Knowledge') = 'knowledge'.

(iii)
SELECT LEFT(MONTHNAME('2024-10-06'), 3);

Output: Oct

Explanation: Working: MONTHNAME('2024-10-06') = 'October' → LEFT('October', 3) = 'Oct'.

C4.21Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(3, 2);
(ii) SELECT INSTR('Education', 'ti');
(iii) SELECT RIGHT('Network', 4);
Answer
(i)
SELECT POWER(3, 2);

Output: 9

Explanation: Working: POWER(3, 2) = 9.

(ii)
SELECT INSTR('Education', 'ti');

Output: 6

Explanation: Working: INSTR('Education', 'ti') = 6.

(iii)
SELECT RIGHT('Network', 4);

Output: work

Explanation: Working: RIGHT('Network', 4) = 'work'.

C4.22Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(137.919, 2);
(ii) SELECT UPPER(RIGHT('Welcome', 4));
(iii) SELECT YEAR('2027-09-01');
Answer
(i)
SELECT ROUND(137.919, 2);

Output: 137.92

Explanation: Working: ROUND(137.919, 2) = 137.92.

(ii)
SELECT UPPER(RIGHT('Welcome', 4));

Output: COME

Explanation: Working: RIGHT('Welcome', 4) = 'come' → UPPER('come') = 'COME'.

(iii)
SELECT YEAR('2027-09-01');

Output: 2027

Explanation: Working: YEAR('2027-09-01') = 2027.

C4.23Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(MOD(32, 7), 2);
(ii) SELECT LEFT('New Delhi', 6);
(iii) SELECT LENGTH('Pandas');
Answer
(i)
SELECT POWER(MOD(32, 7), 2);

Output: 16

Explanation: Working: MOD(32, 7) = 4 → POWER(4, 2) = 16.

(ii)
SELECT LEFT('New Delhi', 6);

Output: New De

Explanation: Working: LEFT('New Delhi', 6) = 'New De'.

(iii)
SELECT LENGTH('Pandas');

Output: 6

Explanation: Working: LENGTH('Pandas') = 6.

C4.24Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(61, 5);
(ii) SELECT LENGTH(RIGHT('Web Server', 2));
(iii) SELECT LENGTH(MONTHNAME('2027-05-04'));
Answer
(i)
SELECT MOD(61, 5);

Output: 1

Explanation: Working: MOD(61, 5) = 1.

(ii)
SELECT LENGTH(RIGHT('Web Server', 2));

Output: 2

Explanation: Working: RIGHT('Web Server', 2) = 'er' → LENGTH('er') = 2.

(iii)
SELECT LENGTH(MONTHNAME('2027-05-04'));

Output: 3

Explanation: Working: MONTHNAME('2027-05-04') = 'May' → LENGTH('May') = 3.

C4.25Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(429.881, 2);
(ii) SELECT RIGHT('Vidyalaya', 7);
(iii) SELECT LENGTH(LTRIM(' Database  '));
Answer
(i)
SELECT ROUND(429.881, 2);

Output: 429.88

Explanation: Working: ROUND(429.881, 2) = 429.88.

(ii)
SELECT RIGHT('Vidyalaya', 7);

Output: dyalaya

Explanation: Working: RIGHT('Vidyalaya', 7) = 'dyalaya'.

(iii)
SELECT LENGTH(LTRIM(' Database  '));

Output: 10

Explanation: Working: LTRIM(' Database ') = 'Database ' → LENGTH('Database ') = 10.

C4.26Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(MOD(30, 8), 3);
(ii) SELECT UPPER(RIGHT('Informatics', 4));
(iii) SELECT LENGTH(TRIM('  Python   '));
Answer
(i)
SELECT POWER(MOD(30, 8), 3);

Output: 216

Explanation: Working: MOD(30, 8) = 6 → POWER(6, 3) = 216.

(ii)
SELECT UPPER(RIGHT('Informatics', 4));

Output: TICS

Explanation: Working: RIGHT('Informatics', 4) = 'tics' → UPPER('tics') = 'TICS'.

(iii)
SELECT LENGTH(TRIM('  Python   '));

Output: 6

Explanation: Working: TRIM(' Python ') = 'Python' → LENGTH('Python') = 6.

C4.27Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(726.417, 0);
(ii) SELECT MID('Python', 2, 3);
(iii) SELECT MONTH('2026-05-05');
Answer
(i)
SELECT ROUND(726.417, 0);

Output: 726

Explanation: Working: ROUND(726.417, 0) = 726.

(ii)
SELECT MID('Python', 2, 3);

Output: yth

Explanation: Working: MID('Python', 2, 3) = 'yth'.

(iii)
SELECT MONTH('2026-05-05');

Output: 5

Explanation: Working: MONTH('2026-05-05') = 5.

C4.28Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(33, 7);
(ii) SELECT LOWER('Sample Paper');
(iii) SELECT LEFT(MONTHNAME('2025-09-27'), 3);
Answer
(i)
SELECT MOD(33, 7);

Output: 5

Explanation: Working: MOD(33, 7) = 5.

(ii)
SELECT LOWER('Sample Paper');

Output: sample paper

Explanation: Working: LOWER('Sample Paper') = 'sample paper'.

(iii)
SELECT LEFT(MONTHNAME('2025-09-27'), 3);

Output: Sep

Explanation: Working: MONTHNAME('2025-09-27') = 'September' → LEFT('September', 3) = 'Sep'.

C4.29Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(3, 4);
(ii) SELECT INSTR('Knowledge', 'g');
(iii) SELECT RIGHT('Kendriya', 4);
Answer
(i)
SELECT POWER(3, 4);

Output: 81

Explanation: Working: POWER(3, 4) = 81.

(ii)
SELECT INSTR('Knowledge', 'g');

Output: 8

Explanation: Working: INSTR('Knowledge', 'g') = 8.

(iii)
SELECT RIGHT('Kendriya', 4);

Output: riya

Explanation: Working: RIGHT('Kendriya', 4) = 'riya'.

C4.30Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(158.667, 2);
(ii) SELECT INSTR(UCASE('Welcome'), 'OM');
(iii) SELECT MONTHNAME('2024-12-18');
Answer
(i)
SELECT ROUND(158.667, 2);

Output: 158.67

Explanation: Working: ROUND(158.667, 2) = 158.67.

(ii)
SELECT INSTR(UCASE('Welcome'), 'OM');

Output: 5

Explanation: Working: UCASE('Welcome') = 'WELCOME' → INSTR('WELCOME', 'OM') = 5.

(iii)
SELECT MONTHNAME('2024-12-18');

Output: December

Explanation: Working: MONTHNAME('2024-12-18') = 'December'.

C4.31Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(POWER(3, 2), 7);
(ii) SELECT LEFT('Network', 5);
(iii) SELECT LENGTH('Structured');
Answer
(i)
SELECT MOD(POWER(3, 2), 7);

Output: 2

Explanation: Working: POWER(3, 2) = 9 → MOD(9, 7) = 2.

(ii)
SELECT LEFT('Network', 5);

Output: Netwo

Explanation: Working: LEFT('Network', 5) = 'Netwo'.

(iii)
SELECT LENGTH('Structured');

Output: 10

Explanation: Working: LENGTH('Structured') = 10.

C4.32Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(52, 3);
(ii) SELECT LENGTH('Histogram') + INSTR('Histogram', 'o');
(iii) SELECT MOD(YEAR('2026-01-02'), 100);
Answer
(i)
SELECT MOD(52, 3);

Output: 1

Explanation: Working: MOD(52, 3) = 1.

(ii)
SELECT LENGTH('Histogram') + INSTR('Histogram', 'o');

Output: 14

Explanation: Working: LENGTH('Histogram') = 9 → INSTR('Histogram', 'o') = 5.

(iii)
SELECT MOD(YEAR('2026-01-02'), 100);

Output: 26

Explanation: Working: YEAR('2026-01-02') = 2026 → MOD(2026, 100) = 26.

C4.33Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(140.309, 0);
(ii) SELECT RIGHT('Shalimar Bagh', 10);
(iii) SELECT LENGTH(TRIM('  Network '));
Answer
(i)
SELECT ROUND(140.309, 0);

Output: 140

Explanation: Working: ROUND(140.309, 0) = 140.

(ii)
SELECT RIGHT('Shalimar Bagh', 10);

Output: limar Bagh

Explanation: Working: RIGHT('Shalimar Bagh', 10) = 'limar Bagh'.

(iii)
SELECT LENGTH(TRIM('  Network '));

Output: 7

Explanation: Working: TRIM(' Network ') = 'Network' → LENGTH('Network') = 7.

C4.34Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(MOD(39, 9), 3);
(ii) SELECT UPPER(RIGHT('New Delhi', 4));
(iii) SELECT LENGTH(LTRIM('  Structured '));
Answer
(i)
SELECT POWER(MOD(39, 9), 3);

Output: 27

Explanation: Working: MOD(39, 9) = 3 → POWER(3, 3) = 27.

(ii)
SELECT UPPER(RIGHT('New Delhi', 4));

Output: ELHI

Explanation: Working: RIGHT('New Delhi', 4) = 'elhi' → UPPER('elhi') = 'ELHI'.

(iii)
SELECT LENGTH(LTRIM('  Structured '));

Output: 11

Explanation: Working: LTRIM(' Structured ') = 'Structured ' → LENGTH('Structured ') = 11.

C4.35Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(835.545, 2);
(ii) SELECT SUBSTR('Network', 3, 2);
(iii) SELECT DAYNAME('2027-03-15');
Answer
(i)
SELECT ROUND(835.545, 2);

Output: 835.55

Explanation: Working: ROUND(835.545, 2) = 835.55.

(ii)
SELECT SUBSTR('Network', 3, 2);

Output: tw

Explanation: Working: SUBSTR('Network', 3, 2) = 'tw'.

(iii)
SELECT DAYNAME('2027-03-15');

Output: Monday

Explanation: Working: DAYNAME('2027-03-15') = 'Monday'.

C4.36Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(93, 9);
(ii) SELECT UPPER('Internet');
(iii) SELECT YEAR('2026-07-24') - 2011;
Answer
(i)
SELECT MOD(93, 9);

Output: 3

Explanation: Working: MOD(93, 9) = 3.

(ii)
SELECT UPPER('Internet');

Output: INTERNET

Explanation: Working: UPPER('Internet') = 'INTERNET'.

(iii)
SELECT YEAR('2026-07-24') - 2011;

Output: 15

Explanation: Working: YEAR('2026-07-24') = 2026.

C4.37Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(6, 3);
(ii) SELECT INSTR('Education', 'on');
(iii) SELECT RIGHT('Sample Paper', 2);
Answer
(i)
SELECT POWER(6, 3);

Output: 216

Explanation: Working: POWER(6, 3) = 216.

(ii)
SELECT INSTR('Education', 'on');

Output: 8

Explanation: Working: INSTR('Education', 'on') = 8.

(iii)
SELECT RIGHT('Sample Paper', 2);

Output: er

Explanation: Working: RIGHT('Sample Paper', 2) = 'er'.

C4.38Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(572.024, 0);
(ii) SELECT LCASE(LEFT('Python', 3));
(iii) SELECT YEAR('2025-04-18');
Answer
(i)
SELECT ROUND(572.024, 0);

Output: 572

Explanation: Working: ROUND(572.024, 0) = 572.

(ii)
SELECT LCASE(LEFT('Python', 3));

Output: pyt

Explanation: Working: LEFT('Python', 3) = 'Pyt' → LCASE('Pyt') = 'pyt'.

(iii)
SELECT YEAR('2025-04-18');

Output: 2025

Explanation: Working: YEAR('2025-04-18') = 2025.

C4.39Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(MOD(40, 6), 3);
(ii) SELECT LEFT('Matplotlib', 8);
(iii) SELECT LENGTH('Network');
Answer
(i)
SELECT POWER(MOD(40, 6), 3);

Output: 64

Explanation: Working: MOD(40, 6) = 4 → POWER(4, 3) = 64.

(ii)
SELECT LEFT('Matplotlib', 8);

Output: Matplotl

Explanation: Working: LEFT('Matplotlib', 8) = 'Matplotl'.

(iii)
SELECT LENGTH('Network');

Output: 7

Explanation: Working: LENGTH('Network') = 7.

C4.40Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(37, 3);
(ii) SELECT UCASE(MID('Data Science', 9, 2));
(iii) SELECT DAY('2024-04-26') + MONTH('2024-04-26');
Answer
(i)
SELECT MOD(37, 3);

Output: 1

Explanation: Working: MOD(37, 3) = 1.

(ii)
SELECT UCASE(MID('Data Science', 9, 2));

Output: EN

Explanation: Working: MID('Data Science', 9, 2) = 'en' → UCASE('en') = 'EN'.

(iii)
SELECT DAY('2024-04-26') + MONTH('2024-04-26');

Output: 30

Explanation: Working: DAY('2024-04-26') = 26 → MONTH('2024-04-26') = 4.

C4.41Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(380.954, -1);
(ii) SELECT RIGHT('Welcome', 4);
(iii) SELECT LENGTH(RTRIM('   Sample Paper '));
Answer
(i)
SELECT ROUND(380.954, -1);

Output: 380

Explanation: Working: ROUND(380.954, -1) = 380.

(ii)
SELECT RIGHT('Welcome', 4);

Output: come

Explanation: Working: RIGHT('Welcome', 4) = 'come'.

(iii)
SELECT LENGTH(RTRIM('   Sample Paper '));

Output: 15

Explanation: Working: RTRIM(' Sample Paper ') = ' Sample Paper' → LENGTH(' Sample Paper') = 15.

C4.42Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(POWER(5, 2), 8);
(ii) SELECT INSTR(UCASE('Computer'), 'MP');
(iii) SELECT LENGTH(RTRIM('   Open Source '));
Answer
(i)
SELECT MOD(POWER(5, 2), 8);

Output: 1

Explanation: Working: POWER(5, 2) = 25 → MOD(25, 8) = 1.

(ii)
SELECT INSTR(UCASE('Computer'), 'MP');

Output: 3

Explanation: Working: UCASE('Computer') = 'COMPUTER' → INSTR('COMPUTER', 'MP') = 3.

(iii)
SELECT LENGTH(RTRIM('   Open Source '));

Output: 14

Explanation: Working: RTRIM(' Open Source ') = ' Open Source' → LENGTH(' Open Source') = 14.

C4.43Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(53.931, 2);
(ii) SELECT SUBSTRING('Open Source', 8, 2);
(iii) SELECT MONTHNAME('2026-11-08');
Answer
(i)
SELECT ROUND(53.931, 2);

Output: 53.93

Explanation: Working: ROUND(53.931, 2) = 53.93.

(ii)
SELECT SUBSTRING('Open Source', 8, 2);

Output: ur

Explanation: Working: SUBSTRING('Open Source', 8, 2) = 'ur'.

(iii)
SELECT MONTHNAME('2026-11-08');

Output: November

Explanation: Working: MONTHNAME('2026-11-08') = 'November'.

C4.44Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(25, 3);
(ii) SELECT LCASE('DataFrame');
(iii) SELECT DAY('2027-06-18') + MONTH('2027-06-18');
Answer
(i)
SELECT MOD(25, 3);

Output: 1

Explanation: Working: MOD(25, 3) = 1.

(ii)
SELECT LCASE('DataFrame');

Output: dataframe

Explanation: Working: LCASE('DataFrame') = 'dataframe'.

(iii)
SELECT DAY('2027-06-18') + MONTH('2027-06-18');

Output: 24

Explanation: Working: DAY('2027-06-18') = 18 → MONTH('2027-06-18') = 6.

C4.45Practice3 marks

Write the output of the following SQL queries.

(i) SELECT POWER(7, 3);
(ii) SELECT INSTR('Web Server', 'eb');
(iii) SELECT RIGHT('Python', 4);
Answer
(i)
SELECT POWER(7, 3);

Output: 343

Explanation: Working: POWER(7, 3) = 343.

(ii)
SELECT INSTR('Web Server', 'eb');

Output: 2

Explanation: Working: INSTR('Web Server', 'eb') = 2.

(iii)
SELECT RIGHT('Python', 4);

Output: thon

Explanation: Working: RIGHT('Python', 4) = 'thon'.

C4.46Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(491.164, -1);
(ii) SELECT LENGTH(RIGHT('Shalimar Bagh', 2));
(iii) SELECT MONTH('2026-11-18');
Answer
(i)
SELECT ROUND(491.164, -1);

Output: 490

Explanation: Working: ROUND(491.164, -1) = 490.

(ii)
SELECT LENGTH(RIGHT('Shalimar Bagh', 2));

Output: 2

Explanation: Working: RIGHT('Shalimar Bagh', 2) = 'gh' → LENGTH('gh') = 2.

(iii)
SELECT MONTH('2026-11-18');

Output: 11

Explanation: Working: MONTH('2026-11-18') = 11.

C4.47Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(POWER(6, 2), 9);
(ii) SELECT LEFT('Histogram', 3);
(iii) SELECT LENGTH('Open Source');
Answer
(i)
SELECT MOD(POWER(6, 2), 9);

Output: 0

Explanation: Working: POWER(6, 2) = 36 → MOD(36, 9) = 0.

(ii)
SELECT LEFT('Histogram', 3);

Output: His

Explanation: Working: LEFT('Histogram', 3) = 'His'.

(iii)
SELECT LENGTH('Open Source');

Output: 11

Explanation: Working: LENGTH('Open Source') = 11.

C4.48Practice3 marks

Write the output of the following SQL queries.

(i) SELECT MOD(57, 7);
(ii) SELECT LENGTH('Python') + INSTR('Python', 'h');
(iii) SELECT LEFT(MONTHNAME('2027-10-07'), 3);
Answer
(i)
SELECT MOD(57, 7);

Output: 1

Explanation: Working: MOD(57, 7) = 1.

(ii)
SELECT LENGTH('Python') + INSTR('Python', 'h');

Output: 10

Explanation: Working: LENGTH('Python') = 6 → INSTR('Python', 'h') = 4.

(iii)
SELECT LEFT(MONTHNAME('2027-10-07'), 3);

Output: Oct

Explanation: Working: MONTHNAME('2027-10-07') = 'October' → LEFT('October', 3) = 'Oct'.

C4.49Practice3 marks

Write the output of the following SQL queries.

(i) SELECT ROUND(599.589, 2);
(ii) SELECT RIGHT('Kendriya', 2);
(iii) SELECT LENGTH(TRIM('   Sample Paper '));
Answer
(i)
SELECT ROUND(599.589, 2);

Output: 599.59

Explanation: Working: ROUND(599.589, 2) = 599.59.

(ii)
SELECT RIGHT('Kendriya', 2);

Output: ya

Explanation: Working: RIGHT('Kendriya', 2) = 'ya'.

(iii)
SELECT LENGTH(TRIM('   Sample Paper '));

Output: 12

Explanation: Working: TRIM(' Sample Paper ') = 'Sample Paper' → LENGTH('Sample Paper') = 12.

Section D · 4 marks each

D1Matplotlib chart programs4 marks · 24 questions
D1.1Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Monthly Sales', the X-axis label 'Month', the Y-axis label 'Sales (in thousand Rs)'. Also save the chart as monthly.png.

month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
sales = [90, 65, 35, 45, 80, 25]
Answer
import matplotlib.pyplot as plt
month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
sales = [90, 65, 35, 45, 80, 25]
plt.plot(month, sales, color='blue', marker='o')
plt.title('Monthly Sales')
plt.xlabel('Month')
plt.ylabel('Sales (in thousand Rs)')
plt.savefig('monthly.png')
plt.show()

The chart that this program draws:

line chart: Monthly Sales
D1.2Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Sales of Two Years', the X-axis label 'Month', the Y-axis label 'Sales (in lakh Rs)', a legend.

month = ['Jan', 'Feb', 'Mar', 'Apr', 'May']
y1 = [36, 28, 16, 46, 18]
y2 = [39, 45, 31, 59, 57]
Answer
import matplotlib.pyplot as plt
month = ['Jan', 'Feb', 'Mar', 'Apr', 'May']
y1 = [36, 28, 16, 46, 18]
y2 = [39, 45, 31, 59, 57]
plt.plot(month, y1, label='2026')
plt.plot(month, y2, label='2027')
plt.title('Sales of Two Years')
plt.xlabel('Month')
plt.ylabel('Sales (in lakh Rs)')
plt.legend()
plt.show()

The chart that this program draws:

line chart: Sales of Two Years
D1.3Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Temperature in a Week', the X-axis label 'Day', the Y-axis label 'Temperature (C)'.

day = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
temperature = [30, 34, 37, 24, 40, 26, 39]
Answer
import matplotlib.pyplot as plt
day = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
temperature = [30, 34, 37, 24, 40, 26, 39]
plt.plot(day, temperature, color='red', linestyle='--')
plt.title('Temperature in a Week')
plt.xlabel('Day')
plt.ylabel('Temperature (C)')
plt.show()

The chart that this program draws:

line chart: Temperature in a Week
D1.4Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Runs in Five Matches', the X-axis label 'Match', the Y-axis label 'Runs', a legend. Also save the chart as runs.png.

match = [1, 2, 3, 4, 5]
rohit = [15, 96, 93, 20, 47]
virat = [67, 33, 81, 34, 34]
Answer
import matplotlib.pyplot as plt
match = [1, 2, 3, 4, 5]
rohit = [15, 96, 93, 20, 47]
virat = [67, 33, 81, 34, 34]
plt.plot(match, rohit, label='Rohit')
plt.plot(match, virat, label='Virat')
plt.title('Runs in Five Matches')
plt.xlabel('Match')
plt.ylabel('Runs')
plt.legend()
plt.savefig('runs.png')
plt.show()

The chart that this program draws:

line chart: Runs in Five Matches
D1.5Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Growth of a Plant', the X-axis label 'Week', the Y-axis label 'Height (cm)'.

week = [1, 2, 3, 4, 5, 6]
height = [50, 43, 23, 37, 30, 43]
Answer
import matplotlib.pyplot as plt
week = [1, 2, 3, 4, 5, 6]
height = [50, 43, 23, 37, 30, 43]
plt.plot(week, height, marker='*', color='green')
plt.title('Growth of a Plant')
plt.xlabel('Week')
plt.ylabel('Height (cm)')
plt.show()

The chart that this program draws:

line chart: Growth of a Plant
D1.6Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Students Enrolled', the X-axis label 'Year', the Y-axis label 'Number of Students', a legend.

year = [2022, 2023, 2024, 2025, 2026]
boys = [510, 410, 410, 560, 470]
girls = [580, 290, 360, 520, 360]
Answer
import matplotlib.pyplot as plt
year = [2022, 2023, 2024, 2025, 2026]
boys = [510, 410, 410, 560, 470]
girls = [580, 290, 360, 520, 360]
plt.plot(year, boys, label='Boys')
plt.plot(year, girls, label='Girls')
plt.title('Students Enrolled')
plt.xlabel('Year')
plt.ylabel('Number of Students')
plt.legend()
plt.show()

The chart that this program draws:

line chart: Students Enrolled
D1.7Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Price of Gold', the X-axis label 'Month', the Y-axis label 'Price (in thousand Rs)'. Also save the chart as price.png.

month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
price = [60, 68, 78, 71, 62, 68]
Answer
import matplotlib.pyplot as plt
month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
price = [60, 68, 78, 71, 62, 68]
plt.plot(month, price, color='orange', linewidth=3)
plt.title('Price of Gold')
plt.xlabel('Month')
plt.ylabel('Price (in thousand Rs)')
plt.savefig('price.png')
plt.show()

The chart that this program draws:

line chart: Price of Gold
D1.8Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Website Visitors', the X-axis label 'Day', the Y-axis label 'Visitors'.

day = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
visitors = [700, 150, 300, 550, 550]
Answer
import matplotlib.pyplot as plt
day = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
visitors = [700, 150, 300, 550, 550]
plt.plot(day, visitors, marker='s', linestyle=':')
plt.title('Website Visitors')
plt.xlabel('Day')
plt.ylabel('Visitors')
plt.show()

The chart that this program draws:

line chart: Website Visitors
D1.9Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Rainfall of Two Cities', the X-axis label 'Month', the Y-axis label 'Rainfall (mm)', a legend.

month = ['Jun', 'Jul', 'Aug', 'Sep']
mumbai = [600, 220, 740, 440]
delhi = [100, 290, 60, 140]
Answer
import matplotlib.pyplot as plt
month = ['Jun', 'Jul', 'Aug', 'Sep']
mumbai = [600, 220, 740, 440]
delhi = [100, 290, 60, 140]
plt.plot(month, mumbai, label='Mumbai')
plt.plot(month, delhi, label='Delhi')
plt.title('Rainfall of Two Cities')
plt.xlabel('Month')
plt.ylabel('Rainfall (mm)')
plt.legend()
plt.show()

The chart that this program draws:

line chart: Rainfall of Two Cities
D1.10Practice4 marks

Write a Python program to draw a line chart for the data given below. The chart must have the title 'Marks in Unit Tests', the X-axis label 'Test', the Y-axis label 'Marks', a legend. Also save the chart as marks.png.

test = ['UT1', 'UT2', 'UT3', 'UT4']
asha = [26, 32, 40, 26]
ravi = [22, 15, 39, 34]
Answer
import matplotlib.pyplot as plt
test = ['UT1', 'UT2', 'UT3', 'UT4']
asha = [26, 32, 40, 26]
ravi = [22, 15, 39, 34]
plt.plot(test, asha, label='Asha')
plt.plot(test, ravi, label='Ravi')
plt.title('Marks in Unit Tests')
plt.xlabel('Test')
plt.ylabel('Marks')
plt.legend()
plt.savefig('marks.png')
plt.show()

The chart that this program draws:

line chart: Marks in Unit Tests
D1.11Practice4 marks

Write a Python program to draw a bar chart for the data given below. The chart must have the title 'Students in Four Houses', the X-axis label 'House', the Y-axis label 'Number of Students'.

house = ['Shivaji', 'Tagore', 'Raman', 'Ashoka']
values = [150, 90, 120, 125]
Answer
import matplotlib.pyplot as plt
house = ['Shivaji', 'Tagore', 'Raman', 'Ashoka']
values = [150, 90, 120, 125]
plt.bar(house, values, color='green')
plt.title('Students in Four Houses')
plt.xlabel('House')
plt.ylabel('Number of Students')
plt.show()

The chart that this program draws:

bar chart: Students in Four Houses
D1.12Practice4 marks

Write a Python program to draw a bar chart for the data given below. The chart must have the title 'Books Sold', the X-axis label 'Subject', the Y-axis label 'Number of Books'.

subject = ['English', 'Hindi', 'Maths', 'Science', 'IP']
values = [90, 80, 80, 40, 45]
Answer
import matplotlib.pyplot as plt
subject = ['English', 'Hindi', 'Maths', 'Science', 'IP']
values = [90, 80, 80, 40, 45]
plt.bar(subject, values, color='orange', width=0.5)
plt.title('Books Sold')
plt.xlabel('Subject')
plt.ylabel('Number of Books')
plt.show()

The chart that this program draws:

bar chart: Books Sold
D1.13Practice4 marks

Write a Python program to draw a bar chart for the data given below. The chart must have the title 'Medals Won', the X-axis label 'Country', the Y-axis label 'Medals'. Also save the chart as medals.png.

country = ['India', 'Japan', 'Kenya', 'Brazil']
values = [38, 52, 24, 17]
Answer
import matplotlib.pyplot as plt
country = ['India', 'Japan', 'Kenya', 'Brazil']
values = [38, 52, 24, 17]
plt.bar(country, values, color=['red', 'green', 'blue', 'orange'])
plt.title('Medals Won')
plt.xlabel('Country')
plt.ylabel('Medals')
plt.savefig('medals.png')
plt.show()

The chart that this program draws:

bar chart: Medals Won
D1.14Practice4 marks

Write a Python program to draw a bar chart for the data given below. The chart must have the title 'Result of Class XII', the X-axis label 'Stream', the Y-axis label 'Pass Percentage'.

stream = ['Science', 'Commerce', 'Humanities']
values = [83, 80, 95]
Answer
import matplotlib.pyplot as plt
stream = ['Science', 'Commerce', 'Humanities']
values = [83, 80, 95]
plt.bar(stream, values, color='purple')
plt.title('Result of Class XII')
plt.xlabel('Stream')
plt.ylabel('Pass Percentage')
plt.show()

The chart that this program draws:

bar chart: Result of Class XII
D1.15Practice4 marks

Write a Python program to draw a horizontal bar chart for the data given below. The chart must have the title 'Population of Cities', the X-axis label 'Population (in lakh)', the Y-axis label 'City'.

city = ['Agra', 'Pune', 'Surat', 'Patna']
values = [22, 53, 24, 37]
Answer
import matplotlib.pyplot as plt
city = ['Agra', 'Pune', 'Surat', 'Patna']
values = [22, 53, 24, 37]
plt.barh(city, values, color='teal')
plt.title('Population of Cities')
plt.xlabel('Population (in lakh)')
plt.ylabel('City')
plt.show()

The chart that this program draws:

horizontal bar chart: Population of Cities
D1.16Practice4 marks

Write a Python program to draw a bar chart for the data given below. The chart must have the title 'Daily Sale of a Canteen', the X-axis label 'Item', the Y-axis label 'Plates Sold'. Also save the chart as daily.png.

item = ['Samosa', 'Idli', 'Poha', 'Sandwich']
values = [45, 65, 145, 70]
Answer
import matplotlib.pyplot as plt
item = ['Samosa', 'Idli', 'Poha', 'Sandwich']
values = [45, 65, 145, 70]
plt.bar(item, values, color='brown', edgecolor='black')
plt.title('Daily Sale of a Canteen')
plt.xlabel('Item')
plt.ylabel('Plates Sold')
plt.savefig('daily.png')
plt.show()

The chart that this program draws:

bar chart: Daily Sale of a Canteen
D1.17Practice4 marks

Write a Python program to draw a horizontal bar chart for the data given below. The chart must have the title 'Favourite Sport', the X-axis label 'Number of Students', the Y-axis label 'Sport'.

sport = ['Cricket', 'Football', 'Chess', 'Kabaddi']
values = [53, 47, 52, 22]
Answer
import matplotlib.pyplot as plt
sport = ['Cricket', 'Football', 'Chess', 'Kabaddi']
values = [53, 47, 52, 22]
plt.barh(sport, values, color='red')
plt.title('Favourite Sport')
plt.xlabel('Number of Students')
plt.ylabel('Sport')
plt.show()

The chart that this program draws:

horizontal bar chart: Favourite Sport
D1.18Practice4 marks

Write a Python program to draw a bar chart for the data given below. The chart must have the title 'Trees Planted', the X-axis label 'Class', the Y-axis label 'Number of Trees'.

classes = ['IX', 'X', 'XI', 'XII']
values = [25, 20, 25, 80]
Answer
import matplotlib.pyplot as plt
classes = ['IX', 'X', 'XI', 'XII']
values = [25, 20, 25, 80]
plt.bar(classes, values, color='green', width=0.4)
plt.title('Trees Planted')
plt.xlabel('Class')
plt.ylabel('Number of Trees')
plt.show()

The chart that this program draws:

bar chart: Trees Planted
D1.19Practice4 marks

Write a Python program to draw a histogram for the data given below. The chart must have the title 'Marks of 20 Students', the X-axis label 'Marks', the Y-axis label 'Number of Students', the bin edges [0, 20, 40, 60, 80, 100]. Also save the chart as marks.png.

marks = [91, 68, 21, 28, 57, 11, 63, 15, 59, 79, 65, 68, 63, 41, 60, 90, 89, 12, 46, 55]
Answer
import matplotlib.pyplot as plt
marks = [91, 68, 21, 28, 57, 11, 63, 15, 59, 79, 65, 68, 63, 41, 60, 90, 89, 12, 46, 55]
plt.hist(marks, bins=[0, 20, 40, 60, 80, 100], edgecolor='black')
plt.title('Marks of 20 Students')
plt.xlabel('Marks')
plt.ylabel('Number of Students')
plt.savefig('marks.png')
plt.show()

The chart that this program draws:

histogram: Marks of 20 Students
D1.20Practice4 marks

Write a Python program to draw a histogram for the data given below. The chart must have the title 'Ages of Members', the X-axis label 'Age', the Y-axis label 'Number of Members', 5 intervals (bins).

age = [55, 45, 59, 29, 30, 27, 47, 27, 23, 21, 46, 27, 42, 19, 37, 18, 15, 52]
Answer
import matplotlib.pyplot as plt
age = [55, 45, 59, 29, 30, 27, 47, 27, 23, 21, 46, 27, 42, 19, 37, 18, 15, 52]
plt.hist(age, bins=5, edgecolor='black', color='orange')
plt.title('Ages of Members')
plt.xlabel('Age')
plt.ylabel('Number of Members')
plt.show()

The chart that this program draws:

histogram: Ages of Members
D1.21Practice4 marks

Write a Python program to draw a histogram for the data given below. The chart must have the title 'Heights of Students', the X-axis label 'Height (cm)', the Y-axis label 'Number of Students', 4 intervals (bins).

height = [178, 160, 166, 149, 161, 151, 141, 178, 173, 155, 164, 173, 170, 145, 173, 141]
Answer
import matplotlib.pyplot as plt
height = [178, 160, 166, 149, 161, 151, 141, 178, 173, 155, 164, 173, 170, 145, 173, 141]
plt.hist(height, bins=4, edgecolor='white')
plt.title('Heights of Students')
plt.xlabel('Height (cm)')
plt.ylabel('Number of Students')
plt.show()

The chart that this program draws:

histogram: Heights of Students
D1.22Practice4 marks

Write a Python program to draw a histogram for the data given below. The chart must have the title 'Daily Temperature', the X-axis label 'Temperature (C)', the Y-axis label 'Number of Days', the bin edges [15, 20, 25, 30, 35, 40, 45]. Also save the chart as daily.png.

temperature = [29, 29, 30, 20, 37, 23, 18, 25, 39, 43, 42, 23, 38, 30, 19]
Answer
import matplotlib.pyplot as plt
temperature = [29, 29, 30, 20, 37, 23, 18, 25, 39, 43, 42, 23, 38, 30, 19]
plt.hist(temperature, bins=[15, 20, 25, 30, 35, 40, 45], color='red', edgecolor='black')
plt.title('Daily Temperature')
plt.xlabel('Temperature (C)')
plt.ylabel('Number of Days')
plt.savefig('daily.png')
plt.show()

The chart that this program draws:

histogram: Daily Temperature
D1.23Practice4 marks

Write a Python program to draw a histogram for the data given below. The chart must have the title 'Weights of Parcels', the X-axis label 'Weight (kg)', the Y-axis label 'Number of Parcels', 6 intervals (bins).

weight = [2, 17, 30, 27, 30, 29, 16, 7, 29, 7, 24, 3, 23, 8]
Answer
import matplotlib.pyplot as plt
weight = [2, 17, 30, 27, 30, 29, 16, 7, 29, 7, 24, 3, 23, 8]
plt.hist(weight, bins=6, color='green', edgecolor='black')
plt.title('Weights of Parcels')
plt.xlabel('Weight (kg)')
plt.ylabel('Number of Parcels')
plt.show()

The chart that this program draws:

histogram: Weights of Parcels
D1.24Practice4 marks

Write a Python program to draw a histogram for the data given below. The chart must have the title 'Scores in a Quiz', the X-axis label 'Score', the Y-axis label 'Number of Students', the bin edges [0, 10, 20, 30, 40, 50].

score = [30, 9, 38, 23, 35, 47, 39, 43, 1, 44, 26, 5, 6, 49, 45, 50, 29, 28, 12, 28]
Answer
import matplotlib.pyplot as plt
score = [30, 9, 38, 23, 35, 47, 39, 43, 1, 44, 26, 5, 6, 49, 45, 50, 29, 28, 12, 28]
plt.hist(score, bins=[0, 10, 20, 30, 40, 50], edgecolor='black')
plt.title('Scores in a Quiz')
plt.xlabel('Score')
plt.ylabel('Number of Students')
plt.show()

The chart that this program draws:

histogram: Scores in a Quiz
D2GROUP BY, HAVING and two tables4 marks · 44 questions
D2.1Practice4 marks

Consider the tables PATIENT and DEPARTMENT given below. Write SQL queries to display:

  1. Each Dept and the number of rows in it
  2. Each Dept and its total Days, only for the groups whose total Days is more than 20
  3. The PName of each row with the Doctor of its Dept, using both the tables
  4. The PName, Days and Floor of the rows where Days is more than 7, using both the tables.

Table: PATIENT

PNoPNameDeptDaysBillDOA
101YashCardiology25000.322026-03-11
102ChetanCardiology155983.682026-03-01
103ZeenatCardiology48922.892026-07-02
104SwatiOrtho76492.812026-04-01
105PankajENT148701.772026-03-13
106MohitENT135473.262026-02-19

Table: DEPARTMENT

DeptDoctorFloor
CardiologyDr. Rao2
ENTDr. Sen1
OrthoDr. Ali3
Answer
(i)
SELECT Dept, COUNT(*) FROM PATIENT GROUP BY Dept;
DeptCOUNT(*)
Cardiology3
ENT2
Ortho1

Explanation: GROUP BY Dept makes 3 groups (Cardiology, ENT, Ortho); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Dept, SUM(Days) FROM PATIENT GROUP BY Dept HAVING SUM(Days) > 20;
DeptSUM(Days)
Cardiology21
ENT27

Explanation: GROUP BY Dept makes 3 groups (Cardiology, ENT, Ortho); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Days) is more than 20. SUM adds the values.

(iii)
SELECT PName, Doctor FROM PATIENT, DEPARTMENT WHERE PATIENT.Dept = DEPARTMENT.Dept;
PNameDoctor
YashDr. Rao
ChetanDr. Rao
ZeenatDr. Rao
SwatiDr. Ali
PankajDr. Sen
MohitDr. Sen

Explanation: The two tables PATIENT and DEPARTMENT are joined: only the row pairs where PATIENT.Dept = DEPARTMENT.Dept are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT PName, Days, Floor FROM PATIENT, DEPARTMENT WHERE PATIENT.Dept = DEPARTMENT.Dept AND Days > 7;
PNameDaysFloor
Chetan152
Pankaj141
Mohit131

Explanation: The two tables PATIENT and DEPARTMENT are joined: only the row pairs where PATIENT.Dept = DEPARTMENT.Dept are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Days is more than 7.

D2.2Practice4 marks

Consider the tables PATIENT and DEPARTMENT given below. Write the output of the following queries.

Table: PATIENT

PNoPNameDeptDaysBillDOA
101YashCardiology25000.322026-03-11
102ChetanCardiology155983.682026-03-01
103ZeenatCardiology48922.892026-07-02
104SwatiOrtho76492.812026-04-01
105PankajENT148701.772026-03-13
106MohitENT135473.262026-02-19

Table: DEPARTMENT

DeptDoctorFloor
CardiologyDr. Rao2
ENTDr. Sen1
OrthoDr. Ali3
(i) SELECT Dept, COUNT(*) FROM PATIENT GROUP BY Dept HAVING COUNT(*) > 1;
(ii) SELECT Dept, MAX(Days) FROM PATIENT GROUP BY Dept ORDER BY MAX(Days) DESC;
(iii) SELECT PName, Days, Floor FROM PATIENT, DEPARTMENT WHERE PATIENT.Dept = DEPARTMENT.Dept AND Days > 7;
(iv) SELECT PName, Doctor FROM PATIENT, DEPARTMENT WHERE PATIENT.Dept = DEPARTMENT.Dept AND Doctor = 'Dr. Rao';
Answer
(i)
DeptCOUNT(*)
Cardiology3
ENT2

Explanation: GROUP BY Dept makes 3 groups (Cardiology, ENT, Ortho); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
DeptMAX(Days)
Cardiology15
ENT14
Ortho7

Explanation: GROUP BY Dept makes 3 groups (Cardiology, ENT, Ortho); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Days) arranges the result in descending (largest first) order.

(iii)
PNameDaysFloor
Chetan152
Pankaj141
Mohit131

Explanation: The two tables PATIENT and DEPARTMENT are joined: only the row pairs where PATIENT.Dept = DEPARTMENT.Dept are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Days is more than 7.

(iv)
PNameDoctor
YashDr. Rao
ChetanDr. Rao
ZeenatDr. Rao

Explanation: The two tables PATIENT and DEPARTMENT are joined: only the row pairs where PATIENT.Dept = DEPARTMENT.Dept are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Doctor is 'Dr. Rao'.

D2.3Practice4 marks

Consider the tables EMPLOYEE and DEPT given below. Write SQL queries to display:

  1. The Dept that have more than one row
  2. Each Dept with its highest Salary, in descending order of the highest Salary
  3. The EName of each row with the Manager of its Dept, using both the tables
  4. The EName, Salary and Staff of the rows where Salary is more than 40000, using both the tables.

Table: EMPLOYEE

ENoENameDeptSalaryBonusDOJ
11IshaHR430003522.372023-02-02
12YashSales400001725.022025-08-02
13SumanHR440003550.142019-09-25
14JatinSales450001269.742025-03-19
15NikhilSales250003263.382022-09-09
16SachinAccounts310003064.282021-05-17

Table: DEPT

DeptManagerStaff
SalesMr. Bose12
AccountsMs. Kaul8
HRMr. Nair5
Answer
(i)
SELECT Dept, COUNT(*) FROM EMPLOYEE GROUP BY Dept HAVING COUNT(*) > 1;
DeptCOUNT(*)
HR2
Sales3

Explanation: GROUP BY Dept makes 3 groups (Accounts, HR, Sales); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Dept, MAX(Salary) FROM EMPLOYEE GROUP BY Dept ORDER BY MAX(Salary) DESC;
DeptMAX(Salary)
Sales45000
HR44000
Accounts31000

Explanation: GROUP BY Dept makes 3 groups (Accounts, HR, Sales); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Salary) arranges the result in descending (largest first) order.

(iii)
SELECT EName, Manager FROM EMPLOYEE, DEPT WHERE EMPLOYEE.Dept = DEPT.Dept;
ENameManager
IshaMr. Nair
YashMr. Bose
SumanMr. Nair
JatinMr. Bose
NikhilMr. Bose
SachinMs. Kaul

Explanation: The two tables EMPLOYEE and DEPT are joined: only the row pairs where EMPLOYEE.Dept = DEPT.Dept are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT EName, Salary, Staff FROM EMPLOYEE, DEPT WHERE EMPLOYEE.Dept = DEPT.Dept AND Salary > 40000;
ENameSalaryStaff
Isha430005
Suman440005
Jatin4500012

Explanation: The two tables EMPLOYEE and DEPT are joined: only the row pairs where EMPLOYEE.Dept = DEPT.Dept are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Salary is more than 40000.

D2.4Practice4 marks

Consider the tables EMPLOYEE and DEPT given below. Write the output of the following queries.

Table: EMPLOYEE

ENoENameDeptSalaryBonusDOJ
11IshaHR430003522.372023-02-02
12YashSales400001725.022025-08-02
13SumanHR440003550.142019-09-25
14JatinSales450001269.742025-03-19
15NikhilSales250003263.382022-09-09
16SachinAccounts310003064.282021-05-17

Table: DEPT

DeptManagerStaff
SalesMr. Bose12
AccountsMs. Kaul8
HRMr. Nair5
(i) SELECT Dept, SUM(Salary) FROM EMPLOYEE GROUP BY Dept HAVING SUM(Salary) > 87000;
(ii) SELECT Dept, COUNT(*) FROM EMPLOYEE GROUP BY Dept;
(iii) SELECT EName, Salary, Staff FROM EMPLOYEE, DEPT WHERE EMPLOYEE.Dept = DEPT.Dept AND Salary > 40000;
(iv) SELECT EName, Manager FROM EMPLOYEE, DEPT WHERE EMPLOYEE.Dept = DEPT.Dept AND Manager = 'Mr. Bose';
Answer
(i)
DeptSUM(Salary)
Sales110000

Explanation: GROUP BY Dept makes 3 groups (Accounts, HR, Sales); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Salary) is more than 87000. SUM adds the values.

(ii)
DeptCOUNT(*)
Accounts1
HR2
Sales3

Explanation: GROUP BY Dept makes 3 groups (Accounts, HR, Sales); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
ENameSalaryStaff
Isha430005
Suman440005
Jatin4500012

Explanation: The two tables EMPLOYEE and DEPT are joined: only the row pairs where EMPLOYEE.Dept = DEPT.Dept are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Salary is more than 40000.

(iv)
ENameManager
YashMr. Bose
JatinMr. Bose
NikhilMr. Bose

Explanation: The two tables EMPLOYEE and DEPT are joined: only the row pairs where EMPLOYEE.Dept = DEPT.Dept are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Manager is 'Mr. Bose'.

D2.5Practice4 marks

Consider the tables BOOK and GENRE given below. Write SQL queries to display:

  1. Each Genre and the number of rows in it
  2. Each Genre and its total Pages, only for the groups whose total Pages is more than 590
  3. The Title of each row with the Shelf of its Genre, using both the tables
  4. The Title, Pages and Copies of the rows where Pages is more than 290, using both the tables.

Table: BOOK

BNoTitleGenrePagesPriceDOP
1Wings of FireFiction120342.442022-06-18
2Malgudi DaysFiction290337.032025-06-20
3PanchatantraBiography150339.912021-07-27
4GodanPoetry320195.342024-05-13
5GitanjaliBiography440520.872024-10-12
6Train to PakistanFiction330359.452021-10-21

Table: GENRE

GenreShelfCopies
FictionS140
BiographyS215
PoetryS322
Answer
(i)
SELECT Genre, COUNT(*) FROM BOOK GROUP BY Genre;
GenreCOUNT(*)
Biography2
Fiction3
Poetry1

Explanation: GROUP BY Genre makes 3 groups (Biography, Fiction, Poetry); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Genre, SUM(Pages) FROM BOOK GROUP BY Genre HAVING SUM(Pages) > 590;
GenreSUM(Pages)
Fiction740

Explanation: GROUP BY Genre makes 3 groups (Biography, Fiction, Poetry); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Pages) is more than 590. SUM adds the values.

(iii)
SELECT Title, Shelf FROM BOOK, GENRE WHERE BOOK.Genre = GENRE.Genre;
TitleShelf
Wings of FireS1
Malgudi DaysS1
PanchatantraS2
GodanS3
GitanjaliS2
Train to PakistanS1

Explanation: The two tables BOOK and GENRE are joined: only the row pairs where BOOK.Genre = GENRE.Genre are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT Title, Pages, Copies FROM BOOK, GENRE WHERE BOOK.Genre = GENRE.Genre AND Pages > 290;
TitlePagesCopies
Godan32022
Gitanjali44015
Train to Pakistan33040

Explanation: The two tables BOOK and GENRE are joined: only the row pairs where BOOK.Genre = GENRE.Genre are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Pages is more than 290.

D2.6Practice4 marks

Consider the tables BOOK and GENRE given below. Write the output of the following queries.

Table: BOOK

BNoTitleGenrePagesPriceDOP
1Wings of FireFiction120342.442022-06-18
2Malgudi DaysFiction290337.032025-06-20
3PanchatantraBiography150339.912021-07-27
4GodanPoetry320195.342024-05-13
5GitanjaliBiography440520.872024-10-12
6Train to PakistanFiction330359.452021-10-21

Table: GENRE

GenreShelfCopies
FictionS140
BiographyS215
PoetryS322
(i) SELECT Genre, COUNT(*) FROM BOOK GROUP BY Genre HAVING COUNT(*) > 1;
(ii) SELECT Genre, MAX(Pages) FROM BOOK GROUP BY Genre ORDER BY MAX(Pages) DESC;
(iii) SELECT Title, Pages, Copies FROM BOOK, GENRE WHERE BOOK.Genre = GENRE.Genre AND Pages > 290;
(iv) SELECT Title, Shelf FROM BOOK, GENRE WHERE BOOK.Genre = GENRE.Genre AND Shelf = 'S1';
Answer
(i)
GenreCOUNT(*)
Biography2
Fiction3

Explanation: GROUP BY Genre makes 3 groups (Biography, Fiction, Poetry); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
GenreMAX(Pages)
Biography440
Fiction330
Poetry320

Explanation: GROUP BY Genre makes 3 groups (Biography, Fiction, Poetry); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Pages) arranges the result in descending (largest first) order.

(iii)
TitlePagesCopies
Godan32022
Gitanjali44015
Train to Pakistan33040

Explanation: The two tables BOOK and GENRE are joined: only the row pairs where BOOK.Genre = GENRE.Genre are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Pages is more than 290.

(iv)
TitleShelf
Wings of FireS1
Malgudi DaysS1
Train to PakistanS1

Explanation: The two tables BOOK and GENRE are joined: only the row pairs where BOOK.Genre = GENRE.Genre are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Shelf is 'S1'.

D2.7Practice4 marks

Consider the tables STUDENT and STREAM given below. Write SQL queries to display:

  1. The Stream that have more than one row
  2. Each Stream with its highest Marks, in descending order of the highest Marks
  3. The SName of each row with the Teacher of its Stream, using both the tables
  4. The SName, Marks and Seats of the rows where Marks is more than 71, using both the tables.

Table: STUDENT

RNoSNameStreamMarksFeesDOB
1IshaScience716193.932008-08-26
2DeepakScience603799.372008-11-04
3GeetaScience883372.652010-03-11
4TanviHumanities764392.132009-02-04
5RohanCommerce633443.292008-05-08
6UmeshCommerce852597.322010-06-25

Table: STREAM

StreamTeacherSeats
ScienceMr. Iyer40
CommerceMs. Gill45
HumanitiesMr. Khan35
Answer
(i)
SELECT Stream, COUNT(*) FROM STUDENT GROUP BY Stream HAVING COUNT(*) > 1;
StreamCOUNT(*)
Commerce2
Science3

Explanation: GROUP BY Stream makes 3 groups (Commerce, Humanities, Science); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Stream, MAX(Marks) FROM STUDENT GROUP BY Stream ORDER BY MAX(Marks) DESC;
StreamMAX(Marks)
Science88
Commerce85
Humanities76

Explanation: GROUP BY Stream makes 3 groups (Commerce, Humanities, Science); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Marks) arranges the result in descending (largest first) order.

(iii)
SELECT SName, Teacher FROM STUDENT, STREAM WHERE STUDENT.Stream = STREAM.Stream;
SNameTeacher
IshaMr. Iyer
DeepakMr. Iyer
GeetaMr. Iyer
TanviMr. Khan
RohanMs. Gill
UmeshMs. Gill

Explanation: The two tables STUDENT and STREAM are joined: only the row pairs where STUDENT.Stream = STREAM.Stream are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT SName, Marks, Seats FROM STUDENT, STREAM WHERE STUDENT.Stream = STREAM.Stream AND Marks > 71;
SNameMarksSeats
Geeta8840
Tanvi7635
Umesh8545

Explanation: The two tables STUDENT and STREAM are joined: only the row pairs where STUDENT.Stream = STREAM.Stream are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Marks is more than 71.

D2.8Practice4 marks

Consider the tables STUDENT and STREAM given below. Write the output of the following queries.

Table: STUDENT

RNoSNameStreamMarksFeesDOB
1IshaScience716193.932008-08-26
2DeepakScience603799.372008-11-04
3GeetaScience883372.652010-03-11
4TanviHumanities764392.132009-02-04
5RohanCommerce633443.292008-05-08
6UmeshCommerce852597.322010-06-25

Table: STREAM

StreamTeacherSeats
ScienceMr. Iyer40
CommerceMs. Gill45
HumanitiesMr. Khan35
(i) SELECT Stream, SUM(Marks) FROM STUDENT GROUP BY Stream HAVING SUM(Marks) > 145;
(ii) SELECT Stream, COUNT(*) FROM STUDENT GROUP BY Stream;
(iii) SELECT SName, Marks, Seats FROM STUDENT, STREAM WHERE STUDENT.Stream = STREAM.Stream AND Marks > 71;
(iv) SELECT SName, Teacher FROM STUDENT, STREAM WHERE STUDENT.Stream = STREAM.Stream AND Teacher = 'Mr. Iyer';
Answer
(i)
StreamSUM(Marks)
Commerce148
Science219

Explanation: GROUP BY Stream makes 3 groups (Commerce, Humanities, Science); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Marks) is more than 145. SUM adds the values.

(ii)
StreamCOUNT(*)
Commerce2
Humanities1
Science3

Explanation: GROUP BY Stream makes 3 groups (Commerce, Humanities, Science); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
SNameMarksSeats
Geeta8840
Tanvi7635
Umesh8545

Explanation: The two tables STUDENT and STREAM are joined: only the row pairs where STUDENT.Stream = STREAM.Stream are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Marks is more than 71.

(iv)
SNameTeacher
IshaMr. Iyer
DeepakMr. Iyer
GeetaMr. Iyer

Explanation: The two tables STUDENT and STREAM are joined: only the row pairs where STUDENT.Stream = STREAM.Stream are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Teacher is 'Mr. Iyer'.

D2.9Practice4 marks

Consider the tables PRODUCT and COMPANY given below. Write SQL queries to display:

  1. Each Company and the number of rows in it
  2. Each Company and its total Stock, only for the groups whose total Stock is more than 210
  3. The PName of each row with the City of its Company, using both the tables
  4. The PName, Stock and Agents of the rows where Stock is more than 110, using both the tables.

Table: PRODUCT

PCodePNameCompanyStockPriceMfgDate
501SoapNeha Foods130114.822026-04-27
502ShampooSai Mart40387.162026-05-15
503BiscuitNeha Foods110187.062026-07-05
504ToothpasteOm Traders30275.282026-11-16
505JuiceNeha Foods120111.882026-11-04
506ButterOm Traders180293.322026-04-27

Table: COMPANY

CompanyCityAgents
Neha FoodsIndore14
Om TradersNagpur9
Sai MartKanpur6
Answer
(i)
SELECT Company, COUNT(*) FROM PRODUCT GROUP BY Company;
CompanyCOUNT(*)
Neha Foods3
Om Traders2
Sai Mart1

Explanation: GROUP BY Company makes 3 groups (Neha Foods, Om Traders, Sai Mart); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Company, SUM(Stock) FROM PRODUCT GROUP BY Company HAVING SUM(Stock) > 210;
CompanySUM(Stock)
Neha Foods360

Explanation: GROUP BY Company makes 3 groups (Neha Foods, Om Traders, Sai Mart); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Stock) is more than 210. SUM adds the values.

(iii)
SELECT PName, City FROM PRODUCT, COMPANY WHERE PRODUCT.Company = COMPANY.Company;
PNameCity
SoapIndore
ShampooKanpur
BiscuitIndore
ToothpasteNagpur
JuiceIndore
ButterNagpur

Explanation: The two tables PRODUCT and COMPANY are joined: only the row pairs where PRODUCT.Company = COMPANY.Company are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT PName, Stock, Agents FROM PRODUCT, COMPANY WHERE PRODUCT.Company = COMPANY.Company AND Stock > 110;
PNameStockAgents
Soap13014
Juice12014
Butter1809

Explanation: The two tables PRODUCT and COMPANY are joined: only the row pairs where PRODUCT.Company = COMPANY.Company are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Stock is more than 110.

D2.10Practice4 marks

Consider the tables PRODUCT and COMPANY given below. Write the output of the following queries.

Table: PRODUCT

PCodePNameCompanyStockPriceMfgDate
501SoapNeha Foods130114.822026-04-27
502ShampooSai Mart40387.162026-05-15
503BiscuitNeha Foods110187.062026-07-05
504ToothpasteOm Traders30275.282026-11-16
505JuiceNeha Foods120111.882026-11-04
506ButterOm Traders180293.322026-04-27

Table: COMPANY

CompanyCityAgents
Neha FoodsIndore14
Om TradersNagpur9
Sai MartKanpur6
(i) SELECT Company, COUNT(*) FROM PRODUCT GROUP BY Company HAVING COUNT(*) > 1;
(ii) SELECT Company, MAX(Stock) FROM PRODUCT GROUP BY Company ORDER BY MAX(Stock) DESC;
(iii) SELECT PName, Stock, Agents FROM PRODUCT, COMPANY WHERE PRODUCT.Company = COMPANY.Company AND Stock > 110;
(iv) SELECT PName, City FROM PRODUCT, COMPANY WHERE PRODUCT.Company = COMPANY.Company AND City = 'Indore';
Answer
(i)
CompanyCOUNT(*)
Neha Foods3
Om Traders2

Explanation: GROUP BY Company makes 3 groups (Neha Foods, Om Traders, Sai Mart); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
CompanyMAX(Stock)
Om Traders180
Neha Foods130
Sai Mart40

Explanation: GROUP BY Company makes 3 groups (Neha Foods, Om Traders, Sai Mart); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Stock) arranges the result in descending (largest first) order.

(iii)
PNameStockAgents
Soap13014
Juice12014
Butter1809

Explanation: The two tables PRODUCT and COMPANY are joined: only the row pairs where PRODUCT.Company = COMPANY.Company are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Stock is more than 110.

(iv)
PNameCity
SoapIndore
BiscuitIndore
JuiceIndore

Explanation: The two tables PRODUCT and COMPANY are joined: only the row pairs where PRODUCT.Company = COMPANY.Company are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: City is 'Indore'.

D2.11Practice4 marks

Consider the tables MEMBER and PLAN given below. Write SQL queries to display:

  1. The Plan that have more than one row
  2. Each Plan with its highest Months, in descending order of the highest Months
  3. The MName of each row with the Trainer of its Plan, using both the tables
  4. The MName, Months and Hours of the rows where Months is more than 6, using both the tables.

Table: MEMBER

MNoMNamePlanMonthsFeeJoinDate
1MohitGold32755.292026-07-09
2VikasGold91680.762025-04-25
3TanviSilver122149.512025-01-03
4PallaviGold41398.782026-05-02
5DivyaSilver62568.092025-06-13
6AmanBasic82546.012026-06-19

Table: PLAN

PlanTrainerHours
GoldVijay3
SilverSana2
BasicRocky1
Answer
(i)
SELECT Plan, COUNT(*) FROM MEMBER GROUP BY Plan HAVING COUNT(*) > 1;
PlanCOUNT(*)
Gold3
Silver2

Explanation: GROUP BY Plan makes 3 groups (Basic, Gold, Silver); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Plan, MAX(Months) FROM MEMBER GROUP BY Plan ORDER BY MAX(Months) DESC;
PlanMAX(Months)
Silver12
Gold9
Basic8

Explanation: GROUP BY Plan makes 3 groups (Basic, Gold, Silver); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Months) arranges the result in descending (largest first) order.

(iii)
SELECT MName, Trainer FROM MEMBER, PLAN WHERE MEMBER.Plan = PLAN.Plan;
MNameTrainer
MohitVijay
VikasVijay
TanviSana
PallaviVijay
DivyaSana
AmanRocky

Explanation: The two tables MEMBER and PLAN are joined: only the row pairs where MEMBER.Plan = PLAN.Plan are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT MName, Months, Hours FROM MEMBER, PLAN WHERE MEMBER.Plan = PLAN.Plan AND Months > 6;
MNameMonthsHours
Vikas93
Tanvi122
Aman81

Explanation: The two tables MEMBER and PLAN are joined: only the row pairs where MEMBER.Plan = PLAN.Plan are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Months is more than 6.

D2.12Practice4 marks

Consider the tables MEMBER and PLAN given below. Write the output of the following queries.

Table: MEMBER

MNoMNamePlanMonthsFeeJoinDate
1MohitGold32755.292026-07-09
2VikasGold91680.762025-04-25
3TanviSilver122149.512025-01-03
4PallaviGold41398.782026-05-02
5DivyaSilver62568.092025-06-13
6AmanBasic82546.012026-06-19

Table: PLAN

PlanTrainerHours
GoldVijay3
SilverSana2
BasicRocky1
(i) SELECT Plan, SUM(Months) FROM MEMBER GROUP BY Plan HAVING SUM(Months) > 15;
(ii) SELECT Plan, COUNT(*) FROM MEMBER GROUP BY Plan;
(iii) SELECT MName, Months, Hours FROM MEMBER, PLAN WHERE MEMBER.Plan = PLAN.Plan AND Months > 6;
(iv) SELECT MName, Trainer FROM MEMBER, PLAN WHERE MEMBER.Plan = PLAN.Plan AND Trainer = 'Vijay';
Answer
(i)
PlanSUM(Months)
Gold16
Silver18

Explanation: GROUP BY Plan makes 3 groups (Basic, Gold, Silver); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Months) is more than 15. SUM adds the values.

(ii)
PlanCOUNT(*)
Basic1
Gold3
Silver2

Explanation: GROUP BY Plan makes 3 groups (Basic, Gold, Silver); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
MNameMonthsHours
Vikas93
Tanvi122
Aman81

Explanation: The two tables MEMBER and PLAN are joined: only the row pairs where MEMBER.Plan = PLAN.Plan are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Months is more than 6.

(iv)
MNameTrainer
MohitVijay
VikasVijay
PallaviVijay

Explanation: The two tables MEMBER and PLAN are joined: only the row pairs where MEMBER.Plan = PLAN.Plan are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Trainer is 'Vijay'.

D2.13Practice4 marks

Consider the tables TICKET and ROUTE given below. Write SQL queries to display:

  1. Each Dest and the number of rows in it
  2. Each Dest and its total Seats, only for the groups whose total Seats is more than 7
  3. The Passenger of each row with the Airline of its Dest, using both the tables
  4. The Passenger, Seats and Hours of the rows where Seats is more than 3, using both the tables.

Table: TICKET

TNoPassengerDestSeatsFareTravelDate
301AnitaGoa39384.042026-01-28
302BhavnaGoa36828.462026-03-11
303SimranKochi68802.732026-04-28
304AmanKochi46806.372026-10-14
305JatinGoa24173.892027-05-03
306SonalLeh59385.632026-12-18

Table: ROUTE

DestAirlineHours
GoaSkyJet3
LehAirWing2
KochiBlueSky4
Answer
(i)
SELECT Dest, COUNT(*) FROM TICKET GROUP BY Dest;
DestCOUNT(*)
Goa3
Kochi2
Leh1

Explanation: GROUP BY Dest makes 3 groups (Goa, Kochi, Leh); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Dest, SUM(Seats) FROM TICKET GROUP BY Dest HAVING SUM(Seats) > 7;
DestSUM(Seats)
Goa8
Kochi10

Explanation: GROUP BY Dest makes 3 groups (Goa, Kochi, Leh); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Seats) is more than 7. SUM adds the values.

(iii)
SELECT Passenger, Airline FROM TICKET, ROUTE WHERE TICKET.Dest = ROUTE.Dest;
PassengerAirline
AnitaSkyJet
BhavnaSkyJet
SimranBlueSky
AmanBlueSky
JatinSkyJet
SonalAirWing

Explanation: The two tables TICKET and ROUTE are joined: only the row pairs where TICKET.Dest = ROUTE.Dest are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT Passenger, Seats, Hours FROM TICKET, ROUTE WHERE TICKET.Dest = ROUTE.Dest AND Seats > 3;
PassengerSeatsHours
Simran64
Aman44
Sonal52

Explanation: The two tables TICKET and ROUTE are joined: only the row pairs where TICKET.Dest = ROUTE.Dest are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Seats is more than 3.

D2.14Practice4 marks

Consider the tables TICKET and ROUTE given below. Write the output of the following queries.

Table: TICKET

TNoPassengerDestSeatsFareTravelDate
301AnitaGoa39384.042026-01-28
302BhavnaGoa36828.462026-03-11
303SimranKochi68802.732026-04-28
304AmanKochi46806.372026-10-14
305JatinGoa24173.892027-05-03
306SonalLeh59385.632026-12-18

Table: ROUTE

DestAirlineHours
GoaSkyJet3
LehAirWing2
KochiBlueSky4
(i) SELECT Dest, COUNT(*) FROM TICKET GROUP BY Dest HAVING COUNT(*) > 1;
(ii) SELECT Dest, MAX(Seats) FROM TICKET GROUP BY Dest ORDER BY MAX(Seats) DESC;
(iii) SELECT Passenger, Seats, Hours FROM TICKET, ROUTE WHERE TICKET.Dest = ROUTE.Dest AND Seats > 3;
(iv) SELECT Passenger, Airline FROM TICKET, ROUTE WHERE TICKET.Dest = ROUTE.Dest AND Airline = 'SkyJet';
Answer
(i)
DestCOUNT(*)
Goa3
Kochi2

Explanation: GROUP BY Dest makes 3 groups (Goa, Kochi, Leh); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
DestMAX(Seats)
Kochi6
Leh5
Goa3

Explanation: GROUP BY Dest makes 3 groups (Goa, Kochi, Leh); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Seats) arranges the result in descending (largest first) order.

(iii)
PassengerSeatsHours
Simran64
Aman44
Sonal52

Explanation: The two tables TICKET and ROUTE are joined: only the row pairs where TICKET.Dest = ROUTE.Dest are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Seats is more than 3.

(iv)
PassengerAirline
AnitaSkyJet
BhavnaSkyJet
JatinSkyJet

Explanation: The two tables TICKET and ROUTE are joined: only the row pairs where TICKET.Dest = ROUTE.Dest are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Airline is 'SkyJet'.

D2.15Practice4 marks

Consider the tables MOVIE and GENRE given below. Write SQL queries to display:

  1. The Genre that have more than one row
  2. Each Genre with its highest Minutes, in descending order of the highest Minutes
  3. The Title of each row with the Award of its Genre, using both the tables
  4. The Title, Minutes and Shows of the rows where Minutes is more than 125, using both the tables.

Table: MOVIE

MNoTitleGenreMinutesRatingRelDate
1UdaanComedy1708.542026-03-24
2SafarComedy1457.522024-08-10
3DostiDrama1256.872023-12-27
4RangoliComedy1305.112023-10-16
5KhelAction1056.832024-12-18
6SapnaAction1155.332024-12-07

Table: GENRE

GenreAwardShows
ComedyHasya4
DramaKala3
ActionVeer5
Answer
(i)
SELECT Genre, COUNT(*) FROM MOVIE GROUP BY Genre HAVING COUNT(*) > 1;
GenreCOUNT(*)
Action2
Comedy3

Explanation: GROUP BY Genre makes 3 groups (Action, Comedy, Drama); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Genre, MAX(Minutes) FROM MOVIE GROUP BY Genre ORDER BY MAX(Minutes) DESC;
GenreMAX(Minutes)
Comedy170
Drama125
Action115

Explanation: GROUP BY Genre makes 3 groups (Action, Comedy, Drama); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Minutes) arranges the result in descending (largest first) order.

(iii)
SELECT Title, Award FROM MOVIE, GENRE WHERE MOVIE.Genre = GENRE.Genre;
TitleAward
UdaanHasya
SafarHasya
DostiKala
RangoliHasya
KhelVeer
SapnaVeer

Explanation: The two tables MOVIE and GENRE are joined: only the row pairs where MOVIE.Genre = GENRE.Genre are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT Title, Minutes, Shows FROM MOVIE, GENRE WHERE MOVIE.Genre = GENRE.Genre AND Minutes > 125;
TitleMinutesShows
Udaan1704
Safar1454
Rangoli1304

Explanation: The two tables MOVIE and GENRE are joined: only the row pairs where MOVIE.Genre = GENRE.Genre are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Minutes is more than 125.

D2.16Practice4 marks

Consider the tables MOVIE and GENRE given below. Write the output of the following queries.

Table: MOVIE

MNoTitleGenreMinutesRatingRelDate
1UdaanComedy1708.542026-03-24
2SafarComedy1457.522024-08-10
3DostiDrama1256.872023-12-27
4RangoliComedy1305.112023-10-16
5KhelAction1056.832024-12-18
6SapnaAction1155.332024-12-07

Table: GENRE

GenreAwardShows
ComedyHasya4
DramaKala3
ActionVeer5
(i) SELECT Genre, SUM(Minutes) FROM MOVIE GROUP BY Genre HAVING SUM(Minutes) > 220;
(ii) SELECT Genre, COUNT(*) FROM MOVIE GROUP BY Genre;
(iii) SELECT Title, Minutes, Shows FROM MOVIE, GENRE WHERE MOVIE.Genre = GENRE.Genre AND Minutes > 125;
(iv) SELECT Title, Award FROM MOVIE, GENRE WHERE MOVIE.Genre = GENRE.Genre AND Award = 'Hasya';
Answer
(i)
GenreSUM(Minutes)
Comedy445

Explanation: GROUP BY Genre makes 3 groups (Action, Comedy, Drama); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Minutes) is more than 220. SUM adds the values.

(ii)
GenreCOUNT(*)
Action2
Comedy3
Drama1

Explanation: GROUP BY Genre makes 3 groups (Action, Comedy, Drama); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
TitleMinutesShows
Udaan1704
Safar1454
Rangoli1304

Explanation: The two tables MOVIE and GENRE are joined: only the row pairs where MOVIE.Genre = GENRE.Genre are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Minutes is more than 125.

(iv)
TitleAward
UdaanHasya
SafarHasya
RangoliHasya

Explanation: The two tables MOVIE and GENRE are joined: only the row pairs where MOVIE.Genre = GENRE.Genre are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Award is 'Hasya'.

D2.17Practice4 marks

Consider the tables COURSE and MODE given below. Write SQL queries to display:

  1. Each Mode and the number of rows in it
  2. Each Mode and its total Weeks, only for the groups whose total Weeks is more than 25
  3. The CName of each row with the Centre of its Mode, using both the tables
  4. The CName, Weeks and Seats of the rows where Weeks is more than 8, using both the tables.

Table: COURSE

CNoCNameModeWeeksFeeStartDate
21PythonOnline68375.412026-06-06
22Web DesignOffline83020.132026-10-13
23TallyOnline104826.352027-03-23
24AnimationHybrid228778.762026-11-11
25RoboticsHybrid46911.582026-09-27
26Data EntryOnline249871.532027-11-05

Table: MODE

ModeCentreSeats
OnlineRohini60
OfflineDwarka30
HybridSaket40
Answer
(i)
SELECT Mode, COUNT(*) FROM COURSE GROUP BY Mode;
ModeCOUNT(*)
Hybrid2
Offline1
Online3

Explanation: GROUP BY Mode makes 3 groups (Hybrid, Offline, Online); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Mode, SUM(Weeks) FROM COURSE GROUP BY Mode HAVING SUM(Weeks) > 25;
ModeSUM(Weeks)
Hybrid26
Online40

Explanation: GROUP BY Mode makes 3 groups (Hybrid, Offline, Online); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Weeks) is more than 25. SUM adds the values.

(iii)
SELECT CName, Centre FROM COURSE, MODE WHERE COURSE.Mode = MODE.Mode;
CNameCentre
PythonRohini
Web DesignDwarka
TallyRohini
AnimationSaket
RoboticsSaket
Data EntryRohini

Explanation: The two tables COURSE and MODE are joined: only the row pairs where COURSE.Mode = MODE.Mode are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT CName, Weeks, Seats FROM COURSE, MODE WHERE COURSE.Mode = MODE.Mode AND Weeks > 8;
CNameWeeksSeats
Tally1060
Animation2240
Data Entry2460

Explanation: The two tables COURSE and MODE are joined: only the row pairs where COURSE.Mode = MODE.Mode are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Weeks is more than 8.

D2.18Practice4 marks

Consider the tables COURSE and MODE given below. Write the output of the following queries.

Table: COURSE

CNoCNameModeWeeksFeeStartDate
21PythonOnline68375.412026-06-06
22Web DesignOffline83020.132026-10-13
23TallyOnline104826.352027-03-23
24AnimationHybrid228778.762026-11-11
25RoboticsHybrid46911.582026-09-27
26Data EntryOnline249871.532027-11-05

Table: MODE

ModeCentreSeats
OnlineRohini60
OfflineDwarka30
HybridSaket40
(i) SELECT Mode, COUNT(*) FROM COURSE GROUP BY Mode HAVING COUNT(*) > 1;
(ii) SELECT Mode, MAX(Weeks) FROM COURSE GROUP BY Mode ORDER BY MAX(Weeks) DESC;
(iii) SELECT CName, Weeks, Seats FROM COURSE, MODE WHERE COURSE.Mode = MODE.Mode AND Weeks > 8;
(iv) SELECT CName, Centre FROM COURSE, MODE WHERE COURSE.Mode = MODE.Mode AND Centre = 'Rohini';
Answer
(i)
ModeCOUNT(*)
Hybrid2
Online3

Explanation: GROUP BY Mode makes 3 groups (Hybrid, Offline, Online); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
ModeMAX(Weeks)
Online24
Hybrid22
Offline8

Explanation: GROUP BY Mode makes 3 groups (Hybrid, Offline, Online); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Weeks) arranges the result in descending (largest first) order.

(iii)
CNameWeeksSeats
Tally1060
Animation2240
Data Entry2460

Explanation: The two tables COURSE and MODE are joined: only the row pairs where COURSE.Mode = MODE.Mode are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Weeks is more than 8.

(iv)
CNameCentre
PythonRohini
TallyRohini
Data EntryRohini

Explanation: The two tables COURSE and MODE are joined: only the row pairs where COURSE.Mode = MODE.Mode are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Centre is 'Rohini'.

D2.19Practice4 marks

Consider the tables VEHICLE and VTYPE given below. Write SQL queries to display:

  1. The Type that have more than one row
  2. Each Type with its highest Km, in descending order of the highest Km
  3. The Owner of each row with the Licence of its Type, using both the tables
  4. The Owner, Km and Parking of the rows where Km is more than 25500, using both the tables.

Table: VEHICLE

VNoOwnerTypeKmTaxRegDate
701YashBike145002852.032019-01-09
702ShreyaVan590002222.072023-01-21
703SimranCar275002206.182018-07-13
704SwatiVan255001253.912020-12-12
705SandeepCar540002275.812025-01-14
706AmanCar155001981.682018-12-01

Table: VTYPE

TypeLicenceParking
CarLMV100
BikeMCWG30
VanLMV-TR150
Answer
(i)
SELECT Type, COUNT(*) FROM VEHICLE GROUP BY Type HAVING COUNT(*) > 1;
TypeCOUNT(*)
Car3
Van2

Explanation: GROUP BY Type makes 3 groups (Bike, Car, Van); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Type, MAX(Km) FROM VEHICLE GROUP BY Type ORDER BY MAX(Km) DESC;
TypeMAX(Km)
Van59000
Car54000
Bike14500

Explanation: GROUP BY Type makes 3 groups (Bike, Car, Van); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Km) arranges the result in descending (largest first) order.

(iii)
SELECT Owner, Licence FROM VEHICLE, VTYPE WHERE VEHICLE.Type = VTYPE.Type;
OwnerLicence
YashMCWG
ShreyaLMV-TR
SimranLMV
SwatiLMV-TR
SandeepLMV
AmanLMV

Explanation: The two tables VEHICLE and VTYPE are joined: only the row pairs where VEHICLE.Type = VTYPE.Type are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT Owner, Km, Parking FROM VEHICLE, VTYPE WHERE VEHICLE.Type = VTYPE.Type AND Km > 25500;
OwnerKmParking
Shreya59000150
Simran27500100
Sandeep54000100

Explanation: The two tables VEHICLE and VTYPE are joined: only the row pairs where VEHICLE.Type = VTYPE.Type are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Km is more than 25500.

D2.20Practice4 marks

Consider the tables VEHICLE and VTYPE given below. Write the output of the following queries.

Table: VEHICLE

VNoOwnerTypeKmTaxRegDate
701YashBike145002852.032019-01-09
702ShreyaVan590002222.072023-01-21
703SimranCar275002206.182018-07-13
704SwatiVan255001253.912020-12-12
705SandeepCar540002275.812025-01-14
706AmanCar155001981.682018-12-01

Table: VTYPE

TypeLicenceParking
CarLMV100
BikeMCWG30
VanLMV-TR150
(i) SELECT Type, SUM(Km) FROM VEHICLE GROUP BY Type HAVING SUM(Km) > 84500;
(ii) SELECT Type, COUNT(*) FROM VEHICLE GROUP BY Type;
(iii) SELECT Owner, Km, Parking FROM VEHICLE, VTYPE WHERE VEHICLE.Type = VTYPE.Type AND Km > 25500;
(iv) SELECT Owner, Licence FROM VEHICLE, VTYPE WHERE VEHICLE.Type = VTYPE.Type AND Licence = 'LMV';
Answer
(i)
TypeSUM(Km)
Car97000

Explanation: GROUP BY Type makes 3 groups (Bike, Car, Van); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Km) is more than 84500. SUM adds the values.

(ii)
TypeCOUNT(*)
Bike1
Car3
Van2

Explanation: GROUP BY Type makes 3 groups (Bike, Car, Van); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
OwnerKmParking
Shreya59000150
Simran27500100
Sandeep54000100

Explanation: The two tables VEHICLE and VTYPE are joined: only the row pairs where VEHICLE.Type = VTYPE.Type are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Km is more than 25500.

(iv)
OwnerLicence
SimranLMV
SandeepLMV
AmanLMV

Explanation: The two tables VEHICLE and VTYPE are joined: only the row pairs where VEHICLE.Type = VTYPE.Type are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Licence is 'LMV'.

D2.21Practice4 marks

Consider the tables ORDERS and CITY given below. Write SQL queries to display:

  1. Each City and the number of rows in it
  2. Each City and its total Qty, only for the groups whose total Qty is more than 20
  3. The Customer of each row with the State of its City, using both the tables
  4. The Customer, Qty and Stores of the rows where Qty is more than 6, using both the tables.

Table: ORDERS

ONoCustomerCityQtyAmountODate
9001HarishDelhi56729.592026-06-22
9002PallaviAgra37662.032026-10-28
9003YashPune11561.132026-11-22
9004ArjunPune124746.242026-04-01
9005NikhilDelhi133876.232026-04-20
9006FarhanDelhi66568.182026-03-14

Table: CITY

CityStateStores
DelhiDelhi5
PuneMaharashtra3
AgraUttar Pradesh2
Answer
(i)
SELECT City, COUNT(*) FROM ORDERS GROUP BY City;
CityCOUNT(*)
Agra1
Delhi3
Pune2

Explanation: GROUP BY City makes 3 groups (Agra, Delhi, Pune); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT City, SUM(Qty) FROM ORDERS GROUP BY City HAVING SUM(Qty) > 20;
CitySUM(Qty)
Delhi24
Pune23

Explanation: GROUP BY City makes 3 groups (Agra, Delhi, Pune); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Qty) is more than 20. SUM adds the values.

(iii)
SELECT Customer, State FROM ORDERS, CITY WHERE ORDERS.City = CITY.City;
CustomerState
HarishDelhi
PallaviUttar Pradesh
YashMaharashtra
ArjunMaharashtra
NikhilDelhi
FarhanDelhi

Explanation: The two tables ORDERS and CITY are joined: only the row pairs where ORDERS.City = CITY.City are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT Customer, Qty, Stores FROM ORDERS, CITY WHERE ORDERS.City = CITY.City AND Qty > 6;
CustomerQtyStores
Yash113
Arjun123
Nikhil135

Explanation: The two tables ORDERS and CITY are joined: only the row pairs where ORDERS.City = CITY.City are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Qty is more than 6.

D2.22Practice4 marks

Consider the tables ORDERS and CITY given below. Write the output of the following queries.

Table: ORDERS

ONoCustomerCityQtyAmountODate
9001HarishDelhi56729.592026-06-22
9002PallaviAgra37662.032026-10-28
9003YashPune11561.132026-11-22
9004ArjunPune124746.242026-04-01
9005NikhilDelhi133876.232026-04-20
9006FarhanDelhi66568.182026-03-14

Table: CITY

CityStateStores
DelhiDelhi5
PuneMaharashtra3
AgraUttar Pradesh2
(i) SELECT City, COUNT(*) FROM ORDERS GROUP BY City HAVING COUNT(*) > 1;
(ii) SELECT City, MAX(Qty) FROM ORDERS GROUP BY City ORDER BY MAX(Qty) DESC;
(iii) SELECT Customer, Qty, Stores FROM ORDERS, CITY WHERE ORDERS.City = CITY.City AND Qty > 6;
(iv) SELECT Customer, State FROM ORDERS, CITY WHERE ORDERS.City = CITY.City AND State = 'Delhi';
Answer
(i)
CityCOUNT(*)
Delhi3
Pune2

Explanation: GROUP BY City makes 3 groups (Agra, Delhi, Pune); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
CityMAX(Qty)
Delhi13
Pune12
Agra3

Explanation: GROUP BY City makes 3 groups (Agra, Delhi, Pune); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Qty) arranges the result in descending (largest first) order.

(iii)
CustomerQtyStores
Yash113
Arjun123
Nikhil135

Explanation: The two tables ORDERS and CITY are joined: only the row pairs where ORDERS.City = CITY.City are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Qty is more than 6.

(iv)
CustomerState
HarishDelhi
NikhilDelhi
FarhanDelhi

Explanation: The two tables ORDERS and CITY are joined: only the row pairs where ORDERS.City = CITY.City are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: State is 'Delhi'.

D2.23Practice4 marks

Consider the tables DOCTOR and SPEC given below. Write SQL queries to display:

  1. The Spec that have more than one row
  2. Each Spec with its highest Exp, in descending order of the highest Exp
  3. The DName of each row with the Room of its Spec, using both the tables
  4. The DName, Exp and Nurses of the rows where Exp is more than 6, using both the tables.

Table: DOCTOR

DNoDNameSpecExpFeeDOJ
1AnitaDental5436.842022-09-22
2OjasviSkin231051.092012-07-22
3NikhilEye21178.342021-05-22
4MeenalSkin141100.172020-08-28
5NaveenDental121207.472014-01-06
6VikasSkin6435.162017-06-04

Table: SPEC

SpecRoomNurses
SkinR12
EyeR23
DentalR34
Answer
(i)
SELECT Spec, COUNT(*) FROM DOCTOR GROUP BY Spec HAVING COUNT(*) > 1;
SpecCOUNT(*)
Dental2
Skin3

Explanation: GROUP BY Spec makes 3 groups (Dental, Eye, Skin); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Spec, MAX(Exp) FROM DOCTOR GROUP BY Spec ORDER BY MAX(Exp) DESC;
SpecMAX(Exp)
Skin23
Dental12
Eye2

Explanation: GROUP BY Spec makes 3 groups (Dental, Eye, Skin); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Exp) arranges the result in descending (largest first) order.

(iii)
SELECT DName, Room FROM DOCTOR, SPEC WHERE DOCTOR.Spec = SPEC.Spec;
DNameRoom
AnitaR3
OjasviR1
NikhilR2
MeenalR1
NaveenR3
VikasR1

Explanation: The two tables DOCTOR and SPEC are joined: only the row pairs where DOCTOR.Spec = SPEC.Spec are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT DName, Exp, Nurses FROM DOCTOR, SPEC WHERE DOCTOR.Spec = SPEC.Spec AND Exp > 6;
DNameExpNurses
Ojasvi232
Meenal142
Naveen124

Explanation: The two tables DOCTOR and SPEC are joined: only the row pairs where DOCTOR.Spec = SPEC.Spec are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Exp is more than 6.

D2.24Practice4 marks

Consider the tables DOCTOR and SPEC given below. Write the output of the following queries.

Table: DOCTOR

DNoDNameSpecExpFeeDOJ
1AnitaDental5436.842022-09-22
2OjasviSkin231051.092012-07-22
3NikhilEye21178.342021-05-22
4MeenalSkin141100.172020-08-28
5NaveenDental121207.472014-01-06
6VikasSkin6435.162017-06-04

Table: SPEC

SpecRoomNurses
SkinR12
EyeR23
DentalR34
(i) SELECT Spec, SUM(Exp) FROM DOCTOR GROUP BY Spec HAVING SUM(Exp) > 15;
(ii) SELECT Spec, COUNT(*) FROM DOCTOR GROUP BY Spec;
(iii) SELECT DName, Exp, Nurses FROM DOCTOR, SPEC WHERE DOCTOR.Spec = SPEC.Spec AND Exp > 6;
(iv) SELECT DName, Room FROM DOCTOR, SPEC WHERE DOCTOR.Spec = SPEC.Spec AND Room = 'R1';
Answer
(i)
SpecSUM(Exp)
Dental17
Skin43

Explanation: GROUP BY Spec makes 3 groups (Dental, Eye, Skin); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Exp) is more than 15. SUM adds the values.

(ii)
SpecCOUNT(*)
Dental2
Eye1
Skin3

Explanation: GROUP BY Spec makes 3 groups (Dental, Eye, Skin); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
DNameExpNurses
Ojasvi232
Meenal142
Naveen124

Explanation: The two tables DOCTOR and SPEC are joined: only the row pairs where DOCTOR.Spec = SPEC.Spec are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Exp is more than 6.

(iv)
DNameRoom
OjasviR1
MeenalR1
VikasR1

Explanation: The two tables DOCTOR and SPEC are joined: only the row pairs where DOCTOR.Spec = SPEC.Spec are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Room is 'R1'.

D2.25Practice4 marks

Consider the tables PLAYER and GAME given below. Write SQL queries to display:

  1. Each Game and the number of rows in it
  2. Each Game and its total Matches, only for the groups whose total Matches is more than 60
  3. The PName of each row with the Coach of its Game, using both the tables
  4. The PName, Matches and Fees of the rows where Matches is more than 35, using both the tables.

Table: PLAYER

PNoPNameGameMatchesAverageDOB
1NishaCricket3539.932007-12-23
2RachnaChess4448.492009-10-21
3MeenalCricket1962.942010-04-10
4NikhilCricket5140.512006-12-17
5HarishHockey2431.152010-08-13
6ZeenatHockey3629.332009-07-23

Table: GAME

GameCoachFees
CricketMr. Dev1500
HockeyMs. Roy1000
ChessMr. Paul800
Answer
(i)
SELECT Game, COUNT(*) FROM PLAYER GROUP BY Game;
GameCOUNT(*)
Chess1
Cricket3
Hockey2

Explanation: GROUP BY Game makes 3 groups (Chess, Cricket, Hockey); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Game, SUM(Matches) FROM PLAYER GROUP BY Game HAVING SUM(Matches) > 60;
GameSUM(Matches)
Cricket105

Explanation: GROUP BY Game makes 3 groups (Chess, Cricket, Hockey); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Matches) is more than 60. SUM adds the values.

(iii)
SELECT PName, Coach FROM PLAYER, GAME WHERE PLAYER.Game = GAME.Game;
PNameCoach
NishaMr. Dev
RachnaMr. Paul
MeenalMr. Dev
NikhilMr. Dev
HarishMs. Roy
ZeenatMs. Roy

Explanation: The two tables PLAYER and GAME are joined: only the row pairs where PLAYER.Game = GAME.Game are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT PName, Matches, Fees FROM PLAYER, GAME WHERE PLAYER.Game = GAME.Game AND Matches > 35;
PNameMatchesFees
Rachna44800
Nikhil511500
Zeenat361000

Explanation: The two tables PLAYER and GAME are joined: only the row pairs where PLAYER.Game = GAME.Game are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Matches is more than 35.

D2.26Practice4 marks

Consider the tables PLAYER and GAME given below. Write the output of the following queries.

Table: PLAYER

PNoPNameGameMatchesAverageDOB
1NishaCricket3539.932007-12-23
2RachnaChess4448.492009-10-21
3MeenalCricket1962.942010-04-10
4NikhilCricket5140.512006-12-17
5HarishHockey2431.152010-08-13
6ZeenatHockey3629.332009-07-23

Table: GAME

GameCoachFees
CricketMr. Dev1500
HockeyMs. Roy1000
ChessMr. Paul800
(i) SELECT Game, COUNT(*) FROM PLAYER GROUP BY Game HAVING COUNT(*) > 1;
(ii) SELECT Game, MAX(Matches) FROM PLAYER GROUP BY Game ORDER BY MAX(Matches) DESC;
(iii) SELECT PName, Matches, Fees FROM PLAYER, GAME WHERE PLAYER.Game = GAME.Game AND Matches > 35;
(iv) SELECT PName, Coach FROM PLAYER, GAME WHERE PLAYER.Game = GAME.Game AND Coach = 'Mr. Dev';
Answer
(i)
GameCOUNT(*)
Cricket3
Hockey2

Explanation: GROUP BY Game makes 3 groups (Chess, Cricket, Hockey); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
GameMAX(Matches)
Cricket51
Chess44
Hockey36

Explanation: GROUP BY Game makes 3 groups (Chess, Cricket, Hockey); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Matches) arranges the result in descending (largest first) order.

(iii)
PNameMatchesFees
Rachna44800
Nikhil511500
Zeenat361000

Explanation: The two tables PLAYER and GAME are joined: only the row pairs where PLAYER.Game = GAME.Game are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Matches is more than 35.

(iv)
PNameCoach
NishaMr. Dev
MeenalMr. Dev
NikhilMr. Dev

Explanation: The two tables PLAYER and GAME are joined: only the row pairs where PLAYER.Game = GAME.Game are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Coach is 'Mr. Dev'.

D2.27Practice4 marks

Consider the tables HOSTEL and BLOCK given below. Write SQL queries to display:

  1. The Block that have more than one row
  2. Each Block with its highest Room, in descending order of the highest Room
  3. The SName of each row with the Warden of its Block, using both the tables
  4. The SName, Room and Rooms of the rows where Room is more than 134, using both the tables.

Table: HOSTEL

HNoSNameBlockRoomMessDOA
1ChetanYamuna1643027.922026-06-19
2RohanGanga1342314.262026-12-15
3SwatiKaveri2792306.822025-09-22
4HarishGanga2501867.612025-10-10
5NaveenYamuna1112282.332025-06-13
6AmanGanga1012423.742026-07-10

Table: BLOCK

BlockWardenRooms
GangaMr. Jha40
YamunaMs. Das35
KaveriMr. Pal50
Answer
(i)
SELECT Block, COUNT(*) FROM HOSTEL GROUP BY Block HAVING COUNT(*) > 1;
BlockCOUNT(*)
Ganga3
Yamuna2

Explanation: GROUP BY Block makes 3 groups (Ganga, Kaveri, Yamuna); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Block, MAX(Room) FROM HOSTEL GROUP BY Block ORDER BY MAX(Room) DESC;
BlockMAX(Room)
Kaveri279
Ganga250
Yamuna164

Explanation: GROUP BY Block makes 3 groups (Ganga, Kaveri, Yamuna); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Room) arranges the result in descending (largest first) order.

(iii)
SELECT SName, Warden FROM HOSTEL, BLOCK WHERE HOSTEL.Block = BLOCK.Block;
SNameWarden
ChetanMs. Das
RohanMr. Jha
SwatiMr. Pal
HarishMr. Jha
NaveenMs. Das
AmanMr. Jha

Explanation: The two tables HOSTEL and BLOCK are joined: only the row pairs where HOSTEL.Block = BLOCK.Block are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT SName, Room, Rooms FROM HOSTEL, BLOCK WHERE HOSTEL.Block = BLOCK.Block AND Room > 134;
SNameRoomRooms
Chetan16435
Swati27950
Harish25040

Explanation: The two tables HOSTEL and BLOCK are joined: only the row pairs where HOSTEL.Block = BLOCK.Block are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Room is more than 134.

D2.28Practice4 marks

Consider the tables HOSTEL and BLOCK given below. Write the output of the following queries.

Table: HOSTEL

HNoSNameBlockRoomMessDOA
1ChetanYamuna1643027.922026-06-19
2RohanGanga1342314.262026-12-15
3SwatiKaveri2792306.822025-09-22
4HarishGanga2501867.612025-10-10
5NaveenYamuna1112282.332025-06-13
6AmanGanga1012423.742026-07-10

Table: BLOCK

BlockWardenRooms
GangaMr. Jha40
YamunaMs. Das35
KaveriMr. Pal50
(i) SELECT Block, SUM(Room) FROM HOSTEL GROUP BY Block HAVING SUM(Room) > 275;
(ii) SELECT Block, COUNT(*) FROM HOSTEL GROUP BY Block;
(iii) SELECT SName, Room, Rooms FROM HOSTEL, BLOCK WHERE HOSTEL.Block = BLOCK.Block AND Room > 134;
(iv) SELECT SName, Warden FROM HOSTEL, BLOCK WHERE HOSTEL.Block = BLOCK.Block AND Warden = 'Mr. Jha';
Answer
(i)
BlockSUM(Room)
Ganga485
Kaveri279

Explanation: GROUP BY Block makes 3 groups (Ganga, Kaveri, Yamuna); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Room) is more than 275. SUM adds the values.

(ii)
BlockCOUNT(*)
Ganga3
Kaveri1
Yamuna2

Explanation: GROUP BY Block makes 3 groups (Ganga, Kaveri, Yamuna); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
SNameRoomRooms
Chetan16435
Swati27950
Harish25040

Explanation: The two tables HOSTEL and BLOCK are joined: only the row pairs where HOSTEL.Block = BLOCK.Block are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Room is more than 134.

(iv)
SNameWarden
RohanMr. Jha
HarishMr. Jha
AmanMr. Jha

Explanation: The two tables HOSTEL and BLOCK are joined: only the row pairs where HOSTEL.Block = BLOCK.Block are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Warden is 'Mr. Jha'.

D2.29Practice4 marks

Consider the tables LOAN and LOANTYPE given below. Write SQL queries to display:

  1. Each Type and the number of rows in it
  2. Each Type and its total Years, only for the groups whose total Years is more than 15
  3. The CName of each row with the Officer of its Type, using both the tables
  4. The CName, Years and MaxYears of the rows where Years is more than 10, using both the tables.

Table: LOAN

LNoCNameTypeYearsRateStartDate
1DivyaEducation1911.172020-11-18
2SachinHome39.022022-04-01
3NaveenCar129.462023-07-07
4SandeepCar29.922026-03-01
5UmeshHome1010.252021-02-05
6RituHome178.622025-08-06

Table: LOANTYPE

TypeOfficerMaxYears
HomeMr. Sethi20
CarMs. Vohra7
EducationMr. Lal10
Answer
(i)
SELECT Type, COUNT(*) FROM LOAN GROUP BY Type;
TypeCOUNT(*)
Car2
Education1
Home3

Explanation: GROUP BY Type makes 3 groups (Car, Education, Home); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Type, SUM(Years) FROM LOAN GROUP BY Type HAVING SUM(Years) > 15;
TypeSUM(Years)
Education19
Home30

Explanation: GROUP BY Type makes 3 groups (Car, Education, Home); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Years) is more than 15. SUM adds the values.

(iii)
SELECT CName, Officer FROM LOAN, LOANTYPE WHERE LOAN.Type = LOANTYPE.Type;
CNameOfficer
DivyaMr. Lal
SachinMr. Sethi
NaveenMs. Vohra
SandeepMs. Vohra
UmeshMr. Sethi
RituMr. Sethi

Explanation: The two tables LOAN and LOANTYPE are joined: only the row pairs where LOAN.Type = LOANTYPE.Type are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT CName, Years, MaxYears FROM LOAN, LOANTYPE WHERE LOAN.Type = LOANTYPE.Type AND Years > 10;
CNameYearsMaxYears
Divya1910
Naveen127
Ritu1720

Explanation: The two tables LOAN and LOANTYPE are joined: only the row pairs where LOAN.Type = LOANTYPE.Type are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Years is more than 10.

D2.30Practice4 marks

Consider the tables LOAN and LOANTYPE given below. Write the output of the following queries.

Table: LOAN

LNoCNameTypeYearsRateStartDate
1DivyaEducation1911.172020-11-18
2SachinHome39.022022-04-01
3NaveenCar129.462023-07-07
4SandeepCar29.922026-03-01
5UmeshHome1010.252021-02-05
6RituHome178.622025-08-06

Table: LOANTYPE

TypeOfficerMaxYears
HomeMr. Sethi20
CarMs. Vohra7
EducationMr. Lal10
(i) SELECT Type, COUNT(*) FROM LOAN GROUP BY Type HAVING COUNT(*) > 1;
(ii) SELECT Type, MAX(Years) FROM LOAN GROUP BY Type ORDER BY MAX(Years) DESC;
(iii) SELECT CName, Years, MaxYears FROM LOAN, LOANTYPE WHERE LOAN.Type = LOANTYPE.Type AND Years > 10;
(iv) SELECT CName, Officer FROM LOAN, LOANTYPE WHERE LOAN.Type = LOANTYPE.Type AND Officer = 'Mr. Sethi';
Answer
(i)
TypeCOUNT(*)
Car2
Home3

Explanation: GROUP BY Type makes 3 groups (Car, Education, Home); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
TypeMAX(Years)
Education19
Home17
Car12

Explanation: GROUP BY Type makes 3 groups (Car, Education, Home); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Years) arranges the result in descending (largest first) order.

(iii)
CNameYearsMaxYears
Divya1910
Naveen127
Ritu1720

Explanation: The two tables LOAN and LOANTYPE are joined: only the row pairs where LOAN.Type = LOANTYPE.Type are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Years is more than 10.

(iv)
CNameOfficer
SachinMr. Sethi
UmeshMr. Sethi
RituMr. Sethi

Explanation: The two tables LOAN and LOANTYPE are joined: only the row pairs where LOAN.Type = LOANTYPE.Type are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Officer is 'Mr. Sethi'.

D2.31Practice4 marks

Consider the tables STAFF and POST given below. Write SQL queries to display:

  1. The Post that have more than one row
  2. Each Post with its highest Periods, in descending order of the highest Periods
  3. The SName of each row with the PayLevel of its Post, using both the tables
  4. The SName, Periods and Vacancy of the rows where Periods is more than 25, using both the tables.

Table: STAFF

SNoSNamePostPeriodsAllowanceDOJ
1RachnaTGT216326.052023-07-03
2MeenalPGT315316.672023-02-03
3SandeepPGT183601.572015-03-06
4YashPGT256358.032011-05-26
5RituPRT305793.032022-08-12
6FarhanTGT335942.382014-11-17

Table: POST

PostPayLevelVacancy
PGTL82
TGTL74
PRTL63
Answer
(i)
SELECT Post, COUNT(*) FROM STAFF GROUP BY Post HAVING COUNT(*) > 1;
PostCOUNT(*)
PGT3
TGT2

Explanation: GROUP BY Post makes 3 groups (PGT, PRT, TGT); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Post, MAX(Periods) FROM STAFF GROUP BY Post ORDER BY MAX(Periods) DESC;
PostMAX(Periods)
TGT33
PGT31
PRT30

Explanation: GROUP BY Post makes 3 groups (PGT, PRT, TGT); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Periods) arranges the result in descending (largest first) order.

(iii)
SELECT SName, PayLevel FROM STAFF, POST WHERE STAFF.Post = POST.Post;
SNamePayLevel
RachnaL7
MeenalL8
SandeepL8
YashL8
RituL6
FarhanL7

Explanation: The two tables STAFF and POST are joined: only the row pairs where STAFF.Post = POST.Post are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT SName, Periods, Vacancy FROM STAFF, POST WHERE STAFF.Post = POST.Post AND Periods > 25;
SNamePeriodsVacancy
Meenal312
Ritu303
Farhan334

Explanation: The two tables STAFF and POST are joined: only the row pairs where STAFF.Post = POST.Post are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Periods is more than 25.

D2.32Practice4 marks

Consider the tables STAFF and POST given below. Write the output of the following queries.

Table: STAFF

SNoSNamePostPeriodsAllowanceDOJ
1RachnaTGT216326.052023-07-03
2MeenalPGT315316.672023-02-03
3SandeepPGT183601.572015-03-06
4YashPGT256358.032011-05-26
5RituPRT305793.032022-08-12
6FarhanTGT335942.382014-11-17

Table: POST

PostPayLevelVacancy
PGTL82
TGTL74
PRTL63
(i) SELECT Post, SUM(Periods) FROM STAFF GROUP BY Post HAVING SUM(Periods) > 50;
(ii) SELECT Post, COUNT(*) FROM STAFF GROUP BY Post;
(iii) SELECT SName, Periods, Vacancy FROM STAFF, POST WHERE STAFF.Post = POST.Post AND Periods > 25;
(iv) SELECT SName, PayLevel FROM STAFF, POST WHERE STAFF.Post = POST.Post AND PayLevel = 'L8';
Answer
(i)
PostSUM(Periods)
PGT74
TGT54

Explanation: GROUP BY Post makes 3 groups (PGT, PRT, TGT); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Periods) is more than 50. SUM adds the values.

(ii)
PostCOUNT(*)
PGT3
PRT1
TGT2

Explanation: GROUP BY Post makes 3 groups (PGT, PRT, TGT); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
SNamePeriodsVacancy
Meenal312
Ritu303
Farhan334

Explanation: The two tables STAFF and POST are joined: only the row pairs where STAFF.Post = POST.Post are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Periods is more than 25.

(iv)
SNamePayLevel
MeenalL8
SandeepL8
YashL8

Explanation: The two tables STAFF and POST are joined: only the row pairs where STAFF.Post = POST.Post are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: PayLevel is 'L8'.

D2.33Practice4 marks

Consider the tables GARMENT and FABRIC given below. Write SQL queries to display:

  1. Each Fabric and the number of rows in it
  2. Each Fabric and its total Stock, only for the groups whose total Stock is more than 40
  3. The GName of each row with the Mill of its Fabric, using both the tables
  4. The GName, Stock and Rate of the rows where Stock is more than 15, using both the tables.

Table: GARMENT

GCodeGNameFabricStockPriceLaunch
10ShirtCotton151434.772025-06-21
11JeansSilk253035.632025-11-15
12KurtaDenim52149.332026-03-28
13JacketCotton101170.282025-10-06
14SareeDenim35787.832025-11-07
15FrockCotton451436.342025-09-11

Table: FABRIC

FabricMillRate
CottonArvind120
DenimRaymond250
SilkMysore600
Answer
(i)
SELECT Fabric, COUNT(*) FROM GARMENT GROUP BY Fabric;
FabricCOUNT(*)
Cotton3
Denim2
Silk1

Explanation: GROUP BY Fabric makes 3 groups (Cotton, Denim, Silk); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Fabric, SUM(Stock) FROM GARMENT GROUP BY Fabric HAVING SUM(Stock) > 40;
FabricSUM(Stock)
Cotton70

Explanation: GROUP BY Fabric makes 3 groups (Cotton, Denim, Silk); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Stock) is more than 40. SUM adds the values.

(iii)
SELECT GName, Mill FROM GARMENT, FABRIC WHERE GARMENT.Fabric = FABRIC.Fabric;
GNameMill
ShirtArvind
JeansMysore
KurtaRaymond
JacketArvind
SareeRaymond
FrockArvind

Explanation: The two tables GARMENT and FABRIC are joined: only the row pairs where GARMENT.Fabric = FABRIC.Fabric are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT GName, Stock, Rate FROM GARMENT, FABRIC WHERE GARMENT.Fabric = FABRIC.Fabric AND Stock > 15;
GNameStockRate
Jeans25600
Saree35250
Frock45120

Explanation: The two tables GARMENT and FABRIC are joined: only the row pairs where GARMENT.Fabric = FABRIC.Fabric are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Stock is more than 15.

D2.34Practice4 marks

Consider the tables GARMENT and FABRIC given below. Write the output of the following queries.

Table: GARMENT

GCodeGNameFabricStockPriceLaunch
10ShirtCotton151434.772025-06-21
11JeansSilk253035.632025-11-15
12KurtaDenim52149.332026-03-28
13JacketCotton101170.282025-10-06
14SareeDenim35787.832025-11-07
15FrockCotton451436.342025-09-11

Table: FABRIC

FabricMillRate
CottonArvind120
DenimRaymond250
SilkMysore600
(i) SELECT Fabric, COUNT(*) FROM GARMENT GROUP BY Fabric HAVING COUNT(*) > 1;
(ii) SELECT Fabric, MAX(Stock) FROM GARMENT GROUP BY Fabric ORDER BY MAX(Stock) DESC;
(iii) SELECT GName, Stock, Rate FROM GARMENT, FABRIC WHERE GARMENT.Fabric = FABRIC.Fabric AND Stock > 15;
(iv) SELECT GName, Mill FROM GARMENT, FABRIC WHERE GARMENT.Fabric = FABRIC.Fabric AND Mill = 'Arvind';
Answer
(i)
FabricCOUNT(*)
Cotton3
Denim2

Explanation: GROUP BY Fabric makes 3 groups (Cotton, Denim, Silk); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
FabricMAX(Stock)
Cotton45
Denim35
Silk25

Explanation: GROUP BY Fabric makes 3 groups (Cotton, Denim, Silk); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Stock) arranges the result in descending (largest first) order.

(iii)
GNameStockRate
Jeans25600
Saree35250
Frock45120

Explanation: The two tables GARMENT and FABRIC are joined: only the row pairs where GARMENT.Fabric = FABRIC.Fabric are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Stock is more than 15.

(iv)
GNameMill
ShirtArvind
JacketArvind
FrockArvind

Explanation: The two tables GARMENT and FABRIC are joined: only the row pairs where GARMENT.Fabric = FABRIC.Fabric are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Mill is 'Arvind'.

D2.35Practice4 marks

Consider the tables EVENT and HOUSE given below. Write SQL queries to display:

  1. The House that have more than one row
  2. Each House with its highest Points, in descending order of the highest Points
  3. The EName of each row with the Captain of its House, using both the tables
  4. The EName, Points and Members of the rows where Points is more than 60, using both the tables.

Table: EVENT

ENoENameHousePointsPrizeEDate
1DebateShivaji302874.632026-07-02
2QuizRaman1002924.742026-07-15
3DanceShivaji602767.112026-02-14
4DramaRaman552300.042026-12-19
5PaintingShivaji954017.092026-08-25
6SingingTagore751901.592026-10-04

Table: HOUSE

HouseCaptainMembers
ShivajiRhea120
TagoreKabir115
RamanMitali125
Answer
(i)
SELECT House, COUNT(*) FROM EVENT GROUP BY House HAVING COUNT(*) > 1;
HouseCOUNT(*)
Raman2
Shivaji3

Explanation: GROUP BY House makes 3 groups (Raman, Shivaji, Tagore); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT House, MAX(Points) FROM EVENT GROUP BY House ORDER BY MAX(Points) DESC;
HouseMAX(Points)
Raman100
Shivaji95
Tagore75

Explanation: GROUP BY House makes 3 groups (Raman, Shivaji, Tagore); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Points) arranges the result in descending (largest first) order.

(iii)
SELECT EName, Captain FROM EVENT, HOUSE WHERE EVENT.House = HOUSE.House;
ENameCaptain
DebateRhea
QuizMitali
DanceRhea
DramaMitali
PaintingRhea
SingingKabir

Explanation: The two tables EVENT and HOUSE are joined: only the row pairs where EVENT.House = HOUSE.House are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT EName, Points, Members FROM EVENT, HOUSE WHERE EVENT.House = HOUSE.House AND Points > 60;
ENamePointsMembers
Quiz100125
Painting95120
Singing75115

Explanation: The two tables EVENT and HOUSE are joined: only the row pairs where EVENT.House = HOUSE.House are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Points is more than 60.

D2.36Practice4 marks

Consider the tables EVENT and HOUSE given below. Write the output of the following queries.

Table: EVENT

ENoENameHousePointsPrizeEDate
1DebateShivaji302874.632026-07-02
2QuizRaman1002924.742026-07-15
3DanceShivaji602767.112026-02-14
4DramaRaman552300.042026-12-19
5PaintingShivaji954017.092026-08-25
6SingingTagore751901.592026-10-04

Table: HOUSE

HouseCaptainMembers
ShivajiRhea120
TagoreKabir115
RamanMitali125
(i) SELECT House, SUM(Points) FROM EVENT GROUP BY House HAVING SUM(Points) > 155;
(ii) SELECT House, COUNT(*) FROM EVENT GROUP BY House;
(iii) SELECT EName, Points, Members FROM EVENT, HOUSE WHERE EVENT.House = HOUSE.House AND Points > 60;
(iv) SELECT EName, Captain FROM EVENT, HOUSE WHERE EVENT.House = HOUSE.House AND Captain = 'Rhea';
Answer
(i)
HouseSUM(Points)
Shivaji185

Explanation: GROUP BY House makes 3 groups (Raman, Shivaji, Tagore); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Points) is more than 155. SUM adds the values.

(ii)
HouseCOUNT(*)
Raman2
Shivaji3
Tagore1

Explanation: GROUP BY House makes 3 groups (Raman, Shivaji, Tagore); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
ENamePointsMembers
Quiz100125
Painting95120
Singing75115

Explanation: The two tables EVENT and HOUSE are joined: only the row pairs where EVENT.House = HOUSE.House are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Points is more than 60.

(iv)
ENameCaptain
DebateRhea
DanceRhea
PaintingRhea

Explanation: The two tables EVENT and HOUSE are joined: only the row pairs where EVENT.House = HOUSE.House are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Captain is 'Rhea'.

D2.37Practice4 marks

Consider the tables TRAIN and ZONE given below. Write SQL queries to display:

  1. Each Zone and the number of rows in it
  2. Each Zone and its total Coaches, only for the groups whose total Coaches is more than 30
  3. The TName of each row with the HQ of its Zone, using both the tables
  4. The TName, Coaches and Divisions of the rows where Coaches is more than 17, using both the tables.

Table: TRAIN

TNoTNameZoneCoachesFareStartDate
12001RajdhaniNorthern172750.732017-02-22
12002ShatabdiSouthern242125.092024-03-03
12003DurontoNorthern132277.832024-03-16
12004Garib RathSouthern103012.732021-04-10
12005TejasWestern182091.892015-02-17
12006Vande BharatNorthern201399.692020-04-10

Table: ZONE

ZoneHQDivisions
NorthernNew Delhi5
WesternMumbai6
SouthernChennai6
Answer
(i)
SELECT Zone, COUNT(*) FROM TRAIN GROUP BY Zone;
ZoneCOUNT(*)
Northern3
Southern2
Western1

Explanation: GROUP BY Zone makes 3 groups (Northern, Southern, Western); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Zone, SUM(Coaches) FROM TRAIN GROUP BY Zone HAVING SUM(Coaches) > 30;
ZoneSUM(Coaches)
Northern50
Southern34

Explanation: GROUP BY Zone makes 3 groups (Northern, Southern, Western); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Coaches) is more than 30. SUM adds the values.

(iii)
SELECT TName, HQ FROM TRAIN, ZONE WHERE TRAIN.Zone = ZONE.Zone;
TNameHQ
RajdhaniNew Delhi
ShatabdiChennai
DurontoNew Delhi
Garib RathChennai
TejasMumbai
Vande BharatNew Delhi

Explanation: The two tables TRAIN and ZONE are joined: only the row pairs where TRAIN.Zone = ZONE.Zone are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT TName, Coaches, Divisions FROM TRAIN, ZONE WHERE TRAIN.Zone = ZONE.Zone AND Coaches > 17;
TNameCoachesDivisions
Shatabdi246
Tejas186
Vande Bharat205

Explanation: The two tables TRAIN and ZONE are joined: only the row pairs where TRAIN.Zone = ZONE.Zone are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Coaches is more than 17.

D2.38Practice4 marks

Consider the tables TRAIN and ZONE given below. Write the output of the following queries.

Table: TRAIN

TNoTNameZoneCoachesFareStartDate
12001RajdhaniNorthern172750.732017-02-22
12002ShatabdiSouthern242125.092024-03-03
12003DurontoNorthern132277.832024-03-16
12004Garib RathSouthern103012.732021-04-10
12005TejasWestern182091.892015-02-17
12006Vande BharatNorthern201399.692020-04-10

Table: ZONE

ZoneHQDivisions
NorthernNew Delhi5
WesternMumbai6
SouthernChennai6
(i) SELECT Zone, COUNT(*) FROM TRAIN GROUP BY Zone HAVING COUNT(*) > 1;
(ii) SELECT Zone, MAX(Coaches) FROM TRAIN GROUP BY Zone ORDER BY MAX(Coaches) DESC;
(iii) SELECT TName, Coaches, Divisions FROM TRAIN, ZONE WHERE TRAIN.Zone = ZONE.Zone AND Coaches > 17;
(iv) SELECT TName, HQ FROM TRAIN, ZONE WHERE TRAIN.Zone = ZONE.Zone AND HQ = 'New Delhi';
Answer
(i)
ZoneCOUNT(*)
Northern3
Southern2

Explanation: GROUP BY Zone makes 3 groups (Northern, Southern, Western); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
ZoneMAX(Coaches)
Southern24
Northern20
Western18

Explanation: GROUP BY Zone makes 3 groups (Northern, Southern, Western); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Coaches) arranges the result in descending (largest first) order.

(iii)
TNameCoachesDivisions
Shatabdi246
Tejas186
Vande Bharat205

Explanation: The two tables TRAIN and ZONE are joined: only the row pairs where TRAIN.Zone = ZONE.Zone are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Coaches is more than 17.

(iv)
TNameHQ
RajdhaniNew Delhi
DurontoNew Delhi
Vande BharatNew Delhi

Explanation: The two tables TRAIN and ZONE are joined: only the row pairs where TRAIN.Zone = ZONE.Zone are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: HQ is 'New Delhi'.

D2.39Practice4 marks

Consider the tables LAPTOP and BRAND given below. Write SQL queries to display:

  1. The Brand that have more than one row
  2. Each Brand with its highest RAM, in descending order of the highest RAM
  3. The Model of each row with the Country of its Brand, using both the tables
  4. The Model, RAM and Warranty of the rows where RAM is more than 16, using both the tables.

Table: LAPTOP

LNoModelBrandRAMPriceLaunch
1Astra 5Orbit1686696.752026-11-10
2Bolt XZenit2884541.932025-10-22
3Comet ProZenit3284965.492026-03-21
4Dyna AirZenit2470706.772025-05-13
5Eon LiteOrbit1241551.162026-07-03
6Flex 14Nova442044.122026-11-12

Table: BRAND

BrandCountryWarranty
ZenitIndia2
OrbitJapan1
NovaKorea3
Answer
(i)
SELECT Brand, COUNT(*) FROM LAPTOP GROUP BY Brand HAVING COUNT(*) > 1;
BrandCOUNT(*)
Orbit2
Zenit3

Explanation: GROUP BY Brand makes 3 groups (Nova, Orbit, Zenit); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Brand, MAX(RAM) FROM LAPTOP GROUP BY Brand ORDER BY MAX(RAM) DESC;
BrandMAX(RAM)
Zenit32
Orbit16
Nova4

Explanation: GROUP BY Brand makes 3 groups (Nova, Orbit, Zenit); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(RAM) arranges the result in descending (largest first) order.

(iii)
SELECT Model, Country FROM LAPTOP, BRAND WHERE LAPTOP.Brand = BRAND.Brand;
ModelCountry
Astra 5Japan
Bolt XIndia
Comet ProIndia
Dyna AirIndia
Eon LiteJapan
Flex 14Korea

Explanation: The two tables LAPTOP and BRAND are joined: only the row pairs where LAPTOP.Brand = BRAND.Brand are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT Model, RAM, Warranty FROM LAPTOP, BRAND WHERE LAPTOP.Brand = BRAND.Brand AND RAM > 16;
ModelRAMWarranty
Bolt X282
Comet Pro322
Dyna Air242

Explanation: The two tables LAPTOP and BRAND are joined: only the row pairs where LAPTOP.Brand = BRAND.Brand are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: RAM is more than 16.

D2.40Practice4 marks

Consider the tables LAPTOP and BRAND given below. Write the output of the following queries.

Table: LAPTOP

LNoModelBrandRAMPriceLaunch
1Astra 5Orbit1686696.752026-11-10
2Bolt XZenit2884541.932025-10-22
3Comet ProZenit3284965.492026-03-21
4Dyna AirZenit2470706.772025-05-13
5Eon LiteOrbit1241551.162026-07-03
6Flex 14Nova442044.122026-11-12

Table: BRAND

BrandCountryWarranty
ZenitIndia2
OrbitJapan1
NovaKorea3
(i) SELECT Brand, SUM(RAM) FROM LAPTOP GROUP BY Brand HAVING SUM(RAM) > 25;
(ii) SELECT Brand, COUNT(*) FROM LAPTOP GROUP BY Brand;
(iii) SELECT Model, RAM, Warranty FROM LAPTOP, BRAND WHERE LAPTOP.Brand = BRAND.Brand AND RAM > 16;
(iv) SELECT Model, Country FROM LAPTOP, BRAND WHERE LAPTOP.Brand = BRAND.Brand AND Country = 'India';
Answer
(i)
BrandSUM(RAM)
Orbit28
Zenit84

Explanation: GROUP BY Brand makes 3 groups (Nova, Orbit, Zenit); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(RAM) is more than 25. SUM adds the values.

(ii)
BrandCOUNT(*)
Nova1
Orbit2
Zenit3

Explanation: GROUP BY Brand makes 3 groups (Nova, Orbit, Zenit); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
ModelRAMWarranty
Bolt X282
Comet Pro322
Dyna Air242

Explanation: The two tables LAPTOP and BRAND are joined: only the row pairs where LAPTOP.Brand = BRAND.Brand are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: RAM is more than 16.

(iv)
ModelCountry
Bolt XIndia
Comet ProIndia
Dyna AirIndia

Explanation: The two tables LAPTOP and BRAND are joined: only the row pairs where LAPTOP.Brand = BRAND.Brand are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Country is 'India'.

D2.41Practice4 marks

Consider the tables CLUB and ACTIVITY given below. Write SQL queries to display:

  1. Each Activity and the number of rows in it
  2. Each Activity and its total Age, only for the groups whose total Age is more than 40
  3. The MName of each row with the Trainer of its Activity, using both the tables
  4. The MName, Age and Days of the rows where Age is more than 27, using both the tables.

Table: CLUB

CNoMNameActivityAgeFeeDOJ
1FarhanTennis271058.822026-12-05
2BhavnaSwimming422296.532023-02-14
3LokeshYoga16805.042023-11-02
4SimranYoga361759.992026-03-27
5SachinTennis173396.682026-04-14
6MohitYoga561552.632023-06-09

Table: ACTIVITY

ActivityTrainerDays
YogaMs. Uma6
SwimmingMr. Zaid5
TennisMs. Tara3
Answer
(i)
SELECT Activity, COUNT(*) FROM CLUB GROUP BY Activity;
ActivityCOUNT(*)
Swimming1
Tennis2
Yoga3

Explanation: GROUP BY Activity makes 3 groups (Swimming, Tennis, Yoga); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(ii)
SELECT Activity, SUM(Age) FROM CLUB GROUP BY Activity HAVING SUM(Age) > 40;
ActivitySUM(Age)
Swimming42
Tennis44
Yoga108

Explanation: GROUP BY Activity makes 3 groups (Swimming, Tennis, Yoga); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Age) is more than 40. SUM adds the values.

(iii)
SELECT MName, Trainer FROM CLUB, ACTIVITY WHERE CLUB.Activity = ACTIVITY.Activity;
MNameTrainer
FarhanMs. Tara
BhavnaMr. Zaid
LokeshMs. Uma
SimranMs. Uma
SachinMs. Tara
MohitMs. Uma

Explanation: The two tables CLUB and ACTIVITY are joined: only the row pairs where CLUB.Activity = ACTIVITY.Activity are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT MName, Age, Days FROM CLUB, ACTIVITY WHERE CLUB.Activity = ACTIVITY.Activity AND Age > 27;
MNameAgeDays
Bhavna425
Simran366
Mohit566

Explanation: The two tables CLUB and ACTIVITY are joined: only the row pairs where CLUB.Activity = ACTIVITY.Activity are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Age is more than 27.

D2.42Practice4 marks

Consider the tables CLUB and ACTIVITY given below. Write the output of the following queries.

Table: CLUB

CNoMNameActivityAgeFeeDOJ
1FarhanTennis271058.822026-12-05
2BhavnaSwimming422296.532023-02-14
3LokeshYoga16805.042023-11-02
4SimranYoga361759.992026-03-27
5SachinTennis173396.682026-04-14
6MohitYoga561552.632023-06-09

Table: ACTIVITY

ActivityTrainerDays
YogaMs. Uma6
SwimmingMr. Zaid5
TennisMs. Tara3
(i) SELECT Activity, COUNT(*) FROM CLUB GROUP BY Activity HAVING COUNT(*) > 1;
(ii) SELECT Activity, MAX(Age) FROM CLUB GROUP BY Activity ORDER BY MAX(Age) DESC;
(iii) SELECT MName, Age, Days FROM CLUB, ACTIVITY WHERE CLUB.Activity = ACTIVITY.Activity AND Age > 27;
(iv) SELECT MName, Trainer FROM CLUB, ACTIVITY WHERE CLUB.Activity = ACTIVITY.Activity AND Trainer = 'Ms. Uma';
Answer
(i)
ActivityCOUNT(*)
Tennis2
Yoga3

Explanation: GROUP BY Activity makes 3 groups (Swimming, Tennis, Yoga); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
ActivityMAX(Age)
Yoga56
Swimming42
Tennis27

Explanation: GROUP BY Activity makes 3 groups (Swimming, Tennis, Yoga); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Age) arranges the result in descending (largest first) order.

(iii)
MNameAgeDays
Bhavna425
Simran366
Mohit566

Explanation: The two tables CLUB and ACTIVITY are joined: only the row pairs where CLUB.Activity = ACTIVITY.Activity are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Age is more than 27.

(iv)
MNameTrainer
LokeshMs. Uma
SimranMs. Uma
MohitMs. Uma

Explanation: The two tables CLUB and ACTIVITY are joined: only the row pairs where CLUB.Activity = ACTIVITY.Activity are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Trainer is 'Ms. Uma'.

D2.43Practice4 marks

Consider the tables FARM and CROP given below. Write SQL queries to display:

  1. The Crop that have more than one row
  2. Each Crop with its highest Acres, in descending order of the highest Acres
  3. The Farmer of each row with the Season of its Crop, using both the tables
  4. The Farmer, Acres and Days of the rows where Acres is more than 11, using both the tables.

Table: FARM

FNoFarmerCropAcresYieldSowDate
1ArjunMaize3934.422026-12-19
2AnitaWheat940.162025-07-19
3IshaRice1124.932026-02-23
4SonalWheat1646.042025-06-25
5VandanaRice641.022026-10-11
6HarishWheat2323.822025-11-28

Table: CROP

CropSeasonDays
WheatRabi120
RiceKharif150
MaizeZaid100
Answer
(i)
SELECT Crop, COUNT(*) FROM FARM GROUP BY Crop HAVING COUNT(*) > 1;
CropCOUNT(*)
Rice2
Wheat3

Explanation: GROUP BY Crop makes 3 groups (Maize, Rice, Wheat); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where COUNT(*) is more than 1. COUNT(*) counts the rows.

(ii)
SELECT Crop, MAX(Acres) FROM FARM GROUP BY Crop ORDER BY MAX(Acres) DESC;
CropMAX(Acres)
Maize39
Wheat23
Rice11

Explanation: GROUP BY Crop makes 3 groups (Maize, Rice, Wheat); the aggregate function is worked out separately for each group. MAX gives the largest value. ORDER BY MAX(Acres) arranges the result in descending (largest first) order.

(iii)
SELECT Farmer, Season FROM FARM, CROP WHERE FARM.Crop = CROP.Crop;
FarmerSeason
ArjunZaid
AnitaRabi
IshaKharif
SonalRabi
VandanaKharif
HarishRabi

Explanation: The two tables FARM and CROP are joined: only the row pairs where FARM.Crop = CROP.Crop are kept (an equi-join). The join gives 6 rows.

(iv)
SELECT Farmer, Acres, Days FROM FARM, CROP WHERE FARM.Crop = CROP.Crop AND Acres > 11;
FarmerAcresDays
Arjun39100
Sonal16120
Harish23120

Explanation: The two tables FARM and CROP are joined: only the row pairs where FARM.Crop = CROP.Crop are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Acres is more than 11.

D2.44Practice4 marks

Consider the tables FARM and CROP given below. Write the output of the following queries.

Table: FARM

FNoFarmerCropAcresYieldSowDate
1ArjunMaize3934.422026-12-19
2AnitaWheat940.162025-07-19
3IshaRice1124.932026-02-23
4SonalWheat1646.042025-06-25
5VandanaRice641.022026-10-11
6HarishWheat2323.822025-11-28

Table: CROP

CropSeasonDays
WheatRabi120
RiceKharif150
MaizeZaid100
(i) SELECT Crop, SUM(Acres) FROM FARM GROUP BY Crop HAVING SUM(Acres) > 35;
(ii) SELECT Crop, COUNT(*) FROM FARM GROUP BY Crop;
(iii) SELECT Farmer, Acres, Days FROM FARM, CROP WHERE FARM.Crop = CROP.Crop AND Acres > 11;
(iv) SELECT Farmer, Season FROM FARM, CROP WHERE FARM.Crop = CROP.Crop AND Season = 'Rabi';
Answer
(i)
CropSUM(Acres)
Maize39
Wheat48

Explanation: GROUP BY Crop makes 3 groups (Maize, Rice, Wheat); the aggregate function is worked out separately for each group. HAVING then keeps only the groups where SUM(Acres) is more than 35. SUM adds the values.

(ii)
CropCOUNT(*)
Maize1
Rice2
Wheat3

Explanation: GROUP BY Crop makes 3 groups (Maize, Rice, Wheat); the aggregate function is worked out separately for each group. COUNT(*) counts the rows.

(iii)
FarmerAcresDays
Arjun39100
Sonal16120
Harish23120

Explanation: The two tables FARM and CROP are joined: only the row pairs where FARM.Crop = CROP.Crop are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Acres is more than 11.

(iv)
FarmerSeason
AnitaRabi
SonalRabi
HarishRabi

Explanation: The two tables FARM and CROP are joined: only the row pairs where FARM.Crop = CROP.Crop are kept (an equi-join). Of the 6 joined rows, 3 match the other condition: Season is 'Rabi'.

Section E · 5 marks each

E1Network case study5 marks · 24 questions
E1.1Practice5 marks

Vidya Public School, Nagpur. Vidya Public School in Nagpur is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

60 m35 m140 m65 m55 m40 mADMIN215 computersLIBRARY210 computersSCIENCE95 computersHOSTEL40 computers

Number of computers

BlockComputers
ADMIN215
LIBRARY210
SCIENCE95
HOSTEL40

Distance between blocks

FromToDistance
ADMINLIBRARY60 m
ADMINSCIENCE140 m
ADMINHOSTEL55 m
LIBRARYSCIENCE40 m
LIBRARYHOSTEL65 m
SCIENCEHOSTEL35 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation wants a website on which each user logs in and sees his or her own details. Should the web pages be static or dynamic? Give a reason.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. ADMIN block, because it has the largest number of computers (215). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (ADMIN, LIBRARY, SCIENCE, HOSTEL). It sends the data only to the computer it is meant for.
  4. Dynamic. The content changes for each user and comes from a database. A static page shows the same content to everyone.
  5. Between ADMIN and SCIENCE (140 m), because the cable is longer than 100 m and the signal becomes weak. The other links are shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

60 m140 mR55 mADMINSERVER + switchLIBRARYswitchSCIENCEswitchHOSTELswitch
E1.2Practice5 marks

Sunrise Textiles, Surat. Sunrise Textiles in Surat is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

80 m115 m150 m150 m60 m40 mHR180 computersSALES190 computersPRODUCTION25 computersSTORE60 computers

Number of computers

BlockComputers
HR180
SALES190
PRODUCTION25
STORE60

Distance between blocks

FromToDistance
HRSALES80 m
HRPRODUCTION150 m
HRSTORE60 m
SALESPRODUCTION40 m
SALESSTORE150 m
PRODUCTIONSTORE115 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation has one more office in Kolkata. Which type of network (PAN, LAN, MAN or WAN) will be formed when the two offices are connected?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. SALES block, because it has the largest number of computers (190). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (HR, SALES, PRODUCTION, STORE). It sends the data only to the computer it is meant for.
  4. WAN (Wide Area Network), because the two offices are in different cities, far from each other.
  5. Between SALES and STORE (150 m), because the cable is longer than 100 m and the signal becomes weak. The other links are shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

80 m40 m150 mRHRswitchSALESSERVER + switchPRODUCTIONswitchSTOREswitch
E1.3Practice5 marks

Lifeline Hospital, Patna. Lifeline Hospital in Patna is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

30 m170 m135 m75 m135 m100 mOPD195 computersLAB80 computersWARD185 computersPHARMACY155 computers

Number of computers

BlockComputers
OPD195
LAB80
WARD185
PHARMACY155

Distance between blocks

FromToDistance
OPDLAB30 m
OPDWARD135 m
OPDPHARMACY135 m
LABWARD100 m
LABPHARMACY75 m
WARDPHARMACY170 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The staff wants to make low-cost voice calls to the office in Chennai through the Internet. Name the technology that makes this possible.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. OPD block, because it has the largest number of computers (195). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (OPD, LAB, WARD, PHARMACY). It sends the data only to the computer it is meant for.
  4. VoIP (Voice over Internet Protocol). It carries the voice as data over the Internet, so the calls are very cheap.
  5. Between OPD and WARD (135 m) and between OPD and PHARMACY (135 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

30 m135 mR135 mROPDSERVER + switchLABswitchWARDswitchPHARMACYswitch
E1.4Practice5 marks

TechNova Institute, Hyderabad. TechNova Institute in Hyderabad is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

145 m100 m60 m115 m30 m80 mRECEPTION80 computersTRAINING230 computersDATA CENTRE25 computersCANTEEN120 computers

Number of computers

BlockComputers
RECEPTION80
TRAINING230
DATA CENTRE25
CANTEEN120

Distance between blocks

FromToDistance
RECEPTIONTRAINING145 m
RECEPTIONDATA CENTRE60 m
RECEPTIONCANTEEN30 m
TRAININGDATA CENTRE80 m
TRAININGCANTEEN115 m
DATA CENTRECANTEEN100 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. Which device will be needed to connect the network of this campus to the Internet? Where should it be placed?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. TRAINING block, because it has the largest number of computers (230). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (RECEPTION, TRAINING, DATA CENTRE, CANTEEN). It sends the data only to the computer it is meant for.
  4. A modem (with a router). It should be placed in the TRAINING block, where the server is.
  5. Between TRAINING and RECEPTION (145 m) and between TRAINING and CANTEEN (115 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

145 mR80 m115 mRRECEPTIONswitchTRAININGSERVER + switchDATA CENTREswitchCANTEENswitch
E1.5Practice5 marks

Green Valley Polytechnic, Dehradun. Green Valley Polytechnic in Dehradun is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

140 m65 m115 m165 m90 m120 mMAIN55 computersANNEXE125 computersWORKSHOP165 computersGUEST HOUSE115 computers

Number of computers

BlockComputers
MAIN55
ANNEXE125
WORKSHOP165
GUEST HOUSE115

Distance between blocks

FromToDistance
MAINANNEXE140 m
MAINWORKSHOP115 m
MAINGUEST HOUSE90 m
ANNEXEWORKSHOP120 m
ANNEXEGUEST HOUSE165 m
WORKSHOPGUEST HOUSE65 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation wants its website to be available on the Internet all the time. What is this service called, and on which kind of computer are the files of the website kept?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. WORKSHOP block, because it has the largest number of computers (165). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (MAIN, ANNEXE, WORKSHOP, GUEST HOUSE). It sends the data only to the computer it is meant for.
  4. Web hosting. The files are kept on a web server, which is connected to the Internet all the time.
  5. Between WORKSHOP and MAIN (115 m) and between WORKSHOP and ANNEXE (120 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

115 mR120 mR65 mMAINswitchANNEXEswitchWORKSHOPSERVER + switchGUEST HOUSEswitch
E1.6Practice5 marks

Daily Times Press, Bhopal. Daily Times Press in Bhopal is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

135 m155 m135 m140 m75 m165 mEDITORIAL120 computersPRINTING110 computersMARKETING60 computersDISPATCH140 computers

Number of computers

BlockComputers
EDITORIAL120
PRINTING110
MARKETING60
DISPATCH140

Distance between blocks

FromToDistance
EDITORIALPRINTING135 m
EDITORIALMARKETING135 m
EDITORIALDISPATCH75 m
PRINTINGMARKETING165 m
PRINTINGDISPATCH140 m
MARKETINGDISPATCH155 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation wants a website on which each user logs in and sees his or her own details. Should the web pages be static or dynamic? Give a reason.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. DISPATCH block, because it has the largest number of computers (140). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (EDITORIAL, PRINTING, MARKETING, DISPATCH). It sends the data only to the computer it is meant for.
  4. Dynamic. The content changes for each user and comes from a database. A static page shows the same content to everyone.
  5. Between DISPATCH and PRINTING (140 m) and between DISPATCH and MARKETING (155 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

75 m140 mR155 mREDITORIALswitchPRINTINGswitchMARKETINGswitchDISPATCHSERVER + switch
E1.7Practice5 marks

Himalaya Sports School, Gangtok. Himalaya Sports School in Gangtok is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

155 m145 m145 m110 m65 m75 mJUNIOR250 computersSENIOR200 computersSPORTS45 computersOFFICE15 computers

Number of computers

BlockComputers
JUNIOR250
SENIOR200
SPORTS45
OFFICE15

Distance between blocks

FromToDistance
JUNIORSENIOR155 m
JUNIORSPORTS145 m
JUNIOROFFICE65 m
SENIORSPORTS75 m
SENIOROFFICE110 m
SPORTSOFFICE145 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation has one more office in Kolkata. Which type of network (PAN, LAN, MAN or WAN) will be formed when the two offices are connected?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. JUNIOR block, because it has the largest number of computers (250). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (JUNIOR, SENIOR, SPORTS, OFFICE). It sends the data only to the computer it is meant for.
  4. WAN (Wide Area Network), because the two offices are in different cities, far from each other.
  5. Between JUNIOR and SENIOR (155 m) and between JUNIOR and SPORTS (145 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

155 mR145 mR65 mJUNIORSERVER + switchSENIORswitchSPORTSswitchOFFICEswitch
E1.8Practice5 marks

Orbit Labs, Bengaluru. Orbit Labs in Bengaluru is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

155 m35 m45 m90 m165 m170 mRESEARCH195 computersDESIGN100 computersTESTING230 computersACCOUNTS85 computers

Number of computers

BlockComputers
RESEARCH195
DESIGN100
TESTING230
ACCOUNTS85

Distance between blocks

FromToDistance
RESEARCHDESIGN155 m
RESEARCHTESTING45 m
RESEARCHACCOUNTS165 m
DESIGNTESTING170 m
DESIGNACCOUNTS90 m
TESTINGACCOUNTS35 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The staff wants to make low-cost voice calls to the office in Chennai through the Internet. Name the technology that makes this possible.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. TESTING block, because it has the largest number of computers (230). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (RESEARCH, DESIGN, TESTING, ACCOUNTS). It sends the data only to the computer it is meant for.
  4. VoIP (Voice over Internet Protocol). It carries the voice as data over the Internet, so the calls are very cheap.
  5. Between TESTING and DESIGN (170 m), because the cable is longer than 100 m and the signal becomes weak. The other links are shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

45 m170 mR35 mRESEARCHswitchDESIGNswitchTESTINGSERVER + switchACCOUNTSswitch
E1.9Practice5 marks

City Degree College, Kanpur. City Degree College in Kanpur is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

65 m90 m30 m120 m105 m155 mARTS85 computersCOMMERCE140 computersSCIENCE125 computersADMIN215 computers

Number of computers

BlockComputers
ARTS85
COMMERCE140
SCIENCE125
ADMIN215

Distance between blocks

FromToDistance
ARTSCOMMERCE65 m
ARTSSCIENCE30 m
ARTSADMIN105 m
COMMERCESCIENCE155 m
COMMERCEADMIN120 m
SCIENCEADMIN90 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. Which device will be needed to connect the network of this campus to the Internet? Where should it be placed?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. ADMIN block, because it has the largest number of computers (215). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (ARTS, COMMERCE, SCIENCE, ADMIN). It sends the data only to the computer it is meant for.
  4. A modem (with a router). It should be placed in the ADMIN block, where the server is.
  5. Between ADMIN and ARTS (105 m) and between ADMIN and COMMERCE (120 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

105 mR120 mR90 mARTSswitchCOMMERCEswitchSCIENCEswitchADMINSERVER + switch
E1.10Practice5 marks

QuickKart Logistics, Noida. QuickKart Logistics in Noida is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

165 m180 m90 m50 m130 m80 mBILLING185 computersCUSTOMER CARE20 computersWAREHOUSE225 computersIT240 computers

Number of computers

BlockComputers
BILLING185
CUSTOMER CARE20
WAREHOUSE225
IT240

Distance between blocks

FromToDistance
BILLINGCUSTOMER CARE165 m
BILLINGWAREHOUSE90 m
BILLINGIT130 m
CUSTOMER CAREWAREHOUSE80 m
CUSTOMER CAREIT50 m
WAREHOUSEIT180 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation wants its website to be available on the Internet all the time. What is this service called, and on which kind of computer are the files of the website kept?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. IT block, because it has the largest number of computers (240). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (BILLING, CUSTOMER CARE, WAREHOUSE, IT). It sends the data only to the computer it is meant for.
  4. Web hosting. The files are kept on a web server, which is connected to the Internet all the time.
  5. Between IT and BILLING (130 m) and between IT and WAREHOUSE (180 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

130 mR50 m180 mRBILLINGswitchCUSTOMER CAREswitchWAREHOUSEswitchITSERVER + switch
E1.11Practice5 marks

Saraswati Vidya Mandir, Ranchi. Saraswati Vidya Mandir in Ranchi is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

110 m115 m40 m105 m50 m55 mPRIMARY230 computersSECONDARY20 computersLAB55 computersOFFICE100 computers

Number of computers

BlockComputers
PRIMARY230
SECONDARY20
LAB55
OFFICE100

Distance between blocks

FromToDistance
PRIMARYSECONDARY110 m
PRIMARYLAB40 m
PRIMARYOFFICE50 m
SECONDARYLAB55 m
SECONDARYOFFICE105 m
LABOFFICE115 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation wants a website on which each user logs in and sees his or her own details. Should the web pages be static or dynamic? Give a reason.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. PRIMARY block, because it has the largest number of computers (230). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (PRIMARY, SECONDARY, LAB, OFFICE). It sends the data only to the computer it is meant for.
  4. Dynamic. The content changes for each user and comes from a database. A static page shows the same content to everyone.
  5. Between PRIMARY and SECONDARY (110 m), because the cable is longer than 100 m and the signal becomes weak. The other links are shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

110 mR40 m50 mPRIMARYSERVER + switchSECONDARYswitchLABswitchOFFICEswitch
E1.12Practice5 marks

Bharat Auto Parts, Pune. Bharat Auto Parts in Pune is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

175 m65 m110 m170 m180 m150 mDESIGN170 computersASSEMBLY55 computersPAINT20 computersDISPATCH205 computers

Number of computers

BlockComputers
DESIGN170
ASSEMBLY55
PAINT20
DISPATCH205

Distance between blocks

FromToDistance
DESIGNASSEMBLY175 m
DESIGNPAINT110 m
DESIGNDISPATCH180 m
ASSEMBLYPAINT150 m
ASSEMBLYDISPATCH170 m
PAINTDISPATCH65 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation has one more office in Kolkata. Which type of network (PAN, LAN, MAN or WAN) will be formed when the two offices are connected?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. DISPATCH block, because it has the largest number of computers (205). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (DESIGN, ASSEMBLY, PAINT, DISPATCH). It sends the data only to the computer it is meant for.
  4. WAN (Wide Area Network), because the two offices are in different cities, far from each other.
  5. Between DISPATCH and DESIGN (180 m) and between DISPATCH and ASSEMBLY (170 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

180 mR170 mR65 mDESIGNswitchASSEMBLYswitchPAINTswitchDISPATCHSERVER + switch
E1.13Practice5 marks

Arogya Medical Centre, Kochi. Arogya Medical Centre in Kochi is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

180 m60 m165 m35 m160 m165 mEMERGENCY120 computersOPD105 computersRECORDS15 computersADMIN125 computers

Number of computers

BlockComputers
EMERGENCY120
OPD105
RECORDS15
ADMIN125

Distance between blocks

FromToDistance
EMERGENCYOPD180 m
EMERGENCYRECORDS165 m
EMERGENCYADMIN160 m
OPDRECORDS165 m
OPDADMIN35 m
RECORDSADMIN60 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The staff wants to make low-cost voice calls to the office in Chennai through the Internet. Name the technology that makes this possible.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. ADMIN block, because it has the largest number of computers (125). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (EMERGENCY, OPD, RECORDS, ADMIN). It sends the data only to the computer it is meant for.
  4. VoIP (Voice over Internet Protocol). It carries the voice as data over the Internet, so the calls are very cheap.
  5. Between ADMIN and EMERGENCY (160 m), because the cable is longer than 100 m and the signal becomes weak. The other links are shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

160 mR35 m60 mEMERGENCYswitchOPDswitchRECORDSswitchADMINSERVER + switch
E1.14Practice5 marks

SkillUp Academy, Indore. SkillUp Academy in Indore is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

60 m140 m180 m175 m155 m155 mBLOCK A135 computersBLOCK B220 computersBLOCK C80 computersBLOCK D185 computers

Number of computers

BlockComputers
BLOCK A135
BLOCK B220
BLOCK C80
BLOCK D185

Distance between blocks

FromToDistance
BLOCK ABLOCK B60 m
BLOCK ABLOCK C180 m
BLOCK ABLOCK D155 m
BLOCK BBLOCK C155 m
BLOCK BBLOCK D175 m
BLOCK CBLOCK D140 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. Which device will be needed to connect the network of this campus to the Internet? Where should it be placed?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. BLOCK B block, because it has the largest number of computers (220). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (BLOCK A, BLOCK B, BLOCK C, BLOCK D). It sends the data only to the computer it is meant for.
  4. A modem (with a router). It should be placed in the BLOCK B block, where the server is.
  5. Between BLOCK B and BLOCK C (155 m) and between BLOCK B and BLOCK D (175 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

60 m155 mR175 mRBLOCK AswitchBLOCK BSERVER + switchBLOCK CswitchBLOCK Dswitch
E1.15Practice5 marks

Ganga Engineering Works, Varanasi. Ganga Engineering Works in Varanasi is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

140 m105 m140 m165 m100 m35 mOFFICE100 computersFOUNDRY50 computersMACHINE SHOP180 computersSTORE155 computers

Number of computers

BlockComputers
OFFICE100
FOUNDRY50
MACHINE SHOP180
STORE155

Distance between blocks

FromToDistance
OFFICEFOUNDRY140 m
OFFICEMACHINE SHOP140 m
OFFICESTORE100 m
FOUNDRYMACHINE SHOP35 m
FOUNDRYSTORE165 m
MACHINE SHOPSTORE105 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation wants its website to be available on the Internet all the time. What is this service called, and on which kind of computer are the files of the website kept?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. MACHINE SHOP block, because it has the largest number of computers (180). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (OFFICE, FOUNDRY, MACHINE SHOP, STORE). It sends the data only to the computer it is meant for.
  4. Web hosting. The files are kept on a web server, which is connected to the Internet all the time.
  5. Between MACHINE SHOP and OFFICE (140 m) and between MACHINE SHOP and STORE (105 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

140 mR35 m105 mROFFICEswitchFOUNDRYswitchMACHINE SHOPSERVER + switchSTOREswitch
E1.16Practice5 marks

Navyug Publications, Chandigarh. Navyug Publications in Chandigarh is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

40 m95 m175 m55 m140 m40 mEDITING120 computersDESIGN200 computersPRESS80 computersSALES250 computers

Number of computers

BlockComputers
EDITING120
DESIGN200
PRESS80
SALES250

Distance between blocks

FromToDistance
EDITINGDESIGN40 m
EDITINGPRESS175 m
EDITINGSALES140 m
DESIGNPRESS40 m
DESIGNSALES55 m
PRESSSALES95 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation wants a website on which each user logs in and sees his or her own details. Should the web pages be static or dynamic? Give a reason.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. SALES block, because it has the largest number of computers (250). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (EDITING, DESIGN, PRESS, SALES). It sends the data only to the computer it is meant for.
  4. Dynamic. The content changes for each user and comes from a database. A static page shows the same content to everyone.
  5. Between SALES and EDITING (140 m), because the cable is longer than 100 m and the signal becomes weak. The other links are shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

140 mR55 m95 mEDITINGswitchDESIGNswitchPRESSswitchSALESSERVER + switch
E1.17Practice5 marks

Delhi Model School, Delhi. Delhi Model School in Delhi is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

175 m40 m150 m170 m55 m175 mJUNIOR WING200 computersSENIOR WING160 computersCOMPUTER LAB245 computersADMIN215 computers

Number of computers

BlockComputers
JUNIOR WING200
SENIOR WING160
COMPUTER LAB245
ADMIN215

Distance between blocks

FromToDistance
JUNIOR WINGSENIOR WING175 m
JUNIOR WINGCOMPUTER LAB150 m
JUNIOR WINGADMIN55 m
SENIOR WINGCOMPUTER LAB175 m
SENIOR WINGADMIN170 m
COMPUTER LABADMIN40 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation has one more office in Kolkata. Which type of network (PAN, LAN, MAN or WAN) will be formed when the two offices are connected?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. COMPUTER LAB block, because it has the largest number of computers (245). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (JUNIOR WING, SENIOR WING, COMPUTER LAB, ADMIN). It sends the data only to the computer it is meant for.
  4. WAN (Wide Area Network), because the two offices are in different cities, far from each other.
  5. Between COMPUTER LAB and JUNIOR WING (150 m) and between COMPUTER LAB and SENIOR WING (175 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

150 mR175 mR40 mJUNIOR WINGswitchSENIOR WINGswitchCOMPUTER LABSERVER + switchADMINswitch
E1.18Practice5 marks

Pixel Design Studio, Mumbai. Pixel Design Studio in Mumbai is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

135 m65 m160 m155 m160 m165 mSTUDIO15 computersEDIT ROOM130 computersACCOUNTS195 computersRECEPTION240 computers

Number of computers

BlockComputers
STUDIO15
EDIT ROOM130
ACCOUNTS195
RECEPTION240

Distance between blocks

FromToDistance
STUDIOEDIT ROOM135 m
STUDIOACCOUNTS160 m
STUDIORECEPTION160 m
EDIT ROOMACCOUNTS165 m
EDIT ROOMRECEPTION155 m
ACCOUNTSRECEPTION65 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The staff wants to make low-cost voice calls to the office in Guwahati through the Internet. Name the technology that makes this possible.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. RECEPTION block, because it has the largest number of computers (240). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (STUDIO, EDIT ROOM, ACCOUNTS, RECEPTION). It sends the data only to the computer it is meant for.
  4. VoIP (Voice over Internet Protocol). It carries the voice as data over the Internet, so the calls are very cheap.
  5. Between RECEPTION and STUDIO (160 m) and between RECEPTION and EDIT ROOM (155 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

160 mR155 mR65 mSTUDIOswitchEDIT ROOMswitchACCOUNTSswitchRECEPTIONSERVER + switch
E1.19Practice5 marks

National Commerce College, Jaipur. National Commerce College in Jaipur is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

160 m115 m55 m175 m55 m35 mBLOCK P40 computersBLOCK Q100 computersBLOCK R65 computersBLOCK S85 computers

Number of computers

BlockComputers
BLOCK P40
BLOCK Q100
BLOCK R65
BLOCK S85

Distance between blocks

FromToDistance
BLOCK PBLOCK Q160 m
BLOCK PBLOCK R55 m
BLOCK PBLOCK S55 m
BLOCK QBLOCK R35 m
BLOCK QBLOCK S175 m
BLOCK RBLOCK S115 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. Which device will be needed to connect the network of this campus to the Internet? Where should it be placed?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. BLOCK Q block, because it has the largest number of computers (100). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (BLOCK P, BLOCK Q, BLOCK R, BLOCK S). It sends the data only to the computer it is meant for.
  4. A modem (with a router). It should be placed in the BLOCK Q block, where the server is.
  5. Between BLOCK Q and BLOCK P (160 m) and between BLOCK Q and BLOCK S (175 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

160 mR35 m175 mRBLOCK PswitchBLOCK QSERVER + switchBLOCK RswitchBLOCK Sswitch
E1.20Practice5 marks

FreshCart Retail, Lucknow. FreshCart Retail in Lucknow is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

170 m100 m60 m65 m160 m175 mBILLING150 computersGODOWN125 computersOFFICE135 computersDELIVERY120 computers

Number of computers

BlockComputers
BILLING150
GODOWN125
OFFICE135
DELIVERY120

Distance between blocks

FromToDistance
BILLINGGODOWN170 m
BILLINGOFFICE60 m
BILLINGDELIVERY160 m
GODOWNOFFICE175 m
GODOWNDELIVERY65 m
OFFICEDELIVERY100 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation wants its website to be available on the Internet all the time. What is this service called, and on which kind of computer are the files of the website kept?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. BILLING block, because it has the largest number of computers (150). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (BILLING, GODOWN, OFFICE, DELIVERY). It sends the data only to the computer it is meant for.
  4. Web hosting. The files are kept on a web server, which is connected to the Internet all the time.
  5. Between BILLING and GODOWN (170 m) and between BILLING and DELIVERY (160 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

170 mR60 m160 mRBILLINGSERVER + switchGODOWNswitchOFFICEswitchDELIVERYswitch
E1.21Practice5 marks

Gyan Deep School, Raipur. Gyan Deep School in Raipur is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

130 m170 m45 m85 m145 m110 mNORTH195 computersSOUTH70 computersEAST150 computersWEST90 computers

Number of computers

BlockComputers
NORTH195
SOUTH70
EAST150
WEST90

Distance between blocks

FromToDistance
NORTHSOUTH130 m
NORTHEAST45 m
NORTHWEST145 m
SOUTHEAST110 m
SOUTHWEST85 m
EASTWEST170 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation wants a website on which each user logs in and sees his or her own details. Should the web pages be static or dynamic? Give a reason.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. NORTH block, because it has the largest number of computers (195). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (NORTH, SOUTH, EAST, WEST). It sends the data only to the computer it is meant for.
  4. Dynamic. The content changes for each user and comes from a database. A static page shows the same content to everyone.
  5. Between NORTH and SOUTH (130 m) and between NORTH and WEST (145 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

130 mR45 m145 mRNORTHSERVER + switchSOUTHswitchEASTswitchWESTswitch
E1.22Practice5 marks

Coastal Foods, Visakhapatnam. Coastal Foods in Visakhapatnam is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

175 m175 m170 m115 m165 m65 mPACKING70 computersCOLD STORE75 computersOFFICE165 computersQUALITY105 computers

Number of computers

BlockComputers
PACKING70
COLD STORE75
OFFICE165
QUALITY105

Distance between blocks

FromToDistance
PACKINGCOLD STORE175 m
PACKINGOFFICE170 m
PACKINGQUALITY165 m
COLD STOREOFFICE65 m
COLD STOREQUALITY115 m
OFFICEQUALITY175 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The organisation has one more office in Kolkata. Which type of network (PAN, LAN, MAN or WAN) will be formed when the two offices are connected?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. OFFICE block, because it has the largest number of computers (165). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (PACKING, COLD STORE, OFFICE, QUALITY). It sends the data only to the computer it is meant for.
  4. WAN (Wide Area Network), because the two offices are in different cities, far from each other.
  5. Between OFFICE and PACKING (170 m) and between OFFICE and QUALITY (175 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

170 mR65 m175 mRPACKINGswitchCOLD STOREswitchOFFICESERVER + switchQUALITYswitch
E1.23Practice5 marks

Care Plus Hospital, Ahmedabad. Care Plus Hospital in Ahmedabad is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

75 m95 m110 m155 m165 m155 mOPD120 computersICU100 computersLAB55 computersBILLING220 computers

Number of computers

BlockComputers
OPD120
ICU100
LAB55
BILLING220

Distance between blocks

FromToDistance
OPDICU75 m
OPDLAB110 m
OPDBILLING165 m
ICULAB155 m
ICUBILLING155 m
LABBILLING95 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. The staff wants to make low-cost voice calls to the office in Chennai through the Internet. Name the technology that makes this possible.
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. BILLING block, because it has the largest number of computers (220). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (OPD, ICU, LAB, BILLING). It sends the data only to the computer it is meant for.
  4. VoIP (Voice over Internet Protocol). It carries the voice as data over the Internet, so the calls are very cheap.
  5. Between BILLING and OPD (165 m) and between BILLING and ICU (155 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

165 mR155 mR95 mOPDswitchICUswitchLABswitchBILLINGSERVER + switch
E1.24Practice5 marks

Future Minds Institute, Chennai. Future Minds Institute in Chennai is setting up a computer network in its campus. It has four blocks, as shown in the layout.

Layout of the blocks

115 m135 m90 m115 m115 m115 mTOWER 1250 computersTOWER 225 computersTOWER 350 computersTOWER 4180 computers

Number of computers

BlockComputers
TOWER 1250
TOWER 225
TOWER 350
TOWER 4180

Distance between blocks

FromToDistance
TOWER 1TOWER 2115 m
TOWER 1TOWER 390 m
TOWER 1TOWER 4115 m
TOWER 2TOWER 3115 m
TOWER 2TOWER 4115 m
TOWER 3TOWER 4135 m
  1. Which block is the most suitable place for the server? Give a reason.
  2. Which type of network (PAN, LAN, MAN or WAN) is formed when the four blocks are connected? Give a reason.
  3. Which device should be placed in every block to connect the computers of that block?
  4. Which device will be needed to connect the network of this campus to the Internet? Where should it be placed?
  5. Between which blocks should a repeater be placed, if the cables are laid from the server block to the other three blocks? Give a reason.
Answer
  1. TOWER 1 block, because it has the largest number of computers (250). Most of the data traffic then stays inside one block.
  2. LAN (Local Area Network), because all the blocks are inside one campus, within a small area.
  3. A switch in every block (TOWER 1, TOWER 2, TOWER 3, TOWER 4). It sends the data only to the computer it is meant for.
  4. A modem (with a router). It should be placed in the TOWER 1 block, where the server is.
  5. Between TOWER 1 and TOWER 2 (115 m) and between TOWER 1 and TOWER 4 (115 m), because the cable is longer than 100 m and the signal becomes weak. The other link is shorter than 100 m.

Suggested cable layout (star). R marks a repeater.

115 mR90 m115 mRTOWER 1SERVER + switchTOWER 2switchTOWER 3switchTOWER 4switch
E2DataFrame program5 marks · 24 questions
E2.1Practice5 marks

The DataFrame Stock stores the items of a stationery shop.

  1. Write a Python program to create the DataFrame Stock given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to add a new row with the label S5: Item Ink, Price 90 and Qty 30. (1 mark)
  3. Write a statement to display only the column Item. (1 mark)

DataFrame: Stock

ItemPriceQty
S1Pen26055
S2Notebook15035
S3Bag17020
S4Stapler19010
Answer
(i)
import pandas as pd
Stock = pd.DataFrame({'Item': ['Pen', 'Notebook', 'Bag', 'Stapler'],
                      'Price': [260, 150, 170, 190],
                      'Qty': [55, 35, 20, 10]},
                     index=['S1', 'S2', 'S3', 'S4'])
print(Stock)

Output:

        Item  Price  Qty
S1       Pen    260   55
S2  Notebook    150   35
S3       Bag    170   20
S4   Stapler    190   10
(ii)
Stock.loc['S5'] = ['Ink', 90, 30]

The DataFrame now:

        Item  Price  Qty
S1       Pen    260   55
S2  Notebook    150   35
S3       Bag    170   20
S4   Stapler    190   10
S5       Ink     90   30
(iii)
print(Stock['Item'])

Output:

S1         Pen
S2    Notebook
S3         Bag
S4     Stapler
Name: Item, dtype: object
E2.2Practice5 marks

The DataFrame Result stores the marks of some students.

  1. Write a Python program to create the DataFrame Result given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to display only the column Name. (1 mark)
  3. Write a statement to display the first two rows. (1 mark)

DataFrame: Result

NameEngMaths
R1Asha8560
R2Ravi6361
R3Tina6773
R4Om6063
Answer
(i)
import pandas as pd
D = {'Name': pd.Series(['Asha', 'Ravi', 'Tina', 'Om'], index=['R1', 'R2', 'R3', 'R4']),
     'Eng': pd.Series([85, 63, 67, 60], index=['R1', 'R2', 'R3', 'R4']),
     'Maths': pd.Series([60, 61, 73, 63], index=['R1', 'R2', 'R3', 'R4'])}
Result = pd.DataFrame(D)
print(Result)

Output:

    Name  Eng  Maths
R1  Asha   85     60
R2  Ravi   63     61
R3  Tina   67     73
R4    Om   60     63
(ii)
print(Result['Name'])

Output:

R1    Asha
R2    Ravi
R3    Tina
R4      Om
Name: Name, dtype: object
(iii)
print(Result.head(2))

Output:

    Name  Eng  Maths
R1  Asha   85     60
R2  Ravi   63     61
E2.3Practice5 marks

The DataFrame Team stores the boundaries hit by some players.

  1. Write a Python program to create the DataFrame Team given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to add a new column Boundaries, which is Fours plus Sixes. (1 mark)
  3. Write a statement to display the Fours of the row P3. (1 mark)

DataFrame: Team

PlayerFoursSixes
P1Rohit362
P2Virat2713
P3Gill1417
P4Pant263
Answer
(i)
import pandas as pd
Team = pd.DataFrame({'Player': ['Rohit', 'Virat', 'Gill', 'Pant'],
                     'Fours': [36, 27, 14, 26],
                     'Sixes': [2, 13, 17, 3]},
                    index=['P1', 'P2', 'P3', 'P4'])
print(Team)

Output:

   Player  Fours  Sixes
P1  Rohit     36      2
P2  Virat     27     13
P3   Gill     14     17
P4   Pant     26      3
(ii)
Team['Boundaries'] = Team['Fours'] + Team['Sixes']

The DataFrame now:

   Player  Fours  Sixes  Boundaries
P1  Rohit     36      2          38
P2  Virat     27     13          40
P3   Gill     14     17          31
P4   Pant     26      3          29
(iii)
print(Team.loc['P3', 'Fours'])

Output:

14
E2.4Practice5 marks

The DataFrame Shop stores the monthly account (in thousand rupees) of some shops.

  1. Write a Python program to create the DataFrame Shop given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to display the rows where Expense is more than 25. (1 mark)
  3. Write a statement to delete the column Expense. (1 mark)

DataFrame: Shop

ShopIncomeExpense
S1Alpha8540
S2Bharat8025
S3City11545
S4Deluxe9020
Answer
(i)
import pandas as pd
D = {'Shop': pd.Series(['Alpha', 'Bharat', 'City', 'Deluxe'], index=['S1', 'S2', 'S3', 'S4']),
     'Income': pd.Series([85, 80, 115, 90], index=['S1', 'S2', 'S3', 'S4']),
     'Expense': pd.Series([40, 25, 45, 20], index=['S1', 'S2', 'S3', 'S4'])}
Shop = pd.DataFrame(D)
print(Shop)

Output:

      Shop  Income  Expense
S1   Alpha      85       40
S2  Bharat      80       25
S3    City     115       45
S4  Deluxe      90       20
(ii)
print(Shop[Shop['Expense'] > 25])

Output:

     Shop  Income  Expense
S1  Alpha      85       40
S3   City     115       45
(iii)
Shop = Shop.drop('Expense', axis=1)

The DataFrame now:

      Shop  Income
S1   Alpha      85
S2  Bharat      80
S3    City     115
S4  Deluxe      90
E2.5Practice5 marks

The DataFrame Classes stores the strength of some classes.

  1. Write a Python program to create the DataFrame Classes given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to add a new row with the label C5: Class VIII, Boys 15 and Girls 23. (1 mark)
  3. Write a statement to display only the column Class. (1 mark)

DataFrame: Classes

ClassBoysGirls
C1IX2918
C2X2813
C3XI2414
C4XII2026
Answer
(i)
import pandas as pd
Classes = pd.DataFrame({'Class': ['IX', 'X', 'XI', 'XII'],
                        'Boys': [29, 28, 24, 20],
                        'Girls': [18, 13, 14, 26]},
                       index=['C1', 'C2', 'C3', 'C4'])
print(Classes)

Output:

   Class  Boys  Girls
C1    IX    29     18
C2     X    28     13
C3    XI    24     14
C4   XII    20     26
(ii)
Classes.loc['C5'] = ['VIII', 15, 23]

The DataFrame now:

   Class  Boys  Girls
C1    IX    29     18
C2     X    28     13
C3    XI    24     14
C4   XII    20     26
C5  VIII    15     23
(iii)
print(Classes['Class'])

Output:

C1     IX
C2      X
C3     XI
C4    XII
Name: Class, dtype: object
E2.6Practice5 marks

The DataFrame Library stores the books of a library.

  1. Write a Python program to create the DataFrame Library given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to display the Issued of the row B3. (1 mark)
  3. Write a statement to display only the column Subject. (1 mark)

DataFrame: Library

SubjectIssuedAvailable
B1English2095
B2Hindi3065
B3Maths75105
B4Science70110
Answer
(i)
import pandas as pd
D = {'Subject': pd.Series(['English', 'Hindi', 'Maths', 'Science'], index=['B1', 'B2', 'B3', 'B4']),
     'Issued': pd.Series([20, 30, 75, 70], index=['B1', 'B2', 'B3', 'B4']),
     'Available': pd.Series([95, 65, 105, 110], index=['B1', 'B2', 'B3', 'B4'])}
Library = pd.DataFrame(D)
print(Library)

Output:

    Subject  Issued  Available
B1  English      20         95
B2    Hindi      30         65
B3    Maths      75        105
B4  Science      70        110
(ii)
print(Library.loc['B3', 'Issued'])

Output:

75
(iii)
print(Library['Subject'])

Output:

B1    English
B2      Hindi
B3      Maths
B4    Science
Name: Subject, dtype: object
E2.7Practice5 marks

The DataFrame Hotel stores the rooms booked in a hotel.

  1. Write a Python program to create the DataFrame Hotel given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to delete the column Days. (1 mark)
  3. Write a statement to add a new column Bill, which is Rent multiplied by Days. (1 mark)

DataFrame: Hotel

RoomTypeRentDays
H1Single38003
H2Double24002
H3Deluxe20005
H4Suite26006
Answer
(i)
import pandas as pd
Hotel = pd.DataFrame({'RoomType': ['Single', 'Double', 'Deluxe', 'Suite'],
                      'Rent': [3800, 2400, 2000, 2600],
                      'Days': [3, 2, 5, 6]},
                     index=['H1', 'H2', 'H3', 'H4'])
print(Hotel)

Output:

   RoomType  Rent  Days
H1   Single  3800     3
H2   Double  2400     2
H3   Deluxe  2000     5
H4    Suite  2600     6
(ii)
Hotel = Hotel.drop('Days', axis=1)

The DataFrame now:

   RoomType  Rent
H1   Single  3800
H2   Double  2400
H3   Deluxe  2000
H4    Suite  2600
(iii)
Hotel['Bill'] = Hotel['Rent'] * Hotel['Days']

The DataFrame now:

   RoomType  Rent  Days   Bill
H1   Single  3800     3  11400
H2   Double  2400     2   4800
H3   Deluxe  2000     5  10000
H4    Suite  2600     6  15600
E2.8Practice5 marks

The DataFrame Crop stores the crop production (in tonnes) of some villages.

  1. Write a Python program to create the DataFrame Crop given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to add a new row with the label V5: Village Madhopur, Wheat 90 and Rice 20. (1 mark)
  3. Write a statement to display the rows where Rice is more than 40. (1 mark)

DataFrame: Crop

VillageWheatRice
V1Rampur5565
V2Sonpur6530
V3Lalganj8550
V4Nayagaon3040
Answer
(i)
import pandas as pd
D = {'Village': pd.Series(['Rampur', 'Sonpur', 'Lalganj', 'Nayagaon'], index=['V1', 'V2', 'V3', 'V4']),
     'Wheat': pd.Series([55, 65, 85, 30], index=['V1', 'V2', 'V3', 'V4']),
     'Rice': pd.Series([65, 30, 50, 40], index=['V1', 'V2', 'V3', 'V4'])}
Crop = pd.DataFrame(D)
print(Crop)

Output:

     Village  Wheat  Rice
V1    Rampur     55    65
V2    Sonpur     65    30
V3   Lalganj     85    50
V4  Nayagaon     30    40
(ii)
Crop.loc['V5'] = ['Madhopur', 90, 20]

The DataFrame now:

     Village  Wheat  Rice
V1    Rampur     55    65
V2    Sonpur     65    30
V3   Lalganj     85    50
V4  Nayagaon     30    40
V5  Madhopur     90    20
(iii)
print(Crop[Crop['Rice'] > 40])

Output:

    Village  Wheat  Rice
V1   Rampur     55    65
V3  Lalganj     85    50
E2.9Practice5 marks

The DataFrame Medal stores the medals won by the houses of a school.

  1. Write a Python program to create the DataFrame Medal given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to add a new row with the label H5: House Tilak, Gold 2 and Silver 15. (1 mark)
  3. Write a statement to display only the column House. (1 mark)

DataFrame: Medal

HouseGoldSilver
H1Shivaji93
H2Tagore116
H3Raman77
H4Ashoka812
Answer
(i)
import pandas as pd
Medal = pd.DataFrame({'House': ['Shivaji', 'Tagore', 'Raman', 'Ashoka'],
                      'Gold': [9, 11, 7, 8],
                      'Silver': [3, 6, 7, 12]},
                     index=['H1', 'H2', 'H3', 'H4'])
print(Medal)

Output:

      House  Gold  Silver
H1  Shivaji     9       3
H2   Tagore    11       6
H3    Raman     7       7
H4   Ashoka     8      12
(ii)
Medal.loc['H5'] = ['Tilak', 2, 15]

The DataFrame now:

      House  Gold  Silver
H1  Shivaji     9       3
H2   Tagore    11       6
H3    Raman     7       7
H4   Ashoka     8      12
H5    Tilak     2      15
(iii)
print(Medal['House'])

Output:

H1    Shivaji
H2     Tagore
H3      Raman
H4     Ashoka
Name: House, dtype: object
E2.10Practice5 marks

The DataFrame Sales stores the sales (in lakh rupees) of some salesmen.

  1. Write a Python program to create the DataFrame Sales given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to add a new column Total, which is Qtr1 plus Qtr2. (1 mark)
  3. Write a statement to display the Qtr1 of the row S3. (1 mark)

DataFrame: Sales

NameQtr1Qtr2
S1Kabir5456
S2Meera5820
S3Nitin3618
S4Pooja2248
Answer
(i)
import pandas as pd
D = {'Name': pd.Series(['Kabir', 'Meera', 'Nitin', 'Pooja'], index=['S1', 'S2', 'S3', 'S4']),
     'Qtr1': pd.Series([54, 58, 36, 22], index=['S1', 'S2', 'S3', 'S4']),
     'Qtr2': pd.Series([56, 20, 18, 48], index=['S1', 'S2', 'S3', 'S4'])}
Sales = pd.DataFrame(D)
print(Sales)

Output:

     Name  Qtr1  Qtr2
S1  Kabir    54    56
S2  Meera    58    20
S3  Nitin    36    18
S4  Pooja    22    48
(ii)
Sales['Total'] = Sales['Qtr1'] + Sales['Qtr2']

The DataFrame now:

     Name  Qtr1  Qtr2  Total
S1  Kabir    54    56    110
S2  Meera    58    20     78
S3  Nitin    36    18     54
S4  Pooja    22    48     70
(iii)
print(Sales.loc['S3', 'Qtr1'])

Output:

36
E2.11Practice5 marks

The DataFrame Fuel stores the fuel filled in some vehicles.

  1. Write a Python program to create the DataFrame Fuel given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to display the rows where Rate is more than 100. (1 mark)
  3. Write a statement to delete the column Rate. (1 mark)

DataFrame: Fuel

VehicleLitresRate
V1Car5592
V2Bike45106
V3Bus25104
V4Van35100
Answer
(i)
import pandas as pd
Fuel = pd.DataFrame({'Vehicle': ['Car', 'Bike', 'Bus', 'Van'],
                     'Litres': [55, 45, 25, 35],
                     'Rate': [92, 106, 104, 100]},
                    index=['V1', 'V2', 'V3', 'V4'])
print(Fuel)

Output:

   Vehicle  Litres  Rate
V1     Car      55    92
V2    Bike      45   106
V3     Bus      25   104
V4     Van      35   100
(ii)
print(Fuel[Fuel['Rate'] > 100])

Output:

   Vehicle  Litres  Rate
V2    Bike      45   106
V3     Bus      25   104
(iii)
Fuel = Fuel.drop('Rate', axis=1)

The DataFrame now:

   Vehicle  Litres
V1     Car      55
V2    Bike      45
V3     Bus      25
V4     Van      35
E2.12Practice5 marks

The DataFrame Exam stores the theory and practical marks of some students.

  1. Write a Python program to create the DataFrame Exam given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to display the first two rows. (1 mark)
  3. Write a statement to add a new row with the label E5: Name Manav, Theory 40 and Practical 20. (1 mark)

DataFrame: Exam

NameTheoryPractical
E1Ishaan3125
E2Jaya5429
E3Kunal3221
E4Lata3422
Answer
(i)
import pandas as pd
D = {'Name': pd.Series(['Ishaan', 'Jaya', 'Kunal', 'Lata'], index=['E1', 'E2', 'E3', 'E4']),
     'Theory': pd.Series([31, 54, 32, 34], index=['E1', 'E2', 'E3', 'E4']),
     'Practical': pd.Series([25, 29, 21, 22], index=['E1', 'E2', 'E3', 'E4'])}
Exam = pd.DataFrame(D)
print(Exam)

Output:

      Name  Theory  Practical
E1  Ishaan      31         25
E2    Jaya      54         29
E3   Kunal      32         21
E4    Lata      34         22
(ii)
print(Exam.head(2))

Output:

      Name  Theory  Practical
E1  Ishaan      31         25
E2    Jaya      54         29
(iii)
Exam.loc['E5'] = ['Manav', 40, 20]

The DataFrame now:

      Name  Theory  Practical
E1  Ishaan      31         25
E2    Jaya      54         29
E3   Kunal      32         21
E4    Lata      34         22
E5   Manav      40         20
E2.13Practice5 marks

The DataFrame Emp stores the pay of some employees.

  1. Write a Python program to create the DataFrame Emp given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to add a new row with the label E5: Name Karan, Basic 46000 and Bonus 1500. (1 mark)
  3. Write a statement to display only the column Name. (1 mark)

DataFrame: Emp

NameBasicBonus
E1Gopal200003500
E2Hema480005500
E3Irfan280004000
E4Jyoti400002000
Answer
(i)
import pandas as pd
Emp = pd.DataFrame({'Name': ['Gopal', 'Hema', 'Irfan', 'Jyoti'],
                    'Basic': [20000, 48000, 28000, 40000],
                    'Bonus': [3500, 5500, 4000, 2000]},
                   index=['E1', 'E2', 'E3', 'E4'])
print(Emp)

Output:

     Name  Basic  Bonus
E1  Gopal  20000   3500
E2   Hema  48000   5500
E3  Irfan  28000   4000
E4  Jyoti  40000   2000
(ii)
Emp.loc['E5'] = ['Karan', 46000, 1500]

The DataFrame now:

     Name  Basic  Bonus
E1  Gopal  20000   3500
E2   Hema  48000   5500
E3  Irfan  28000   4000
E4  Jyoti  40000   2000
E5  Karan  46000   1500
(iii)
print(Emp['Name'])

Output:

E1    Gopal
E2     Hema
E3    Irfan
E4    Jyoti
Name: Name, dtype: object
E2.14Practice5 marks

The DataFrame Ticket stores the tickets sold for the shows of a film.

  1. Write a Python program to create the DataFrame Ticket given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to delete the column Price. (1 mark)
  3. Write a statement to add a new column Collection, which is Tickets multiplied by Price. (1 mark)

DataFrame: Ticket

ShowTicketsPrice
T1Morning40250
T2Noon100200
T3Evening60150
T4Night130300
Answer
(i)
import pandas as pd
D = {'Show': pd.Series(['Morning', 'Noon', 'Evening', 'Night'], index=['T1', 'T2', 'T3', 'T4']),
     'Tickets': pd.Series([40, 100, 60, 130], index=['T1', 'T2', 'T3', 'T4']),
     'Price': pd.Series([250, 200, 150, 300], index=['T1', 'T2', 'T3', 'T4'])}
Ticket = pd.DataFrame(D)
print(Ticket)

Output:

       Show  Tickets  Price
T1  Morning       40    250
T2     Noon      100    200
T3  Evening       60    150
T4    Night      130    300
(ii)
Ticket = Ticket.drop('Price', axis=1)

The DataFrame now:

       Show  Tickets
T1  Morning       40
T2     Noon      100
T3  Evening       60
T4    Night      130
(iii)
Ticket['Collection'] = Ticket['Tickets'] * Ticket['Price']

The DataFrame now:

       Show  Tickets  Price  Collection
T1  Morning       40    250       10000
T2     Noon      100    200       20000
T3  Evening       60    150        9000
T4    Night      130    300       39000
E2.15Practice5 marks

The DataFrame Weather stores the temperature of some cities.

  1. Write a Python program to create the DataFrame Weather given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to add a new row with the label W5: City Patna, MaxTemp 43 and MinTemp 15. (1 mark)
  3. Write a statement to display the rows where MinTemp is more than 16. (1 mark)

DataFrame: Weather

CityMaxTempMinTemp
W1Delhi3918
W2Shimla3116
W3Jaipur3424
W4Kochi3013
Answer
(i)
import pandas as pd
Weather = pd.DataFrame({'City': ['Delhi', 'Shimla', 'Jaipur', 'Kochi'],
                        'MaxTemp': [39, 31, 34, 30],
                        'MinTemp': [18, 16, 24, 13]},
                       index=['W1', 'W2', 'W3', 'W4'])
print(Weather)

Output:

      City  MaxTemp  MinTemp
W1   Delhi       39       18
W2  Shimla       31       16
W3  Jaipur       34       24
W4   Kochi       30       13
(ii)
Weather.loc['W5'] = ['Patna', 43, 15]

The DataFrame now:

      City  MaxTemp  MinTemp
W1   Delhi       39       18
W2  Shimla       31       16
W3  Jaipur       34       24
W4   Kochi       30       13
W5   Patna       43       15
(iii)
print(Weather[Weather['MinTemp'] > 16])

Output:

      City  MaxTemp  MinTemp
W1   Delhi       39       18
W3  Jaipur       34       24
E2.16Practice5 marks

The DataFrame Canteen stores the items sold in a school canteen.

  1. Write a Python program to create the DataFrame Canteen given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to display only the column Item. (1 mark)
  3. Write a statement to display the first two rows. (1 mark)

DataFrame: Canteen

ItemPriceSold
C1Samosa20140
C2Tea3020
C3Juice5590
C4Sandwich6060
Answer
(i)
import pandas as pd
D = {'Item': pd.Series(['Samosa', 'Tea', 'Juice', 'Sandwich'], index=['C1', 'C2', 'C3', 'C4']),
     'Price': pd.Series([20, 30, 55, 60], index=['C1', 'C2', 'C3', 'C4']),
     'Sold': pd.Series([140, 20, 90, 60], index=['C1', 'C2', 'C3', 'C4'])}
Canteen = pd.DataFrame(D)
print(Canteen)

Output:

        Item  Price  Sold
C1    Samosa     20   140
C2       Tea     30    20
C3     Juice     55    90
C4  Sandwich     60    60
(ii)
print(Canteen['Item'])

Output:

C1      Samosa
C2         Tea
C3       Juice
C4    Sandwich
Name: Item, dtype: object
(iii)
print(Canteen.head(2))

Output:

      Item  Price  Sold
C1  Samosa     20   140
C2     Tea     30    20
E2.17Practice5 marks

The DataFrame Budget stores the budget (in thousand rupees) of some departments.

  1. Write a Python program to create the DataFrame Budget given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to add a new row with the label D5: Dept Art, Allotted 150 and Spent 45. (1 mark)
  3. Write a statement to display only the column Dept. (1 mark)

DataFrame: Budget

DeptAllottedSpent
D1Sports19020
D2Library17025
D3Lab9030
D4Music14055
Answer
(i)
import pandas as pd
Budget = pd.DataFrame({'Dept': ['Sports', 'Library', 'Lab', 'Music'],
                       'Allotted': [190, 170, 90, 140],
                       'Spent': [20, 25, 30, 55]},
                      index=['D1', 'D2', 'D3', 'D4'])
print(Budget)

Output:

       Dept  Allotted  Spent
D1   Sports       190     20
D2  Library       170     25
D3      Lab        90     30
D4    Music       140     55
(ii)
Budget.loc['D5'] = ['Art', 150, 45]

The DataFrame now:

       Dept  Allotted  Spent
D1   Sports       190     20
D2  Library       170     25
D3      Lab        90     30
D4    Music       140     55
D5      Art       150     45
(iii)
print(Budget['Dept'])

Output:

D1     Sports
D2    Library
D3        Lab
D4      Music
Name: Dept, dtype: object
E2.18Practice5 marks

The DataFrame Orders stores the online orders of a store.

  1. Write a Python program to create the DataFrame Orders given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to display the rows where Units is more than 11. (1 mark)
  3. Write a statement to delete the column Units. (1 mark)

DataFrame: Orders

ProductRateUnits
O1Mouse160017
O2Keyboard240011
O3Webcam150018
O4Speaker9006
Answer
(i)
import pandas as pd
D = {'Product': pd.Series(['Mouse', 'Keyboard', 'Webcam', 'Speaker'], index=['O1', 'O2', 'O3', 'O4']),
     'Rate': pd.Series([1600, 2400, 1500, 900], index=['O1', 'O2', 'O3', 'O4']),
     'Units': pd.Series([17, 11, 18, 6], index=['O1', 'O2', 'O3', 'O4'])}
Orders = pd.DataFrame(D)
print(Orders)

Output:

     Product  Rate  Units
O1     Mouse  1600     17
O2  Keyboard  2400     11
O3    Webcam  1500     18
O4   Speaker   900      6
(ii)
print(Orders[Orders['Units'] > 11])

Output:

   Product  Rate  Units
O1   Mouse  1600     17
O3  Webcam  1500     18
(iii)
Orders = Orders.drop('Units', axis=1)

The DataFrame now:

     Product  Rate
O1     Mouse  1600
O2  Keyboard  2400
O3    Webcam  1500
O4   Speaker   900
E2.19Practice5 marks

The DataFrame Trip stores the persons going on a school trip.

  1. Write a Python program to create the DataFrame Trip given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to display the first two rows. (1 mark)
  3. Write a statement to add a new row with the label T5: Class X, Students 45 and Teachers 2. (1 mark)

DataFrame: Trip

ClassStudentsTeachers
T1VI315
T2VII363
T3VIII284
T4IX386
Answer
(i)
import pandas as pd
Trip = pd.DataFrame({'Class': ['VI', 'VII', 'VIII', 'IX'],
                     'Students': [31, 36, 28, 38],
                     'Teachers': [5, 3, 4, 6]},
                    index=['T1', 'T2', 'T3', 'T4'])
print(Trip)

Output:

   Class  Students  Teachers
T1    VI        31         5
T2   VII        36         3
T3  VIII        28         4
T4    IX        38         6
(ii)
print(Trip.head(2))

Output:

   Class  Students  Teachers
T1    VI        31         5
T2   VII        36         3
(iii)
Trip.loc['T5'] = ['X', 45, 2]

The DataFrame now:

   Class  Students  Teachers
T1    VI        31         5
T2   VII        36         3
T3  VIII        28         4
T4    IX        38         6
T5     X        45         2
E2.20Practice5 marks

The DataFrame Garden stores the plants in the gardens of a city.

  1. Write a Python program to create the DataFrame Garden given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to display the Trees of the row G3. (1 mark)
  3. Write a statement to display only the column Garden. (1 mark)

DataFrame: Garden

GardenTreesShrubs
G1Rose11070
G2Lotus90120
G3Lily20100
G4Tulip70190
Answer
(i)
import pandas as pd
D = {'Garden': pd.Series(['Rose', 'Lotus', 'Lily', 'Tulip'], index=['G1', 'G2', 'G3', 'G4']),
     'Trees': pd.Series([110, 90, 20, 70], index=['G1', 'G2', 'G3', 'G4']),
     'Shrubs': pd.Series([70, 120, 100, 190], index=['G1', 'G2', 'G3', 'G4'])}
Garden = pd.DataFrame(D)
print(Garden)

Output:

   Garden  Trees  Shrubs
G1   Rose    110      70
G2  Lotus     90     120
G3   Lily     20     100
G4  Tulip     70     190
(ii)
print(Garden.loc['G3', 'Trees'])

Output:

20
(iii)
print(Garden['Garden'])

Output:

G1     Rose
G2    Lotus
G3     Lily
G4    Tulip
Name: Garden, dtype: object
E2.21Practice5 marks

The DataFrame Bank stores the accounts (in thousand rupees) of some customers.

  1. Write a Python program to create the DataFrame Bank given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to add a new row with the label A5: Customer Jatin, Deposit 80 and Withdraw 55. (1 mark)
  3. Write a statement to display only the column Customer. (1 mark)

DataFrame: Bank

CustomerDepositWithdraw
A1Farah6045
A2Girish18040
A3Harsh12050
A4Indu16015
Answer
(i)
import pandas as pd
Bank = pd.DataFrame({'Customer': ['Farah', 'Girish', 'Harsh', 'Indu'],
                     'Deposit': [60, 180, 120, 160],
                     'Withdraw': [45, 40, 50, 15]},
                    index=['A1', 'A2', 'A3', 'A4'])
print(Bank)

Output:

   Customer  Deposit  Withdraw
A1    Farah       60        45
A2   Girish      180        40
A3    Harsh      120        50
A4     Indu      160        15
(ii)
Bank.loc['A5'] = ['Jatin', 80, 55]

The DataFrame now:

   Customer  Deposit  Withdraw
A1    Farah       60        45
A2   Girish      180        40
A3    Harsh      120        50
A4     Indu      160        15
A5    Jatin       80        55
(iii)
print(Bank['Customer'])

Output:

A1     Farah
A2    Girish
A3     Harsh
A4      Indu
Name: Customer, dtype: object
E2.22Practice5 marks

The DataFrame Game stores the scores of some gamers.

  1. Write a Python program to create the DataFrame Game given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to add a new row with the label G5: Gamer Zen, Round1 72 and Round2 54. (1 mark)
  3. Write a statement to display the rows where Round2 is more than 42. (1 mark)

DataFrame: Game

GamerRound1Round2
G1Neo3242
G2Rex2065
G3Sky5932
G4Max5261
Answer
(i)
import pandas as pd
D = {'Gamer': pd.Series(['Neo', 'Rex', 'Sky', 'Max'], index=['G1', 'G2', 'G3', 'G4']),
     'Round1': pd.Series([32, 20, 59, 52], index=['G1', 'G2', 'G3', 'G4']),
     'Round2': pd.Series([42, 65, 32, 61], index=['G1', 'G2', 'G3', 'G4'])}
Game = pd.DataFrame(D)
print(Game)

Output:

   Gamer  Round1  Round2
G1   Neo      32      42
G2   Rex      20      65
G3   Sky      59      32
G4   Max      52      61
(ii)
Game.loc['G5'] = ['Zen', 72, 54]

The DataFrame now:

   Gamer  Round1  Round2
G1   Neo      32      42
G2   Rex      20      65
G3   Sky      59      32
G4   Max      52      61
G5   Zen      72      54
(iii)
print(Game[Game['Round2'] > 42])

Output:

   Gamer  Round1  Round2
G2   Rex      20      65
G4   Max      52      61
E2.23Practice5 marks

The DataFrame Mobile stores the mobile phones in a showroom.

  1. Write a Python program to create the DataFrame Mobile given below from a dictionary of lists, and display it. (3 marks)
  2. Write a statement to display only the column Model. (1 mark)
  3. Write a statement to display the first two rows. (1 mark)

DataFrame: Mobile

ModelPriceStock
M1Astra100004
M2Bolt1500013
M3Comet200003
M4Dyna2700010
Answer
(i)
import pandas as pd
Mobile = pd.DataFrame({'Model': ['Astra', 'Bolt', 'Comet', 'Dyna'],
                       'Price': [10000, 15000, 20000, 27000],
                       'Stock': [4, 13, 3, 10]},
                      index=['M1', 'M2', 'M3', 'M4'])
print(Mobile)

Output:

    Model  Price  Stock
M1  Astra  10000      4
M2   Bolt  15000     13
M3  Comet  20000      3
M4   Dyna  27000     10
(ii)
print(Mobile['Model'])

Output:

M1    Astra
M2     Bolt
M3    Comet
M4     Dyna
Name: Model, dtype: object
(iii)
print(Mobile.head(2))

Output:

    Model  Price  Stock
M1  Astra  10000      4
M2   Bolt  15000     13
E2.24Practice5 marks

The DataFrame Quiz stores the scores of the teams in a quiz.

  1. Write a Python program to create the DataFrame Quiz given below from a dictionary of Series, and display it. (3 marks)
  2. Write a statement to add a new column Total, which is Round1 plus Round2. (1 mark)
  3. Write a statement to display the Round1 of the row Q3. (1 mark)

DataFrame: Quiz

TeamRound1Round2
Q1Alpha3050
Q2Beta4010
Q3Gamma1525
Q4Delta2535
Answer
(i)
import pandas as pd
D = {'Team': pd.Series(['Alpha', 'Beta', 'Gamma', 'Delta'], index=['Q1', 'Q2', 'Q3', 'Q4']),
     'Round1': pd.Series([30, 40, 15, 25], index=['Q1', 'Q2', 'Q3', 'Q4']),
     'Round2': pd.Series([50, 10, 25, 35], index=['Q1', 'Q2', 'Q3', 'Q4'])}
Quiz = pd.DataFrame(D)
print(Quiz)

Output:

     Team  Round1  Round2
Q1  Alpha      30      50
Q2   Beta      40      10
Q3  Gamma      15      25
Q4  Delta      25      35
(ii)
Quiz['Total'] = Quiz['Round1'] + Quiz['Round2']

The DataFrame now:

     Team  Round1  Round2  Total
Q1  Alpha      30      50     80
Q2   Beta      40      10     50
Q3  Gamma      15      25     40
Q4  Delta      25      35     60
(iii)
print(Quiz.loc['Q3', 'Round1'])

Output:

15
E3SQL commands and queries in five parts5 marks · 44 questions
E3.1Practice5 marks

Consider the table PATIENT given below. Write SQL commands to:

  1. Add a new row with the values 107, 'Aman', 'Cardiology', 3, 5994.18, '2026-12-15'
  2. Increase the Days by 5 for the rows where Dept is 'Cardiology'
  3. Delete the rows where Days is less than 4
  4. Add a new column Remarks of type VARCHAR(30)
  5. Remove the table PATIENT from the database.

Table: PATIENT

PNoPNameDeptDaysBillDOA
101YashCardiology25000.322026-03-11
102ChetanCardiology155983.682026-03-01
103ZeenatCardiology48922.892026-07-02
104SwatiOrtho76492.812026-04-01
105PankajENT148701.772026-03-13
106MohitENT135473.262026-02-19
Answer
(i)
INSERT INTO PATIENT VALUES (107, 'Aman', 'Cardiology', 3, 5994.18, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE PATIENT SET Days = Days + 5 WHERE Dept = 'Cardiology';

Rows affected: 3

Explanation: SET Days = Days + 5 changes the value; WHERE limits the change to the rows where Dept is 'Cardiology': 3 rows changed.

(iii)
DELETE FROM PATIENT WHERE Days < 4;

Rows affected: 1

Explanation: WHERE picks the rows where Days is less than 4: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE PATIENT ADD Remarks VARCHAR(30);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE PATIENT;

Explanation: DROP removes the whole object with its data.

E3.2Practice5 marks

Consider the table PATIENT given below. Write SQL queries to display:

  1. Each PName and its Bill rounded to one decimal place
  2. The PName that end with the letter 'n'
  3. The PName and Days of the rows where Days is 7 or less
  4. The total Days of the rows where Dept is 'Cardiology'
  5. The first three characters of each PName.

Table: PATIENT

PNoPNameDeptDaysBillDOA
101YashCardiology25000.322026-03-11
102ChetanCardiology155983.682026-03-01
103ZeenatCardiology48922.892026-07-02
104SwatiOrtho76492.812026-04-01
105PankajENT148701.772026-03-13
106MohitENT135473.262026-02-19
Answer
(i)
SELECT PName, ROUND(Bill, 1) FROM PATIENT;
PNameROUND(Bill, 1)
Yash5000.3
Chetan5983.7
Zeenat8922.9
Swati6492.8
Pankaj8701.8
Mohit5473.3

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT PName FROM PATIENT WHERE PName LIKE '%n';
PName
Chetan

Explanation: WHERE keeps only the rows where PName matches the pattern '%n': 1 of the 6 rows matches (Chetan). '%n' means the value ends with 'n'.

(iii)
SELECT PName, Days FROM PATIENT WHERE Days <= 7;
PNameDays
Yash2
Zeenat4
Swati7

Explanation: WHERE keeps only the rows where Days is at most 7: 3 of the 6 rows match (Yash, Zeenat, Swati).

(iv)
SELECT SUM(Days) FROM PATIENT WHERE Dept = 'Cardiology';
SUM(Days)
21

Explanation: WHERE keeps only the rows where Dept is 'Cardiology': 3 of the 6 rows match (Yash, Chetan, Zeenat). SUM adds the values of the matching rows.

(v)
SELECT LEFT(PName, 3) FROM PATIENT;
LEFT(PName, 3)
Yas
Che
Zee
Swa
Pan
Moh

Explanation: The function LEFT is worked out for every row that is shown.

E3.3Practice5 marks

Consider the table EMPLOYEE given below. Write SQL commands to:

  1. Add a new row with the values 17, 'Bhavna', 'Sales', 43001, 1735.52, '2025-12-15'
  2. Increase the Salary by 500 for the rows where Dept is 'Sales'
  3. Delete the rows where Salary is less than 31000
  4. Add a new column Email of type VARCHAR(40)
  5. Remove the table EMPLOYEE from the database.

Table: EMPLOYEE

ENoENameDeptSalaryBonusDOJ
11IshaHR430003522.372023-02-02
12YashSales400001725.022025-08-02
13SumanHR440003550.142019-09-25
14JatinSales450001269.742025-03-19
15NikhilSales250003263.382022-09-09
16SachinAccounts310003064.282021-05-17
Answer
(i)
INSERT INTO EMPLOYEE VALUES (17, 'Bhavna', 'Sales', 43001, 1735.52, '2025-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE EMPLOYEE SET Salary = Salary + 500 WHERE Dept = 'Sales';

Rows affected: 3

Explanation: SET Salary = Salary + 500 changes the value; WHERE limits the change to the rows where Dept is 'Sales': 3 rows changed.

(iii)
DELETE FROM EMPLOYEE WHERE Salary < 31000;

Rows affected: 1

Explanation: WHERE picks the rows where Salary is less than 31000: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE EMPLOYEE ADD Email VARCHAR(40);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE EMPLOYEE;

Explanation: DROP removes the whole object with its data.

E3.4Practice5 marks

Consider the table EMPLOYEE given below. Write SQL queries to display:

  1. Each EName and its Bonus rounded to the nearest whole number
  2. The rows where EName starts with the letter 'I'
  3. The EName and Salary of the rows where Salary is 40000 or less
  4. The highest and the lowest Bonus
  5. The EName in capital letters.

Table: EMPLOYEE

ENoENameDeptSalaryBonusDOJ
11IshaHR430003522.372023-02-02
12YashSales400001725.022025-08-02
13SumanHR440003550.142019-09-25
14JatinSales450001269.742025-03-19
15NikhilSales250003263.382022-09-09
16SachinAccounts310003064.282021-05-17
Answer
(i)
SELECT EName, ROUND(Bonus) FROM EMPLOYEE;
ENameROUND(Bonus)
Isha3522
Yash1725
Suman3550
Jatin1270
Nikhil3263
Sachin3064

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM EMPLOYEE WHERE EName LIKE 'I%';
ENoENameDeptSalaryBonusDOJ
11IshaHR430003522.372023-02-02

Explanation: WHERE keeps only the rows where EName matches the pattern 'I%': 1 of the 6 rows matches (Isha). 'I%' means the value starts with 'I'.

(iii)
SELECT EName, Salary FROM EMPLOYEE WHERE Salary <= 40000;
ENameSalary
Yash40000
Nikhil25000
Sachin31000

Explanation: WHERE keeps only the rows where Salary is at most 40000: 3 of the 6 rows match (Yash, Nikhil, Sachin).

(iv)
SELECT MAX(Bonus), MIN(Bonus) FROM EMPLOYEE;
MAX(Bonus)MIN(Bonus)
3550.141269.74

Explanation: MAX gives the largest value of all the rows. MIN gives the smallest value.

(v)
SELECT UCASE(EName) FROM EMPLOYEE;
UCASE(EName)
ISHA
YASH
SUMAN
JATIN
NIKHIL
SACHIN

Explanation: The function UCASE is worked out for every row that is shown.

E3.5Practice5 marks

Consider the table BOOK given below. Write SQL commands to:

  1. Add a new row with the values 7, 'New Wings', 'Fiction', 121, 347.53, '2025-12-15'
  2. Increase the Pages by 2 for the rows where Genre is 'Fiction'
  3. Delete the rows where Pages is less than 150
  4. Add a new column Grade of type CHAR(1)
  5. Remove the table BOOK from the database.

Table: BOOK

BNoTitleGenrePagesPriceDOP
1Wings of FireFiction120342.442022-06-18
2Malgudi DaysFiction290337.032025-06-20
3PanchatantraBiography150339.912021-07-27
4GodanPoetry320195.342024-05-13
5GitanjaliBiography440520.872024-10-12
6Train to PakistanFiction330359.452021-10-21
Answer
(i)
INSERT INTO BOOK VALUES (7, 'New Wings', 'Fiction', 121, 347.53, '2025-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE BOOK SET Pages = Pages + 2 WHERE Genre = 'Fiction';

Rows affected: 3

Explanation: SET Pages = Pages + 2 changes the value; WHERE limits the change to the rows where Genre is 'Fiction': 3 rows changed.

(iii)
DELETE FROM BOOK WHERE Pages < 150;

Rows affected: 1

Explanation: WHERE picks the rows where Pages is less than 150: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE BOOK ADD Grade CHAR(1);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE BOOK;

Explanation: DROP removes the whole object with its data.

E3.6Practice5 marks

Consider the table BOOK given below. Write SQL queries to display:

  1. Each Title and its Price rounded to one decimal place
  2. The Title that end with the letter 's'
  3. The Title and Pages of the rows where Pages is 290 or less
  4. The number of rows where Genre is 'Fiction'
  5. Each Title and the number of characters in it.

Table: BOOK

BNoTitleGenrePagesPriceDOP
1Wings of FireFiction120342.442022-06-18
2Malgudi DaysFiction290337.032025-06-20
3PanchatantraBiography150339.912021-07-27
4GodanPoetry320195.342024-05-13
5GitanjaliBiography440520.872024-10-12
6Train to PakistanFiction330359.452021-10-21
Answer
(i)
SELECT Title, ROUND(Price, 1) FROM BOOK;
TitleROUND(Price, 1)
Wings of Fire342.4
Malgudi Days337.0
Panchatantra339.9
Godan195.3
Gitanjali520.9
Train to Pakistan359.5

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT Title FROM BOOK WHERE Title LIKE '%s';
Title
Malgudi Days

Explanation: WHERE keeps only the rows where Title matches the pattern '%s': 1 of the 6 rows matches (Malgudi Days). '%s' means the value ends with 's'.

(iii)
SELECT Title, Pages FROM BOOK WHERE Pages <= 290;
TitlePages
Wings of Fire120
Malgudi Days290
Panchatantra150

Explanation: WHERE keeps only the rows where Pages is at most 290: 3 of the 6 rows match (Wings of Fire, Malgudi Days, Panchatantra).

(iv)
SELECT COUNT(*) FROM BOOK WHERE Genre = 'Fiction';
COUNT(*)
3

Explanation: WHERE keeps only the rows where Genre is 'Fiction': 3 of the 6 rows match (Wings of Fire, Malgudi Days, Train to Pakistan). COUNT(*) counts the rows of the matching rows.

(v)
SELECT Title, LENGTH(Title) FROM BOOK;
TitleLENGTH(Title)
Wings of Fire13
Malgudi Days12
Panchatantra12
Godan5
Gitanjali9
Train to Pakistan17

Explanation: The function LENGTH is worked out for every row that is shown.

E3.7Practice5 marks

Consider the table STUDENT given below. Write SQL commands to:

  1. Add a new row with the values 7, 'Divya', 'Science', 72, 3809.87, '2010-12-15'
  2. Increase the Marks by 100 for the rows where Stream is 'Science'
  3. Delete the rows where Marks is less than 63
  4. Add a new column City of type VARCHAR(20)
  5. Remove the table STUDENT from the database.

Table: STUDENT

RNoSNameStreamMarksFeesDOB
1IshaScience716193.932008-08-26
2DeepakScience603799.372008-11-04
3GeetaScience883372.652010-03-11
4TanviHumanities764392.132009-02-04
5RohanCommerce633443.292008-05-08
6UmeshCommerce852597.322010-06-25
Answer
(i)
INSERT INTO STUDENT VALUES (7, 'Divya', 'Science', 72, 3809.87, '2010-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE STUDENT SET Marks = Marks + 100 WHERE Stream = 'Science';

Rows affected: 3

Explanation: SET Marks = Marks + 100 changes the value; WHERE limits the change to the rows where Stream is 'Science': 3 rows changed.

(iii)
DELETE FROM STUDENT WHERE Marks < 63;

Rows affected: 1

Explanation: WHERE picks the rows where Marks is less than 63: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE STUDENT ADD City VARCHAR(20);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE STUDENT;

Explanation: DROP removes the whole object with its data.

E3.8Practice5 marks

Consider the table STUDENT given below. Write SQL queries to display:

  1. Each SName and its Fees rounded to the nearest whole number
  2. The rows where SName starts with the letter 'I'
  3. The SName and Marks of the rows where Marks is 71 or less
  4. The total Marks of the rows where Stream is 'Science'
  5. Each SName and the name of the month of DOB.

Table: STUDENT

RNoSNameStreamMarksFeesDOB
1IshaScience716193.932008-08-26
2DeepakScience603799.372008-11-04
3GeetaScience883372.652010-03-11
4TanviHumanities764392.132009-02-04
5RohanCommerce633443.292008-05-08
6UmeshCommerce852597.322010-06-25
Answer
(i)
SELECT SName, ROUND(Fees) FROM STUDENT;
SNameROUND(Fees)
Isha6194
Deepak3799
Geeta3373
Tanvi4392
Rohan3443
Umesh2597

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM STUDENT WHERE SName LIKE 'I%';
RNoSNameStreamMarksFeesDOB
1IshaScience716193.932008-08-26

Explanation: WHERE keeps only the rows where SName matches the pattern 'I%': 1 of the 6 rows matches (Isha). 'I%' means the value starts with 'I'.

(iii)
SELECT SName, Marks FROM STUDENT WHERE Marks <= 71;
SNameMarks
Isha71
Deepak60
Rohan63

Explanation: WHERE keeps only the rows where Marks is at most 71: 3 of the 6 rows match (Isha, Deepak, Rohan).

(iv)
SELECT SUM(Marks) FROM STUDENT WHERE Stream = 'Science';
SUM(Marks)
219

Explanation: WHERE keeps only the rows where Stream is 'Science': 3 of the 6 rows match (Isha, Deepak, Geeta). SUM adds the values of the matching rows.

(v)
SELECT SName, MONTHNAME(DOB) FROM STUDENT;
SNameMONTHNAME(DOB)
IshaAugust
DeepakNovember
GeetaMarch
TanviFebruary
RohanMay
UmeshJune

Explanation: The function MONTHNAME is worked out for every row that is shown.

E3.9Practice5 marks

Consider the table PRODUCT given below. Write SQL commands to:

  1. Add a new row with the values 507, 'New Soap', 'Sai Mart', 131, 397.66, '2026-12-15'
  2. Increase the Stock by 5 for the rows where Company is 'Sai Mart'
  3. Delete the rows where Stock is less than 40
  4. Add a new column Remarks of type VARCHAR(30)
  5. Remove the table PRODUCT from the database.

Table: PRODUCT

PCodePNameCompanyStockPriceMfgDate
501SoapNeha Foods130114.822026-04-27
502ShampooSai Mart40387.162026-05-15
503BiscuitNeha Foods110187.062026-07-05
504ToothpasteOm Traders30275.282026-11-16
505JuiceNeha Foods120111.882026-11-04
506ButterOm Traders180293.322026-04-27
Answer
(i)
INSERT INTO PRODUCT VALUES (507, 'New Soap', 'Sai Mart', 131, 397.66, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE PRODUCT SET Stock = Stock + 5 WHERE Company = 'Sai Mart';

Rows affected: 1

Explanation: SET Stock = Stock + 5 changes the value; WHERE limits the change to the rows where Company is 'Sai Mart': 1 row changed.

(iii)
DELETE FROM PRODUCT WHERE Stock < 40;

Rows affected: 1

Explanation: WHERE picks the rows where Stock is less than 40: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE PRODUCT ADD Remarks VARCHAR(30);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE PRODUCT;

Explanation: DROP removes the whole object with its data.

E3.10Practice5 marks

Consider the table PRODUCT given below. Write SQL queries to display:

  1. Each PName and its Price rounded to one decimal place
  2. The PName that end with the letter 'o'
  3. The PName and Stock of the rows where Stock is 110 or less
  4. The highest and the lowest Price
  5. Each PName and the name of the week day of MfgDate.

Table: PRODUCT

PCodePNameCompanyStockPriceMfgDate
501SoapNeha Foods130114.822026-04-27
502ShampooSai Mart40387.162026-05-15
503BiscuitNeha Foods110187.062026-07-05
504ToothpasteOm Traders30275.282026-11-16
505JuiceNeha Foods120111.882026-11-04
506ButterOm Traders180293.322026-04-27
Answer
(i)
SELECT PName, ROUND(Price, 1) FROM PRODUCT;
PNameROUND(Price, 1)
Soap114.8
Shampoo387.2
Biscuit187.1
Toothpaste275.3
Juice111.9
Butter293.3

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT PName FROM PRODUCT WHERE PName LIKE '%o';
PName
Shampoo

Explanation: WHERE keeps only the rows where PName matches the pattern '%o': 1 of the 6 rows matches (Shampoo). '%o' means the value ends with 'o'.

(iii)
SELECT PName, Stock FROM PRODUCT WHERE Stock <= 110;
PNameStock
Shampoo40
Biscuit110
Toothpaste30

Explanation: WHERE keeps only the rows where Stock is at most 110: 3 of the 6 rows match (Shampoo, Biscuit, Toothpaste).

(iv)
SELECT MAX(Price), MIN(Price) FROM PRODUCT;
MAX(Price)MIN(Price)
387.16111.88

Explanation: MAX gives the largest value of all the rows. MIN gives the smallest value.

(v)
SELECT PName, DAYNAME(MfgDate) FROM PRODUCT;
PNameDAYNAME(MfgDate)
SoapMonday
ShampooFriday
BiscuitSunday
ToothpasteMonday
JuiceWednesday
ButterMonday

Explanation: The function DAYNAME is worked out for every row that is shown.

E3.11Practice5 marks

Consider the table MEMBER given below. Write SQL commands to:

  1. Add a new row with the values 7, 'Isha', 'Gold', 4, 1691.26, '2026-12-15'
  2. Increase the Months by 10 for the rows where Plan is 'Gold'
  3. Delete the rows where Months is less than 4
  4. Add a new column Email of type VARCHAR(40)
  5. Remove the table MEMBER from the database.

Table: MEMBER

MNoMNamePlanMonthsFeeJoinDate
1MohitGold32755.292026-07-09
2VikasGold91680.762025-04-25
3TanviSilver122149.512025-01-03
4PallaviGold41398.782026-05-02
5DivyaSilver62568.092025-06-13
6AmanBasic82546.012026-06-19
Answer
(i)
INSERT INTO MEMBER VALUES (7, 'Isha', 'Gold', 4, 1691.26, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE MEMBER SET Months = Months + 10 WHERE Plan = 'Gold';

Rows affected: 3

Explanation: SET Months = Months + 10 changes the value; WHERE limits the change to the rows where Plan is 'Gold': 3 rows changed.

(iii)
DELETE FROM MEMBER WHERE Months < 4;

Rows affected: 1

Explanation: WHERE picks the rows where Months is less than 4: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE MEMBER ADD Email VARCHAR(40);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE MEMBER;

Explanation: DROP removes the whole object with its data.

E3.12Practice5 marks

Consider the table MEMBER given below. Write SQL queries to display:

  1. Each MName and its Fee rounded to the nearest whole number
  2. The rows where MName starts with the letter 'M'
  3. The MName and Months of the rows where Months is 6 or less
  4. The number of rows where Plan is 'Gold'
  5. The last two characters of each MName.

Table: MEMBER

MNoMNamePlanMonthsFeeJoinDate
1MohitGold32755.292026-07-09
2VikasGold91680.762025-04-25
3TanviSilver122149.512025-01-03
4PallaviGold41398.782026-05-02
5DivyaSilver62568.092025-06-13
6AmanBasic82546.012026-06-19
Answer
(i)
SELECT MName, ROUND(Fee) FROM MEMBER;
MNameROUND(Fee)
Mohit2755
Vikas1681
Tanvi2150
Pallavi1399
Divya2568
Aman2546

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM MEMBER WHERE MName LIKE 'M%';
MNoMNamePlanMonthsFeeJoinDate
1MohitGold32755.292026-07-09

Explanation: WHERE keeps only the rows where MName matches the pattern 'M%': 1 of the 6 rows matches (Mohit). 'M%' means the value starts with 'M'.

(iii)
SELECT MName, Months FROM MEMBER WHERE Months <= 6;
MNameMonths
Mohit3
Pallavi4
Divya6

Explanation: WHERE keeps only the rows where Months is at most 6: 3 of the 6 rows match (Mohit, Pallavi, Divya).

(iv)
SELECT COUNT(*) FROM MEMBER WHERE Plan = 'Gold';
COUNT(*)
3

Explanation: WHERE keeps only the rows where Plan is 'Gold': 3 of the 6 rows match (Mohit, Vikas, Pallavi). COUNT(*) counts the rows of the matching rows.

(v)
SELECT RIGHT(MName, 2) FROM MEMBER;
RIGHT(MName, 2)
it
as
vi
vi
ya
an

Explanation: The function RIGHT is worked out for every row that is shown.

E3.13Practice5 marks

Consider the table TICKET given below. Write SQL commands to:

  1. Add a new row with the values 307, 'Kavita', 'Goa', 4, 6838.96, '2027-12-15'
  2. Increase the Seats by 2 for the rows where Dest is 'Goa'
  3. Delete the rows where Seats is less than 3
  4. Add a new column Grade of type CHAR(1)
  5. Remove the table TICKET from the database.

Table: TICKET

TNoPassengerDestSeatsFareTravelDate
301AnitaGoa39384.042026-01-28
302BhavnaGoa36828.462026-03-11
303SimranKochi68802.732026-04-28
304AmanKochi46806.372026-10-14
305JatinGoa24173.892027-05-03
306SonalLeh59385.632026-12-18
Answer
(i)
INSERT INTO TICKET VALUES (307, 'Kavita', 'Goa', 4, 6838.96, '2027-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE TICKET SET Seats = Seats + 2 WHERE Dest = 'Goa';

Rows affected: 3

Explanation: SET Seats = Seats + 2 changes the value; WHERE limits the change to the rows where Dest is 'Goa': 3 rows changed.

(iii)
DELETE FROM TICKET WHERE Seats < 3;

Rows affected: 1

Explanation: WHERE picks the rows where Seats is less than 3: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE TICKET ADD Grade CHAR(1);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE TICKET;

Explanation: DROP removes the whole object with its data.

E3.14Practice5 marks

Consider the table TICKET given below. Write SQL queries to display:

  1. Each Passenger and its Fare rounded to one decimal place
  2. The Passenger that end with the letter 'a'
  3. The Passenger and Seats of the rows where Seats is 3 or less
  4. The total Seats of the rows where Dest is 'Goa'
  5. The first three characters of each Passenger.

Table: TICKET

TNoPassengerDestSeatsFareTravelDate
301AnitaGoa39384.042026-01-28
302BhavnaGoa36828.462026-03-11
303SimranKochi68802.732026-04-28
304AmanKochi46806.372026-10-14
305JatinGoa24173.892027-05-03
306SonalLeh59385.632026-12-18
Answer
(i)
SELECT Passenger, ROUND(Fare, 1) FROM TICKET;
PassengerROUND(Fare, 1)
Anita9384.0
Bhavna6828.5
Simran8802.7
Aman6806.4
Jatin4173.9
Sonal9385.6

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT Passenger FROM TICKET WHERE Passenger LIKE '%a';
Passenger
Anita
Bhavna

Explanation: WHERE keeps only the rows where Passenger matches the pattern '%a': 2 of the 6 rows match (Anita, Bhavna). '%a' means the value ends with 'a'.

(iii)
SELECT Passenger, Seats FROM TICKET WHERE Seats <= 3;
PassengerSeats
Anita3
Bhavna3
Jatin2

Explanation: WHERE keeps only the rows where Seats is at most 3: 3 of the 6 rows match (Anita, Bhavna, Jatin).

(iv)
SELECT SUM(Seats) FROM TICKET WHERE Dest = 'Goa';
SUM(Seats)
8

Explanation: WHERE keeps only the rows where Dest is 'Goa': 3 of the 6 rows match (Anita, Bhavna, Jatin). SUM adds the values of the matching rows.

(v)
SELECT LEFT(Passenger, 3) FROM TICKET;
LEFT(Passenger, 3)
Ani
Bha
Sim
Ama
Jat
Son

Explanation: The function LEFT is worked out for every row that is shown.

E3.15Practice5 marks

Consider the table MOVIE given below. Write SQL commands to:

  1. Add a new row with the values 7, 'New Udaan', 'Comedy', 171, 18.02, '2026-12-15'
  2. Increase the Minutes by 100 for the rows where Genre is 'Comedy'
  3. Delete the rows where Minutes is less than 115
  4. Add a new column City of type VARCHAR(20)
  5. Remove the table MOVIE from the database.

Table: MOVIE

MNoTitleGenreMinutesRatingRelDate
1UdaanComedy1708.542026-03-24
2SafarComedy1457.522024-08-10
3DostiDrama1256.872023-12-27
4RangoliComedy1305.112023-10-16
5KhelAction1056.832024-12-18
6SapnaAction1155.332024-12-07
Answer
(i)
INSERT INTO MOVIE VALUES (7, 'New Udaan', 'Comedy', 171, 18.02, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE MOVIE SET Minutes = Minutes + 100 WHERE Genre = 'Comedy';

Rows affected: 3

Explanation: SET Minutes = Minutes + 100 changes the value; WHERE limits the change to the rows where Genre is 'Comedy': 3 rows changed.

(iii)
DELETE FROM MOVIE WHERE Minutes < 115;

Rows affected: 1

Explanation: WHERE picks the rows where Minutes is less than 115: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE MOVIE ADD City VARCHAR(20);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE MOVIE;

Explanation: DROP removes the whole object with its data.

E3.16Practice5 marks

Consider the table MOVIE given below. Write SQL queries to display:

  1. Each Title and its Rating rounded to the nearest whole number
  2. The rows where Title starts with the letter 'U'
  3. The Title and Minutes of the rows where Minutes is 125 or less
  4. The highest and the lowest Rating
  5. The Title in capital letters.

Table: MOVIE

MNoTitleGenreMinutesRatingRelDate
1UdaanComedy1708.542026-03-24
2SafarComedy1457.522024-08-10
3DostiDrama1256.872023-12-27
4RangoliComedy1305.112023-10-16
5KhelAction1056.832024-12-18
6SapnaAction1155.332024-12-07
Answer
(i)
SELECT Title, ROUND(Rating) FROM MOVIE;
TitleROUND(Rating)
Udaan9
Safar8
Dosti7
Rangoli5
Khel7
Sapna5

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM MOVIE WHERE Title LIKE 'U%';
MNoTitleGenreMinutesRatingRelDate
1UdaanComedy1708.542026-03-24

Explanation: WHERE keeps only the rows where Title matches the pattern 'U%': 1 of the 6 rows matches (Udaan). 'U%' means the value starts with 'U'.

(iii)
SELECT Title, Minutes FROM MOVIE WHERE Minutes <= 125;
TitleMinutes
Dosti125
Khel105
Sapna115

Explanation: WHERE keeps only the rows where Minutes is at most 125: 3 of the 6 rows match (Dosti, Khel, Sapna).

(iv)
SELECT MAX(Rating), MIN(Rating) FROM MOVIE;
MAX(Rating)MIN(Rating)
8.545.11

Explanation: MAX gives the largest value of all the rows. MIN gives the smallest value.

(v)
SELECT UCASE(Title) FROM MOVIE;
UCASE(Title)
UDAAN
SAFAR
DOSTI
RANGOLI
KHEL
SAPNA

Explanation: The function UCASE is worked out for every row that is shown.

E3.17Practice5 marks

Consider the table COURSE given below. Write SQL commands to:

  1. Add a new row with the values 27, 'New Python', 'Offline', 7, 3030.63, '2027-12-15'
  2. Increase the Weeks by 5 for the rows where Mode is 'Offline'
  3. Delete the rows where Weeks is less than 6
  4. Add a new column Remarks of type VARCHAR(30)
  5. Remove the table COURSE from the database.

Table: COURSE

CNoCNameModeWeeksFeeStartDate
21PythonOnline68375.412026-06-06
22Web DesignOffline83020.132026-10-13
23TallyOnline104826.352027-03-23
24AnimationHybrid228778.762026-11-11
25RoboticsHybrid46911.582026-09-27
26Data EntryOnline249871.532027-11-05
Answer
(i)
INSERT INTO COURSE VALUES (27, 'New Python', 'Offline', 7, 3030.63, '2027-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE COURSE SET Weeks = Weeks + 5 WHERE Mode = 'Offline';

Rows affected: 1

Explanation: SET Weeks = Weeks + 5 changes the value; WHERE limits the change to the rows where Mode is 'Offline': 1 row changed.

(iii)
DELETE FROM COURSE WHERE Weeks < 6;

Rows affected: 1

Explanation: WHERE picks the rows where Weeks is less than 6: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE COURSE ADD Remarks VARCHAR(30);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE COURSE;

Explanation: DROP removes the whole object with its data.

E3.18Practice5 marks

Consider the table COURSE given below. Write SQL queries to display:

  1. Each CName and its Fee rounded to one decimal place
  2. The CName that end with the letter 'n'
  3. The CName and Weeks of the rows where Weeks is 8 or less
  4. The number of rows where Mode is 'Online'
  5. Each CName and the number of characters in it.

Table: COURSE

CNoCNameModeWeeksFeeStartDate
21PythonOnline68375.412026-06-06
22Web DesignOffline83020.132026-10-13
23TallyOnline104826.352027-03-23
24AnimationHybrid228778.762026-11-11
25RoboticsHybrid46911.582026-09-27
26Data EntryOnline249871.532027-11-05
Answer
(i)
SELECT CName, ROUND(Fee, 1) FROM COURSE;
CNameROUND(Fee, 1)
Python8375.4
Web Design3020.1
Tally4826.4
Animation8778.8
Robotics6911.6
Data Entry9871.5

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT CName FROM COURSE WHERE CName LIKE '%n';
CName
Python
Web Design
Animation

Explanation: WHERE keeps only the rows where CName matches the pattern '%n': 3 of the 6 rows match (Python, Web Design, Animation). '%n' means the value ends with 'n'.

(iii)
SELECT CName, Weeks FROM COURSE WHERE Weeks <= 8;
CNameWeeks
Python6
Web Design8
Robotics4

Explanation: WHERE keeps only the rows where Weeks is at most 8: 3 of the 6 rows match (Python, Web Design, Robotics).

(iv)
SELECT COUNT(*) FROM COURSE WHERE Mode = 'Online';
COUNT(*)
3

Explanation: WHERE keeps only the rows where Mode is 'Online': 3 of the 6 rows match (Python, Tally, Data Entry). COUNT(*) counts the rows of the matching rows.

(v)
SELECT CName, LENGTH(CName) FROM COURSE;
CNameLENGTH(CName)
Python6
Web Design10
Tally5
Animation9
Robotics8
Data Entry10

Explanation: The function LENGTH is worked out for every row that is shown.

E3.19Practice5 marks

Consider the table VEHICLE given below. Write SQL commands to:

  1. Add a new row with the values 707, 'Lokesh', 'Van', 14501, 2232.57, '2025-12-15'
  2. Increase the Km by 500 for the rows where Type is 'Van'
  3. Delete the rows where Km is less than 15500
  4. Add a new column Email of type VARCHAR(40)
  5. Remove the table VEHICLE from the database.

Table: VEHICLE

VNoOwnerTypeKmTaxRegDate
701YashBike145002852.032019-01-09
702ShreyaVan590002222.072023-01-21
703SimranCar275002206.182018-07-13
704SwatiVan255001253.912020-12-12
705SandeepCar540002275.812025-01-14
706AmanCar155001981.682018-12-01
Answer
(i)
INSERT INTO VEHICLE VALUES (707, 'Lokesh', 'Van', 14501, 2232.57, '2025-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE VEHICLE SET Km = Km + 500 WHERE Type = 'Van';

Rows affected: 2

Explanation: SET Km = Km + 500 changes the value; WHERE limits the change to the rows where Type is 'Van': 2 rows changed.

(iii)
DELETE FROM VEHICLE WHERE Km < 15500;

Rows affected: 1

Explanation: WHERE picks the rows where Km is less than 15500: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE VEHICLE ADD Email VARCHAR(40);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE VEHICLE;

Explanation: DROP removes the whole object with its data.

E3.20Practice5 marks

Consider the table VEHICLE given below. Write SQL queries to display:

  1. Each Owner and its Tax rounded to the nearest whole number
  2. The rows where Owner starts with the letter 'Y'
  3. The Owner and Km of the rows where Km is 25500 or less
  4. The total Km of the rows where Type is 'Bike'
  5. Each Owner and the name of the month of RegDate.

Table: VEHICLE

VNoOwnerTypeKmTaxRegDate
701YashBike145002852.032019-01-09
702ShreyaVan590002222.072023-01-21
703SimranCar275002206.182018-07-13
704SwatiVan255001253.912020-12-12
705SandeepCar540002275.812025-01-14
706AmanCar155001981.682018-12-01
Answer
(i)
SELECT Owner, ROUND(Tax) FROM VEHICLE;
OwnerROUND(Tax)
Yash2852
Shreya2222
Simran2206
Swati1254
Sandeep2276
Aman1982

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM VEHICLE WHERE Owner LIKE 'Y%';
VNoOwnerTypeKmTaxRegDate
701YashBike145002852.032019-01-09

Explanation: WHERE keeps only the rows where Owner matches the pattern 'Y%': 1 of the 6 rows matches (Yash). 'Y%' means the value starts with 'Y'.

(iii)
SELECT Owner, Km FROM VEHICLE WHERE Km <= 25500;
OwnerKm
Yash14500
Swati25500
Aman15500

Explanation: WHERE keeps only the rows where Km is at most 25500: 3 of the 6 rows match (Yash, Swati, Aman).

(iv)
SELECT SUM(Km) FROM VEHICLE WHERE Type = 'Bike';
SUM(Km)
14500

Explanation: WHERE keeps only the rows where Type is 'Bike': 1 of the 6 rows matches (Yash). SUM adds the values of the matching rows.

(v)
SELECT Owner, MONTHNAME(RegDate) FROM VEHICLE;
OwnerMONTHNAME(RegDate)
YashJanuary
ShreyaJanuary
SimranJuly
SwatiDecember
SandeepJanuary
AmanDecember

Explanation: The function MONTHNAME is worked out for every row that is shown.

E3.21Practice5 marks

Consider the table ORDERS given below. Write SQL commands to:

  1. Add a new row with the values 9007, 'Naveen', 'Agra', 6, 7672.53, '2026-12-15'
  2. Increase the Qty by 2 for the rows where City is 'Agra'
  3. Delete the rows where Qty is less than 5
  4. Add a new column Grade of type CHAR(1)
  5. Remove the table ORDERS from the database.

Table: ORDERS

ONoCustomerCityQtyAmountODate
9001HarishDelhi56729.592026-06-22
9002PallaviAgra37662.032026-10-28
9003YashPune11561.132026-11-22
9004ArjunPune124746.242026-04-01
9005NikhilDelhi133876.232026-04-20
9006FarhanDelhi66568.182026-03-14
Answer
(i)
INSERT INTO ORDERS VALUES (9007, 'Naveen', 'Agra', 6, 7672.53, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE ORDERS SET Qty = Qty + 2 WHERE City = 'Agra';

Rows affected: 1

Explanation: SET Qty = Qty + 2 changes the value; WHERE limits the change to the rows where City is 'Agra': 1 row changed.

(iii)
DELETE FROM ORDERS WHERE Qty < 5;

Rows affected: 1

Explanation: WHERE picks the rows where Qty is less than 5: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE ORDERS ADD Grade CHAR(1);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE ORDERS;

Explanation: DROP removes the whole object with its data.

E3.22Practice5 marks

Consider the table ORDERS given below. Write SQL queries to display:

  1. Each Customer and its Amount rounded to one decimal place
  2. The Customer that end with the letter 'i'
  3. The Customer and Qty of the rows where Qty is 6 or less
  4. The highest and the lowest Amount
  5. Each Customer and the name of the week day of ODate.

Table: ORDERS

ONoCustomerCityQtyAmountODate
9001HarishDelhi56729.592026-06-22
9002PallaviAgra37662.032026-10-28
9003YashPune11561.132026-11-22
9004ArjunPune124746.242026-04-01
9005NikhilDelhi133876.232026-04-20
9006FarhanDelhi66568.182026-03-14
Answer
(i)
SELECT Customer, ROUND(Amount, 1) FROM ORDERS;
CustomerROUND(Amount, 1)
Harish6729.6
Pallavi7662.0
Yash561.1
Arjun4746.2
Nikhil3876.2
Farhan6568.2

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT Customer FROM ORDERS WHERE Customer LIKE '%i';
Customer
Pallavi

Explanation: WHERE keeps only the rows where Customer matches the pattern '%i': 1 of the 6 rows matches (Pallavi). '%i' means the value ends with 'i'.

(iii)
SELECT Customer, Qty FROM ORDERS WHERE Qty <= 6;
CustomerQty
Harish5
Pallavi3
Farhan6

Explanation: WHERE keeps only the rows where Qty is at most 6: 3 of the 6 rows match (Harish, Pallavi, Farhan).

(iv)
SELECT MAX(Amount), MIN(Amount) FROM ORDERS;
MAX(Amount)MIN(Amount)
7662.03561.13

Explanation: MAX gives the largest value of all the rows. MIN gives the smallest value.

(v)
SELECT Customer, DAYNAME(ODate) FROM ORDERS;
CustomerDAYNAME(ODate)
HarishMonday
PallaviWednesday
YashSunday
ArjunWednesday
NikhilMonday
FarhanSaturday

Explanation: The function DAYNAME is worked out for every row that is shown.

E3.23Practice5 marks

Consider the table DOCTOR given below. Write SQL commands to:

  1. Add a new row with the values 7, 'Pankaj', 'Skin', 6, 1061.59, '2022-12-15'
  2. Increase the Exp by 100 for the rows where Spec is 'Skin'
  3. Delete the rows where Exp is less than 5
  4. Add a new column City of type VARCHAR(20)
  5. Remove the table DOCTOR from the database.

Table: DOCTOR

DNoDNameSpecExpFeeDOJ
1AnitaDental5436.842022-09-22
2OjasviSkin231051.092012-07-22
3NikhilEye21178.342021-05-22
4MeenalSkin141100.172020-08-28
5NaveenDental121207.472014-01-06
6VikasSkin6435.162017-06-04
Answer
(i)
INSERT INTO DOCTOR VALUES (7, 'Pankaj', 'Skin', 6, 1061.59, '2022-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE DOCTOR SET Exp = Exp + 100 WHERE Spec = 'Skin';

Rows affected: 3

Explanation: SET Exp = Exp + 100 changes the value; WHERE limits the change to the rows where Spec is 'Skin': 3 rows changed.

(iii)
DELETE FROM DOCTOR WHERE Exp < 5;

Rows affected: 1

Explanation: WHERE picks the rows where Exp is less than 5: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE DOCTOR ADD City VARCHAR(20);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE DOCTOR;

Explanation: DROP removes the whole object with its data.

E3.24Practice5 marks

Consider the table DOCTOR given below. Write SQL queries to display:

  1. Each DName and its Fee rounded to the nearest whole number
  2. The rows where DName starts with the letter 'A'
  3. The DName and Exp of the rows where Exp is 6 or less
  4. The number of rows where Spec is 'Dental'
  5. The last two characters of each DName.

Table: DOCTOR

DNoDNameSpecExpFeeDOJ
1AnitaDental5436.842022-09-22
2OjasviSkin231051.092012-07-22
3NikhilEye21178.342021-05-22
4MeenalSkin141100.172020-08-28
5NaveenDental121207.472014-01-06
6VikasSkin6435.162017-06-04
Answer
(i)
SELECT DName, ROUND(Fee) FROM DOCTOR;
DNameROUND(Fee)
Anita437
Ojasvi1051
Nikhil1178
Meenal1100
Naveen1207
Vikas435

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM DOCTOR WHERE DName LIKE 'A%';
DNoDNameSpecExpFeeDOJ
1AnitaDental5436.842022-09-22

Explanation: WHERE keeps only the rows where DName matches the pattern 'A%': 1 of the 6 rows matches (Anita). 'A%' means the value starts with 'A'.

(iii)
SELECT DName, Exp FROM DOCTOR WHERE Exp <= 6;
DNameExp
Anita5
Nikhil2
Vikas6

Explanation: WHERE keeps only the rows where Exp is at most 6: 3 of the 6 rows match (Anita, Nikhil, Vikas).

(iv)
SELECT COUNT(*) FROM DOCTOR WHERE Spec = 'Dental';
COUNT(*)
2

Explanation: WHERE keeps only the rows where Spec is 'Dental': 2 of the 6 rows match (Anita, Naveen). COUNT(*) counts the rows of the matching rows.

(v)
SELECT RIGHT(DName, 2) FROM DOCTOR;
RIGHT(DName, 2)
ta
vi
il
al
en
as

Explanation: The function RIGHT is worked out for every row that is shown.

E3.25Practice5 marks

Consider the table PLAYER given below. Write SQL commands to:

  1. Add a new row with the values 7, 'Pankaj', 'Chess', 36, 58.99, '2010-12-15'
  2. Increase the Matches by 5 for the rows where Game is 'Chess'
  3. Delete the rows where Matches is less than 24
  4. Add a new column Remarks of type VARCHAR(30)
  5. Remove the table PLAYER from the database.

Table: PLAYER

PNoPNameGameMatchesAverageDOB
1NishaCricket3539.932007-12-23
2RachnaChess4448.492009-10-21
3MeenalCricket1962.942010-04-10
4NikhilCricket5140.512006-12-17
5HarishHockey2431.152010-08-13
6ZeenatHockey3629.332009-07-23
Answer
(i)
INSERT INTO PLAYER VALUES (7, 'Pankaj', 'Chess', 36, 58.99, '2010-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE PLAYER SET Matches = Matches + 5 WHERE Game = 'Chess';

Rows affected: 1

Explanation: SET Matches = Matches + 5 changes the value; WHERE limits the change to the rows where Game is 'Chess': 1 row changed.

(iii)
DELETE FROM PLAYER WHERE Matches < 24;

Rows affected: 1

Explanation: WHERE picks the rows where Matches is less than 24: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE PLAYER ADD Remarks VARCHAR(30);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE PLAYER;

Explanation: DROP removes the whole object with its data.

E3.26Practice5 marks

Consider the table PLAYER given below. Write SQL queries to display:

  1. Each PName and its Average rounded to one decimal place
  2. The PName that end with the letter 'a'
  3. The PName and Matches of the rows where Matches is 35 or less
  4. The total Matches of the rows where Game is 'Cricket'
  5. The first three characters of each PName.

Table: PLAYER

PNoPNameGameMatchesAverageDOB
1NishaCricket3539.932007-12-23
2RachnaChess4448.492009-10-21
3MeenalCricket1962.942010-04-10
4NikhilCricket5140.512006-12-17
5HarishHockey2431.152010-08-13
6ZeenatHockey3629.332009-07-23
Answer
(i)
SELECT PName, ROUND(Average, 1) FROM PLAYER;
PNameROUND(Average, 1)
Nisha39.9
Rachna48.5
Meenal62.9
Nikhil40.5
Harish31.2
Zeenat29.3

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT PName FROM PLAYER WHERE PName LIKE '%a';
PName
Nisha
Rachna

Explanation: WHERE keeps only the rows where PName matches the pattern '%a': 2 of the 6 rows match (Nisha, Rachna). '%a' means the value ends with 'a'.

(iii)
SELECT PName, Matches FROM PLAYER WHERE Matches <= 35;
PNameMatches
Nisha35
Meenal19
Harish24

Explanation: WHERE keeps only the rows where Matches is at most 35: 3 of the 6 rows match (Nisha, Meenal, Harish).

(iv)
SELECT SUM(Matches) FROM PLAYER WHERE Game = 'Cricket';
SUM(Matches)
105

Explanation: WHERE keeps only the rows where Game is 'Cricket': 3 of the 6 rows match (Nisha, Meenal, Nikhil). SUM adds the values of the matching rows.

(v)
SELECT LEFT(PName, 3) FROM PLAYER;
LEFT(PName, 3)
Nis
Rac
Mee
Nik
Har
Zee

Explanation: The function LEFT is worked out for every row that is shown.

E3.27Practice5 marks

Consider the table HOSTEL given below. Write SQL commands to:

  1. Add a new row with the values 7, 'Tanvi', 'Ganga', 165, 2324.76, '2026-12-15'
  2. Increase the Room by 10 for the rows where Block is 'Ganga'
  3. Delete the rows where Room is less than 111
  4. Add a new column Email of type VARCHAR(40)
  5. Remove the table HOSTEL from the database.

Table: HOSTEL

HNoSNameBlockRoomMessDOA
1ChetanYamuna1643027.922026-06-19
2RohanGanga1342314.262026-12-15
3SwatiKaveri2792306.822025-09-22
4HarishGanga2501867.612025-10-10
5NaveenYamuna1112282.332025-06-13
6AmanGanga1012423.742026-07-10
Answer
(i)
INSERT INTO HOSTEL VALUES (7, 'Tanvi', 'Ganga', 165, 2324.76, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE HOSTEL SET Room = Room + 10 WHERE Block = 'Ganga';

Rows affected: 3

Explanation: SET Room = Room + 10 changes the value; WHERE limits the change to the rows where Block is 'Ganga': 3 rows changed.

(iii)
DELETE FROM HOSTEL WHERE Room < 111;

Rows affected: 1

Explanation: WHERE picks the rows where Room is less than 111: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE HOSTEL ADD Email VARCHAR(40);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE HOSTEL;

Explanation: DROP removes the whole object with its data.

E3.28Practice5 marks

Consider the table HOSTEL given below. Write SQL queries to display:

  1. Each SName and its Mess rounded to the nearest whole number
  2. The rows where SName starts with the letter 'C'
  3. The SName and Room of the rows where Room is 134 or less
  4. The highest and the lowest Mess
  5. The SName in capital letters.

Table: HOSTEL

HNoSNameBlockRoomMessDOA
1ChetanYamuna1643027.922026-06-19
2RohanGanga1342314.262026-12-15
3SwatiKaveri2792306.822025-09-22
4HarishGanga2501867.612025-10-10
5NaveenYamuna1112282.332025-06-13
6AmanGanga1012423.742026-07-10
Answer
(i)
SELECT SName, ROUND(Mess) FROM HOSTEL;
SNameROUND(Mess)
Chetan3028
Rohan2314
Swati2307
Harish1868
Naveen2282
Aman2424

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM HOSTEL WHERE SName LIKE 'C%';
HNoSNameBlockRoomMessDOA
1ChetanYamuna1643027.922026-06-19

Explanation: WHERE keeps only the rows where SName matches the pattern 'C%': 1 of the 6 rows matches (Chetan). 'C%' means the value starts with 'C'.

(iii)
SELECT SName, Room FROM HOSTEL WHERE Room <= 134;
SNameRoom
Rohan134
Naveen111
Aman101

Explanation: WHERE keeps only the rows where Room is at most 134: 3 of the 6 rows match (Rohan, Naveen, Aman).

(iv)
SELECT MAX(Mess), MIN(Mess) FROM HOSTEL;
MAX(Mess)MIN(Mess)
3027.921867.61

Explanation: MAX gives the largest value of all the rows. MIN gives the smallest value.

(v)
SELECT UCASE(SName) FROM HOSTEL;
UCASE(SName)
CHETAN
ROHAN
SWATI
HARISH
NAVEEN
AMAN

Explanation: The function UCASE is worked out for every row that is shown.

E3.29Practice5 marks

Consider the table LOAN given below. Write SQL commands to:

  1. Add a new row with the values 7, 'Tanvi', 'Home', 20, 19.52, '2026-12-15'
  2. Increase the Years by 2 for the rows where Type is 'Home'
  3. Delete the rows where Years is less than 3
  4. Add a new column Grade of type CHAR(1)
  5. Remove the table LOAN from the database.

Table: LOAN

LNoCNameTypeYearsRateStartDate
1DivyaEducation1911.172020-11-18
2SachinHome39.022022-04-01
3NaveenCar129.462023-07-07
4SandeepCar29.922026-03-01
5UmeshHome1010.252021-02-05
6RituHome178.622025-08-06
Answer
(i)
INSERT INTO LOAN VALUES (7, 'Tanvi', 'Home', 20, 19.52, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE LOAN SET Years = Years + 2 WHERE Type = 'Home';

Rows affected: 3

Explanation: SET Years = Years + 2 changes the value; WHERE limits the change to the rows where Type is 'Home': 3 rows changed.

(iii)
DELETE FROM LOAN WHERE Years < 3;

Rows affected: 1

Explanation: WHERE picks the rows where Years is less than 3: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE LOAN ADD Grade CHAR(1);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE LOAN;

Explanation: DROP removes the whole object with its data.

E3.30Practice5 marks

Consider the table LOAN given below. Write SQL queries to display:

  1. Each CName and its Rate rounded to one decimal place
  2. The CName that end with the letter 'n'
  3. The CName and Years of the rows where Years is 10 or less
  4. The number of rows where Type is 'Education'
  5. Each CName and the number of characters in it.

Table: LOAN

LNoCNameTypeYearsRateStartDate
1DivyaEducation1911.172020-11-18
2SachinHome39.022022-04-01
3NaveenCar129.462023-07-07
4SandeepCar29.922026-03-01
5UmeshHome1010.252021-02-05
6RituHome178.622025-08-06
Answer
(i)
SELECT CName, ROUND(Rate, 1) FROM LOAN;
CNameROUND(Rate, 1)
Divya11.2
Sachin9.0
Naveen9.5
Sandeep9.9
Umesh10.3
Ritu8.6

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT CName FROM LOAN WHERE CName LIKE '%n';
CName
Sachin
Naveen

Explanation: WHERE keeps only the rows where CName matches the pattern '%n': 2 of the 6 rows match (Sachin, Naveen). '%n' means the value ends with 'n'.

(iii)
SELECT CName, Years FROM LOAN WHERE Years <= 10;
CNameYears
Sachin3
Sandeep2
Umesh10

Explanation: WHERE keeps only the rows where Years is at most 10: 3 of the 6 rows match (Sachin, Sandeep, Umesh).

(iv)
SELECT COUNT(*) FROM LOAN WHERE Type = 'Education';
COUNT(*)
1

Explanation: WHERE keeps only the rows where Type is 'Education': 1 of the 6 rows matches (Divya). COUNT(*) counts the rows of the matching rows.

(v)
SELECT CName, LENGTH(CName) FROM LOAN;
CNameLENGTH(CName)
Divya5
Sachin6
Naveen6
Sandeep7
Umesh5
Ritu4

Explanation: The function LENGTH is worked out for every row that is shown.

E3.31Practice5 marks

Consider the table STAFF given below. Write SQL commands to:

  1. Add a new row with the values 7, 'Vandana', 'PGT', 22, 5327.17, '2023-12-15'
  2. Increase the Periods by 100 for the rows where Post is 'PGT'
  3. Delete the rows where Periods is less than 21
  4. Add a new column City of type VARCHAR(20)
  5. Remove the table STAFF from the database.

Table: STAFF

SNoSNamePostPeriodsAllowanceDOJ
1RachnaTGT216326.052023-07-03
2MeenalPGT315316.672023-02-03
3SandeepPGT183601.572015-03-06
4YashPGT256358.032011-05-26
5RituPRT305793.032022-08-12
6FarhanTGT335942.382014-11-17
Answer
(i)
INSERT INTO STAFF VALUES (7, 'Vandana', 'PGT', 22, 5327.17, '2023-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE STAFF SET Periods = Periods + 100 WHERE Post = 'PGT';

Rows affected: 3

Explanation: SET Periods = Periods + 100 changes the value; WHERE limits the change to the rows where Post is 'PGT': 3 rows changed.

(iii)
DELETE FROM STAFF WHERE Periods < 21;

Rows affected: 1

Explanation: WHERE picks the rows where Periods is less than 21: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE STAFF ADD City VARCHAR(20);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE STAFF;

Explanation: DROP removes the whole object with its data.

E3.32Practice5 marks

Consider the table STAFF given below. Write SQL queries to display:

  1. Each SName and its Allowance rounded to the nearest whole number
  2. The rows where SName starts with the letter 'R'
  3. The SName and Periods of the rows where Periods is 25 or less
  4. The total Periods of the rows where Post is 'TGT'
  5. Each SName and the name of the month of DOJ.

Table: STAFF

SNoSNamePostPeriodsAllowanceDOJ
1RachnaTGT216326.052023-07-03
2MeenalPGT315316.672023-02-03
3SandeepPGT183601.572015-03-06
4YashPGT256358.032011-05-26
5RituPRT305793.032022-08-12
6FarhanTGT335942.382014-11-17
Answer
(i)
SELECT SName, ROUND(Allowance) FROM STAFF;
SNameROUND(Allowance)
Rachna6326
Meenal5317
Sandeep3602
Yash6358
Ritu5793
Farhan5942

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM STAFF WHERE SName LIKE 'R%';
SNoSNamePostPeriodsAllowanceDOJ
1RachnaTGT216326.052023-07-03
5RituPRT305793.032022-08-12

Explanation: WHERE keeps only the rows where SName matches the pattern 'R%': 2 of the 6 rows match (Rachna, Ritu). 'R%' means the value starts with 'R'.

(iii)
SELECT SName, Periods FROM STAFF WHERE Periods <= 25;
SNamePeriods
Rachna21
Sandeep18
Yash25

Explanation: WHERE keeps only the rows where Periods is at most 25: 3 of the 6 rows match (Rachna, Sandeep, Yash).

(iv)
SELECT SUM(Periods) FROM STAFF WHERE Post = 'TGT';
SUM(Periods)
54

Explanation: WHERE keeps only the rows where Post is 'TGT': 2 of the 6 rows match (Rachna, Farhan). SUM adds the values of the matching rows.

(v)
SELECT SName, MONTHNAME(DOJ) FROM STAFF;
SNameMONTHNAME(DOJ)
RachnaJuly
MeenalFebruary
SandeepMarch
YashMay
RituAugust
FarhanNovember

Explanation: The function MONTHNAME is worked out for every row that is shown.

E3.33Practice5 marks

Consider the table GARMENT given below. Write SQL commands to:

  1. Add a new row with the values 16, 'New Shirt', 'Silk', 16, 3046.13, '2026-12-15'
  2. Increase the Stock by 5 for the rows where Fabric is 'Silk'
  3. Delete the rows where Stock is less than 10
  4. Add a new column Remarks of type VARCHAR(30)
  5. Remove the table GARMENT from the database.

Table: GARMENT

GCodeGNameFabricStockPriceLaunch
10ShirtCotton151434.772025-06-21
11JeansSilk253035.632025-11-15
12KurtaDenim52149.332026-03-28
13JacketCotton101170.282025-10-06
14SareeDenim35787.832025-11-07
15FrockCotton451436.342025-09-11
Answer
(i)
INSERT INTO GARMENT VALUES (16, 'New Shirt', 'Silk', 16, 3046.13, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE GARMENT SET Stock = Stock + 5 WHERE Fabric = 'Silk';

Rows affected: 1

Explanation: SET Stock = Stock + 5 changes the value; WHERE limits the change to the rows where Fabric is 'Silk': 1 row changed.

(iii)
DELETE FROM GARMENT WHERE Stock < 10;

Rows affected: 1

Explanation: WHERE picks the rows where Stock is less than 10: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE GARMENT ADD Remarks VARCHAR(30);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE GARMENT;

Explanation: DROP removes the whole object with its data.

E3.34Practice5 marks

Consider the table GARMENT given below. Write SQL queries to display:

  1. Each GName and its Price rounded to one decimal place
  2. The GName that end with the letter 's'
  3. The GName and Stock of the rows where Stock is 15 or less
  4. The highest and the lowest Price
  5. Each GName and the name of the week day of Launch.

Table: GARMENT

GCodeGNameFabricStockPriceLaunch
10ShirtCotton151434.772025-06-21
11JeansSilk253035.632025-11-15
12KurtaDenim52149.332026-03-28
13JacketCotton101170.282025-10-06
14SareeDenim35787.832025-11-07
15FrockCotton451436.342025-09-11
Answer
(i)
SELECT GName, ROUND(Price, 1) FROM GARMENT;
GNameROUND(Price, 1)
Shirt1434.8
Jeans3035.6
Kurta2149.3
Jacket1170.3
Saree787.8
Frock1436.3

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT GName FROM GARMENT WHERE GName LIKE '%s';
GName
Jeans

Explanation: WHERE keeps only the rows where GName matches the pattern '%s': 1 of the 6 rows matches (Jeans). '%s' means the value ends with 's'.

(iii)
SELECT GName, Stock FROM GARMENT WHERE Stock <= 15;
GNameStock
Shirt15
Kurta5
Jacket10

Explanation: WHERE keeps only the rows where Stock is at most 15: 3 of the 6 rows match (Shirt, Kurta, Jacket).

(iv)
SELECT MAX(Price), MIN(Price) FROM GARMENT;
MAX(Price)MIN(Price)
3035.63787.83

Explanation: MAX gives the largest value of all the rows. MIN gives the smallest value.

(v)
SELECT GName, DAYNAME(Launch) FROM GARMENT;
GNameDAYNAME(Launch)
ShirtSaturday
JeansSaturday
KurtaSaturday
JacketMonday
SareeFriday
FrockThursday

Explanation: The function DAYNAME is worked out for every row that is shown.

E3.35Practice5 marks

Consider the table EVENT given below. Write SQL commands to:

  1. Add a new row with the values 7, 'New Debate', 'Raman', 31, 2935.24, '2026-12-15'
  2. Increase the Points by 10 for the rows where House is 'Raman'
  3. Delete the rows where Points is less than 55
  4. Add a new column Email of type VARCHAR(40)
  5. Remove the table EVENT from the database.

Table: EVENT

ENoENameHousePointsPrizeEDate
1DebateShivaji302874.632026-07-02
2QuizRaman1002924.742026-07-15
3DanceShivaji602767.112026-02-14
4DramaRaman552300.042026-12-19
5PaintingShivaji954017.092026-08-25
6SingingTagore751901.592026-10-04
Answer
(i)
INSERT INTO EVENT VALUES (7, 'New Debate', 'Raman', 31, 2935.24, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE EVENT SET Points = Points + 10 WHERE House = 'Raman';

Rows affected: 2

Explanation: SET Points = Points + 10 changes the value; WHERE limits the change to the rows where House is 'Raman': 2 rows changed.

(iii)
DELETE FROM EVENT WHERE Points < 55;

Rows affected: 1

Explanation: WHERE picks the rows where Points is less than 55: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE EVENT ADD Email VARCHAR(40);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE EVENT;

Explanation: DROP removes the whole object with its data.

E3.36Practice5 marks

Consider the table EVENT given below. Write SQL queries to display:

  1. Each EName and its Prize rounded to the nearest whole number
  2. The rows where EName starts with the letter 'D'
  3. The EName and Points of the rows where Points is 60 or less
  4. The number of rows where House is 'Shivaji'
  5. The last two characters of each EName.

Table: EVENT

ENoENameHousePointsPrizeEDate
1DebateShivaji302874.632026-07-02
2QuizRaman1002924.742026-07-15
3DanceShivaji602767.112026-02-14
4DramaRaman552300.042026-12-19
5PaintingShivaji954017.092026-08-25
6SingingTagore751901.592026-10-04
Answer
(i)
SELECT EName, ROUND(Prize) FROM EVENT;
ENameROUND(Prize)
Debate2875
Quiz2925
Dance2767
Drama2300
Painting4017
Singing1902

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM EVENT WHERE EName LIKE 'D%';
ENoENameHousePointsPrizeEDate
1DebateShivaji302874.632026-07-02
3DanceShivaji602767.112026-02-14
4DramaRaman552300.042026-12-19

Explanation: WHERE keeps only the rows where EName matches the pattern 'D%': 3 of the 6 rows match (Debate, Dance, Drama). 'D%' means the value starts with 'D'.

(iii)
SELECT EName, Points FROM EVENT WHERE Points <= 60;
ENamePoints
Debate30
Dance60
Drama55

Explanation: WHERE keeps only the rows where Points is at most 60: 3 of the 6 rows match (Debate, Dance, Drama).

(iv)
SELECT COUNT(*) FROM EVENT WHERE House = 'Shivaji';
COUNT(*)
3

Explanation: WHERE keeps only the rows where House is 'Shivaji': 3 of the 6 rows match (Debate, Dance, Painting). COUNT(*) counts the rows of the matching rows.

(v)
SELECT RIGHT(EName, 2) FROM EVENT;
RIGHT(EName, 2)
te
iz
ce
ma
ng
ng

Explanation: The function RIGHT is worked out for every row that is shown.

E3.37Practice5 marks

Consider the table TRAIN given below. Write SQL commands to:

  1. Add a new row with the values 12007, 'New Rajdhani', 'Southern', 18, 2135.59, '2024-12-15'
  2. Increase the Coaches by 2 for the rows where Zone is 'Southern'
  3. Delete the rows where Coaches is less than 13
  4. Add a new column Grade of type CHAR(1)
  5. Remove the table TRAIN from the database.

Table: TRAIN

TNoTNameZoneCoachesFareStartDate
12001RajdhaniNorthern172750.732017-02-22
12002ShatabdiSouthern242125.092024-03-03
12003DurontoNorthern132277.832024-03-16
12004Garib RathSouthern103012.732021-04-10
12005TejasWestern182091.892015-02-17
12006Vande BharatNorthern201399.692020-04-10
Answer
(i)
INSERT INTO TRAIN VALUES (12007, 'New Rajdhani', 'Southern', 18, 2135.59, '2024-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE TRAIN SET Coaches = Coaches + 2 WHERE Zone = 'Southern';

Rows affected: 2

Explanation: SET Coaches = Coaches + 2 changes the value; WHERE limits the change to the rows where Zone is 'Southern': 2 rows changed.

(iii)
DELETE FROM TRAIN WHERE Coaches < 13;

Rows affected: 1

Explanation: WHERE picks the rows where Coaches is less than 13: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE TRAIN ADD Grade CHAR(1);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE TRAIN;

Explanation: DROP removes the whole object with its data.

E3.38Practice5 marks

Consider the table TRAIN given below. Write SQL queries to display:

  1. Each TName and its Fare rounded to one decimal place
  2. The TName that end with the letter 'i'
  3. The TName and Coaches of the rows where Coaches is 17 or less
  4. The total Coaches of the rows where Zone is 'Northern'
  5. The first three characters of each TName.

Table: TRAIN

TNoTNameZoneCoachesFareStartDate
12001RajdhaniNorthern172750.732017-02-22
12002ShatabdiSouthern242125.092024-03-03
12003DurontoNorthern132277.832024-03-16
12004Garib RathSouthern103012.732021-04-10
12005TejasWestern182091.892015-02-17
12006Vande BharatNorthern201399.692020-04-10
Answer
(i)
SELECT TName, ROUND(Fare, 1) FROM TRAIN;
TNameROUND(Fare, 1)
Rajdhani2750.7
Shatabdi2125.1
Duronto2277.8
Garib Rath3012.7
Tejas2091.9
Vande Bharat1399.7

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT TName FROM TRAIN WHERE TName LIKE '%i';
TName
Rajdhani
Shatabdi

Explanation: WHERE keeps only the rows where TName matches the pattern '%i': 2 of the 6 rows match (Rajdhani, Shatabdi). '%i' means the value ends with 'i'.

(iii)
SELECT TName, Coaches FROM TRAIN WHERE Coaches <= 17;
TNameCoaches
Rajdhani17
Duronto13
Garib Rath10

Explanation: WHERE keeps only the rows where Coaches is at most 17: 3 of the 6 rows match (Rajdhani, Duronto, Garib Rath).

(iv)
SELECT SUM(Coaches) FROM TRAIN WHERE Zone = 'Northern';
SUM(Coaches)
50

Explanation: WHERE keeps only the rows where Zone is 'Northern': 3 of the 6 rows match (Rajdhani, Duronto, Vande Bharat). SUM adds the values of the matching rows.

(v)
SELECT LEFT(TName, 3) FROM TRAIN;
LEFT(TName, 3)
Raj
Sha
Dur
Gar
Tej
Van

Explanation: The function LEFT is worked out for every row that is shown.

E3.39Practice5 marks

Consider the table LAPTOP given below. Write SQL commands to:

  1. Add a new row with the values 7, 'New Astra', 'Zenit', 17, 84552.43, '2026-12-15'
  2. Increase the RAM by 100 for the rows where Brand is 'Zenit'
  3. Delete the rows where RAM is less than 12
  4. Add a new column City of type VARCHAR(20)
  5. Remove the table LAPTOP from the database.

Table: LAPTOP

LNoModelBrandRAMPriceLaunch
1Astra 5Orbit1686696.752026-11-10
2Bolt XZenit2884541.932025-10-22
3Comet ProZenit3284965.492026-03-21
4Dyna AirZenit2470706.772025-05-13
5Eon LiteOrbit1241551.162026-07-03
6Flex 14Nova442044.122026-11-12
Answer
(i)
INSERT INTO LAPTOP VALUES (7, 'New Astra', 'Zenit', 17, 84552.43, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE LAPTOP SET RAM = RAM + 100 WHERE Brand = 'Zenit';

Rows affected: 3

Explanation: SET RAM = RAM + 100 changes the value; WHERE limits the change to the rows where Brand is 'Zenit': 3 rows changed.

(iii)
DELETE FROM LAPTOP WHERE RAM < 12;

Rows affected: 1

Explanation: WHERE picks the rows where RAM is less than 12: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE LAPTOP ADD City VARCHAR(20);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE LAPTOP;

Explanation: DROP removes the whole object with its data.

E3.40Practice5 marks

Consider the table LAPTOP given below. Write SQL queries to display:

  1. Each Model and its Price rounded to the nearest whole number
  2. The rows where Model starts with the letter 'A'
  3. The Model and RAM of the rows where RAM is 16 or less
  4. The highest and the lowest Price
  5. The Model in capital letters.

Table: LAPTOP

LNoModelBrandRAMPriceLaunch
1Astra 5Orbit1686696.752026-11-10
2Bolt XZenit2884541.932025-10-22
3Comet ProZenit3284965.492026-03-21
4Dyna AirZenit2470706.772025-05-13
5Eon LiteOrbit1241551.162026-07-03
6Flex 14Nova442044.122026-11-12
Answer
(i)
SELECT Model, ROUND(Price) FROM LAPTOP;
ModelROUND(Price)
Astra 586697
Bolt X84542
Comet Pro84965
Dyna Air70707
Eon Lite41551
Flex 1442044

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM LAPTOP WHERE Model LIKE 'A%';
LNoModelBrandRAMPriceLaunch
1Astra 5Orbit1686696.752026-11-10

Explanation: WHERE keeps only the rows where Model matches the pattern 'A%': 1 of the 6 rows matches (Astra 5). 'A%' means the value starts with 'A'.

(iii)
SELECT Model, RAM FROM LAPTOP WHERE RAM <= 16;
ModelRAM
Astra 516
Eon Lite12
Flex 144

Explanation: WHERE keeps only the rows where RAM is at most 16: 3 of the 6 rows match (Astra 5, Eon Lite, Flex 14).

(iv)
SELECT MAX(Price), MIN(Price) FROM LAPTOP;
MAX(Price)MIN(Price)
86696.7541551.16

Explanation: MAX gives the largest value of all the rows. MIN gives the smallest value.

(v)
SELECT UCASE(Model) FROM LAPTOP;
UCASE(Model)
ASTRA 5
BOLT X
COMET PRO
DYNA AIR
EON LITE
FLEX 14

Explanation: The function UCASE is worked out for every row that is shown.

E3.41Practice5 marks

Consider the table CLUB given below. Write SQL commands to:

  1. Add a new row with the values 7, 'Suman', 'Swimming', 28, 2307.03, '2026-12-15'
  2. Increase the Age by 5 for the rows where Activity is 'Swimming'
  3. Delete the rows where Age is less than 17
  4. Add a new column Remarks of type VARCHAR(30)
  5. Remove the table CLUB from the database.

Table: CLUB

CNoMNameActivityAgeFeeDOJ
1FarhanTennis271058.822026-12-05
2BhavnaSwimming422296.532023-02-14
3LokeshYoga16805.042023-11-02
4SimranYoga361759.992026-03-27
5SachinTennis173396.682026-04-14
6MohitYoga561552.632023-06-09
Answer
(i)
INSERT INTO CLUB VALUES (7, 'Suman', 'Swimming', 28, 2307.03, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE CLUB SET Age = Age + 5 WHERE Activity = 'Swimming';

Rows affected: 1

Explanation: SET Age = Age + 5 changes the value; WHERE limits the change to the rows where Activity is 'Swimming': 1 row changed.

(iii)
DELETE FROM CLUB WHERE Age < 17;

Rows affected: 1

Explanation: WHERE picks the rows where Age is less than 17: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE CLUB ADD Remarks VARCHAR(30);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE CLUB;

Explanation: DROP removes the whole object with its data.

E3.42Practice5 marks

Consider the table CLUB given below. Write SQL queries to display:

  1. Each MName and its Fee rounded to one decimal place
  2. The MName that end with the letter 'a'
  3. The MName and Age of the rows where Age is 27 or less
  4. The number of rows where Activity is 'Tennis'
  5. Each MName and the number of characters in it.

Table: CLUB

CNoMNameActivityAgeFeeDOJ
1FarhanTennis271058.822026-12-05
2BhavnaSwimming422296.532023-02-14
3LokeshYoga16805.042023-11-02
4SimranYoga361759.992026-03-27
5SachinTennis173396.682026-04-14
6MohitYoga561552.632023-06-09
Answer
(i)
SELECT MName, ROUND(Fee, 1) FROM CLUB;
MNameROUND(Fee, 1)
Farhan1058.8
Bhavna2296.5
Lokesh805.0
Simran1760.0
Sachin3396.7
Mohit1552.6

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT MName FROM CLUB WHERE MName LIKE '%a';
MName
Bhavna

Explanation: WHERE keeps only the rows where MName matches the pattern '%a': 1 of the 6 rows matches (Bhavna). '%a' means the value ends with 'a'.

(iii)
SELECT MName, Age FROM CLUB WHERE Age <= 27;
MNameAge
Farhan27
Lokesh16
Sachin17

Explanation: WHERE keeps only the rows where Age is at most 27: 3 of the 6 rows match (Farhan, Lokesh, Sachin).

(iv)
SELECT COUNT(*) FROM CLUB WHERE Activity = 'Tennis';
COUNT(*)
2

Explanation: WHERE keeps only the rows where Activity is 'Tennis': 2 of the 6 rows match (Farhan, Sachin). COUNT(*) counts the rows of the matching rows.

(v)
SELECT MName, LENGTH(MName) FROM CLUB;
MNameLENGTH(MName)
Farhan6
Bhavna6
Lokesh6
Simran6
Sachin6
Mohit5

Explanation: The function LENGTH is worked out for every row that is shown.

E3.43Practice5 marks

Consider the table FARM given below. Write SQL commands to:

  1. Add a new row with the values 7, 'Simran', 'Wheat', 40, 50.66, '2026-12-15'
  2. Increase the Acres by 10 for the rows where Crop is 'Wheat'
  3. Delete the rows where Acres is less than 9
  4. Add a new column Email of type VARCHAR(40)
  5. Remove the table FARM from the database.

Table: FARM

FNoFarmerCropAcresYieldSowDate
1ArjunMaize3934.422026-12-19
2AnitaWheat940.162025-07-19
3IshaRice1124.932026-02-23
4SonalWheat1646.042025-06-25
5VandanaRice641.022026-10-11
6HarishWheat2323.822025-11-28
Answer
(i)
INSERT INTO FARM VALUES (7, 'Simran', 'Wheat', 40, 50.66, '2026-12-15');

Rows affected: 1

Explanation: INSERT adds a new row; values are given in the order of the columns, text and dates in quotes.

(ii)
UPDATE FARM SET Acres = Acres + 10 WHERE Crop = 'Wheat';

Rows affected: 3

Explanation: SET Acres = Acres + 10 changes the value; WHERE limits the change to the rows where Crop is 'Wheat': 3 rows changed.

(iii)
DELETE FROM FARM WHERE Acres < 9;

Rows affected: 1

Explanation: WHERE picks the rows where Acres is less than 9: 1 row is deleted; the table and the other rows remain.

(iv)
ALTER TABLE FARM ADD Email VARCHAR(40);

Explanation: ALTER TABLE changes the structure (columns or keys) of an existing table; the data stays.

(v)
DROP TABLE FARM;

Explanation: DROP removes the whole object with its data.

E3.44Practice5 marks

Consider the table FARM given below. Write SQL queries to display:

  1. Each Farmer and its Yield rounded to the nearest whole number
  2. The rows where Farmer starts with the letter 'A'
  3. The Farmer and Acres of the rows where Acres is 11 or less
  4. The total Acres of the rows where Crop is 'Maize'
  5. Each Farmer and the name of the month of SowDate.

Table: FARM

FNoFarmerCropAcresYieldSowDate
1ArjunMaize3934.422026-12-19
2AnitaWheat940.162025-07-19
3IshaRice1124.932026-02-23
4SonalWheat1646.042025-06-25
5VandanaRice641.022026-10-11
6HarishWheat2323.822025-11-28
Answer
(i)
SELECT Farmer, ROUND(Yield) FROM FARM;
FarmerROUND(Yield)
Arjun34
Anita40
Isha25
Sonal46
Vandana41
Harish24

Explanation: The function ROUND is worked out for every row that is shown.

(ii)
SELECT * FROM FARM WHERE Farmer LIKE 'A%';
FNoFarmerCropAcresYieldSowDate
1ArjunMaize3934.422026-12-19
2AnitaWheat940.162025-07-19

Explanation: WHERE keeps only the rows where Farmer matches the pattern 'A%': 2 of the 6 rows match (Arjun, Anita). 'A%' means the value starts with 'A'.

(iii)
SELECT Farmer, Acres FROM FARM WHERE Acres <= 11;
FarmerAcres
Anita9
Isha11
Vandana6

Explanation: WHERE keeps only the rows where Acres is at most 11: 3 of the 6 rows match (Anita, Isha, Vandana).

(iv)
SELECT SUM(Acres) FROM FARM WHERE Crop = 'Maize';
SUM(Acres)
39

Explanation: WHERE keeps only the rows where Crop is 'Maize': 1 of the 6 rows matches (Arjun). SUM adds the values of the matching rows.

(v)
SELECT Farmer, MONTHNAME(SowDate) FROM FARM;
FarmerMONTHNAME(SowDate)
ArjunDecember
AnitaJuly
IshaFebruary
SonalJune
VandanaOctober
HarishNovember

Explanation: The function MONTHNAME is worked out for every row that is shown.

11

Flashcards for one-mark questions

Tap an option to check your answer at once; your score is saved

Quick quiz: 10 MCQs

Ten multiple-choice questions picked at random. Tap an option to answer. You get your score at the end.

12

Practice question papers

Twenty ready papers with blueprints and a random paper maker, all on the design of the CBSE Sample Question Paper 2026-27

Twenty ready practice papers

Each paper has 37 questions for 70 marks in Sections A to E, with internal choices (OR) in Q22, Q25, Q28, Q30, Q32, Q34 and Q37, as in the CBSE Sample Question Paper 2026-27. Unit marks are kept as in the syllabus: Pandas and data visualization 25, SQL 25, Networks 10, Societal Impacts 10. Every paper opens with its chapter-wise blueprint. No question is repeated: the twenty papers use 880 different questions.

Or make a fresh random paper

Marking scheme, download and timer

Blueprint only:
03:00:00

Choose Paper 1 to Paper 20, or make a random paper. The blueprint and the paper open here.

13

Last-day checklist

Read this the evening before and again at the exam centre gate

Before the paper

  • Write once from memory: a Series program, a DataFrame program, a line chart program, and the five SQL commands.
  • Revise the device table, the four topologies and the six case-study rules.
  • Revise the Societal Impacts tables: footprint, IPR, FOSS, cyber crimes, e-waste.

In the first 15 minutes

  • Mark Q29 to Q37. These are your model-answer questions.
  • Where a question has OR, choose the part you know. Attempt only one.
  • Note the exact names of the Series, DataFrame, table and columns given.

While writing

  • Start with the case study and Societal Impacts, then SQL, then Pandas.
  • Write the import statement in every Pandas and Matplotlib program.
  • In output questions, write the output exactly, with labels and column headings.
Marks katne wali galti
  • Forgetting import pandas as pd or plt.show()
  • Mixing axis=0 (row) and axis=1 (column)
  • Using WHERE with an aggregate function in place of HAVING
  • Counting characters from 0 in MID() and INSTR()
  • Leaving a 4 or 5 mark question blank