0% found this document useful (0 votes)
4 views6 pages

July 12TH Key

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

July 12TH Key

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Army Public School, Chennai

PERIODIC TEST(JULY)-2025-2026

INFORMATICS PRACTICES (065)


CLASS XII SEC:A,B Max Marks: 35
Date: 26-07-2024 Time: 1 ½ Hours

I. Choose the Best Answer

1. (c) MID()
MID() is a synonym for SUBSTRING() in MySQL.
2. (a) LENGTH()
LENGTH() returns the length of a string in bytes in MySQL.
3. (a) ALTER
The ALTER command is used to change the structure of a table.
4. (a) 7876.46
ROUND(7876.4568, 2) rounds the number to 2 decimal places.
5. (a) 20500
SUM(DISTINCT Fees) sums only the unique values: 5000 + 8000 + 7500 = 20500

II. Answer ANY FOUR out of the given 5 questions

1. SQL Statement to count records in ORDERS:

SELECT COUNT(*) FROM ORDERS;

2. Python program to create Series using dictionary:

import pandas as pd
data = {"Krishna": 18, "Cauvery": 2, "Narmada": 20, "Ganga": 18}
s = pd.Series(data)
print(s)

3. Python program to create series of vowels:

import pandas as pd
vowels = pd.Series(['a', 'e', 'i', 'o', 'u'])
print(vowels)

4. Extract 4 characters from 5th right character of "ABCDEFG":


o String: 'ABCDEFG'
o 5th from right = position 3 (0-indexed) = 'C'
o From there: 'CDEF'

print('ABCDEFG'[-5: -1]) # Output: 'CDEF'

5. SQL Query to find remainder of 11 divide by 4:


SELECT 11 % 4;
-- Output: 3

III. Answer ANY THREE of the following

1. Justification for different outputs in COUNT queries:


o SELECT COUNT(*) → counts all rows → Output: 4
o SELECT COUNT(commission) → counts non-NULL values in commission
→ Output: 3
So, one of the rows has a NULL value in the commission field.
2. Corrected SQL query for highest Agg in each Stream:

SELECT Stream, MAX(Agg) FROM Employee GROUP BY Stream;

3. Output of SQL queries:


o (i) SELECT RIGHT('software', 2); → 're'
o (ii) SELECT INSTR('twelve', 'lV'); → 0
❗ Because 'lV' (lowercase l and uppercase V) is not found in 'twelve'
o (iii) SELECT DAYOFMONTH('2014-03-01'); → 1
4. Output of Python Programs:

A)

import numpy as num


import pandas as pd
arr = num.array([1, 7, 21])
S1 = pd.Series(arr)
print(S1)

Output:

0 1
1 7
2 21
dtype: int64

B)

import numpy as num


import pandas as pd
arr = num.array([1, 7, 21])
S1 = pd.Series(arr, index = (77, 777)) # Error: Length mismatch
print(S1)

❌ Output: Error

o The length of the index (2 values) does not match the array length (3 values).
It will raise a ValueError.
IV. Answer the following questions:
1. Write outputs for SQL queries (i) to (iii) which are based on the given table
PURCHASE: TABLE: PURCHASE

CNO CNAME CITY QUANTITY DOP


C01 GURPREET NEW DELHI 150 2022-06-11
C02 MALIKA HYDERABAD 10 2022-02-19
C03 NADAR DALHOUSIE 100 2021-12-04
C04 SAHIB CHANDIGARH 50 2021-10-10
C05 MEHAK CHANDIGARH 15 2021-10-20
i. SELECT LENGTH(CNAME) FROM PURCHASE WHERE QUANTITY>100;
ii. SELECT CNAME FROM PURCHASE WHERE MONTH(DOP)=3;
iii.SELECT MOD (QUANTITY, DAY(DOP)) FROM PURCHASE WHERE
CITY= ‘CHANDIGARH’;
iv. SELECT UCASE(CITY), YEAR(DOP) FROM PURCHASE WHERE
LENGTH(CNAME) < 6;
i.SELECT LENGTH(CNAME) FROM PURCHASE WHERE QUANTITY > 100;
Output:8
ii.
SELECT CNAME FROM PURCHASE WHERE MONTH(DOP) = 3;
Condition: MONTH of DOP = 3 (March)
→ No dates in March
Output:
(No rows)

iii.

SELECT MOD(QUANTITY, DAY(DOP)) FROM PURCHASE WHERE CITY =


'CHANDIGARH';

Matching Rows:

 C04 → QUANTITY = 50, DOP = 2021-10-10 → DAY = 10 → MOD(50,10) = 0


 C05 → QUANTITY = 15, DOP = 2021-10-20 → DAY = 20 → MOD(15,20) = 15

Output:

0
15

iv.

SELECT UCASE(CITY), YEAR(DOP) FROM PURCHASE WHERE LENGTH(CNAME)


< 6;
Condition: LENGTH(CNAME) < 6
→ C03: NADAR (5), C04: SAHIB (5), C05: MEHAK (5)
Corresponding CITY and YEAR:

CITY DOP

DALHOUSIE 2021-12-04
CHANDIGARH 2021-10-10
CHANDIGARH 2021-10-20

Output:

DALHOUSIE 2021
CHANDIGARH 2021
CHANDIGARH 2021

2. Consider a table “MYPET” with the following data.

Table: MYPET
Write SQL queries for the following:
i) Display the breed of all the pets in uppercase.
ii) Display the breed name along with the number of characters in it.
iii) Change the discount of the pet named 'Oscar' to 10%.
iv) Increase the price of all pets by 1000.
i) Display the breed of all the pets in uppercase:
SELECT UPPER(Breed) FROM MYPET;

ii) Display the breed name along with the number of characters in it:
SELECT Breed, LENGTH(Breed) AS Breed_Length FROM MYPET;

iii) Change the discount of the pet named 'Oscar' to 10%:


UPDATE MYPET SET Discount = 10 WHERE Pet_Name = 'Oscar';

iv) Increase the price of all pets by 1000:


UPDATE MYPET SET Price = Price + 1000;
V. Answer the following:
1. Consider the following tables ACTIVITY and COACH.Write the SQL commands for
the statements (i) to (iv) and give the output for (v)
(i)Display the name of all the activities with their Acodes in descending order.
(ii)Display sum of prizemoney for each of the number of participants groupings (as
shown in column ParticipantsNum 10,12,16).
(iii)Display the coach’s name and Acodes in ascending order of Acode.
(iv)Display the content of the Activity table whose ScheduleDate is earlier than
01/01/2004 in ascending order of ParticipantsNum.
(v) Select max(ScheduleDate),min(scheduleDate) from Activity;
(i) Display Activity names and Coach Names for those activities which are scheduled
after 01-Feb –2004.

SELECT ACTIVITY.ActivityName, COACH.Name, ACTIVITY.ScheduleDate

FROM ACTIVITY, COACH


WHERE ACTIVITY.ACode = COACH.ACode
AND ACTIVITY.ScheduleDate > '2004-02-01';

(ii) Display sum of prizemoney for each of the number of participants groupings
(ParticipantsNum = 10,12,16):

SELECT ParticipantsNum, SUM(PrizeMoney) AS TotalPrize FROM ACTIVITY GROUP BY


ParticipantsNum;

Expected Output:

ParticipantsNum TotalPrize
10 27000
12 17000
16 10000

(iii) Display the coach’s name and Acodes in ascending order of Acode:

SELECT Name, ACode FROM COACH ORDER BY ACode ASC;

Expected Output:
Name ACode
Ahmed Hussain 1001
Janila 1001
Naaz 1003
Ranvinder 1008

(iv) Display the content of the Activity table whose ScheduleDate is earlier than 01/01/2004 in
ascending order of ParticipantsNum:

SELECT * FROM ACTIVITY WHERE ScheduleDate < '2004-01-01' ORDER BY ParticipantsNum


ASC;

Matching Row:

ACode ActivityName ParticipantsNum PrizeMoney ScheduleDate


1002 High Jump 10 12000 12-Dec-2003

(v)

SELECT MAX(ScheduleDate), MIN(ScheduleDate) FROM ACTIVITY;

Expected Output:

MAX(ScheduleDate) MIN(ScheduleDate)
19-Mar-2004 01-Jan-2004

You might also like