GLOBAL INDIAN INTERNATIONAL SCHOOL
ANSWER KEY
GRADE: XII TA-1 (Set-I) SUBJECT: INFORMATICS PRACTICES 70 Marks
SECTION – A
[ 18 X 1 = 18 ]
Multiple Choice Questions
1. In a table named ‘Student’, if a column “Name” contains the data set (“Rashi”, “Shreyas”, “Nitya”, “Rashi”,
“Nitya”, “Nityam”, “Kavya”, “Rashi”), what will be the output after the execution of the given query?
SELECT COUNT(DISTINCT Name) FROM student;
(a) Error – cannot work on char data type (b) 5
(c) “Five” (d) No output
2. What will be the order of the data being sorted after the execution of given SQL query?
SELECT * From School Order by Class;
(a) Order of inserting records in a table (b) Ascending order
(c) Descending order (d) None of these
3. Consider a table named Employees with columns – EName, Age, Salary and Designation. Which SQL
statement do we use to find out the total salary given to employees?
(a) Select SUM(Salary) From Employees;
(b) Select COUNT (*) From Employees;
(c) Select FIND (*) From Employees;
(d) Select SUM () From Employees;
4. Which clause in SQL is used to apply a condition on a group?
(a) Where (b) Having
(c) As (d) On
5. In SQL, which of the following functions is used to display an average of a given number?
(a) Average() (b) Aver()
(c) Avg() (d) Avge()
6. The function to create a Series in Pandas is:
(a) Series[] (b) Series{ }
(c) Series() (d) .Series
7. The library used for data analysis in Python is:
(a) math (b) pandas
(c) Series (d) DataFrame
8. The cartesian product is also called ________ join
a. Equi Join b. Natural Join c. Unrestricted Join d. Restricted Join
9. By default, ORDER BY clause lists the result in ________ order.
a. Descending b. Any c. Same d. Ascending
10. What will be returned by the given query?
SELECT INSTR(“INDIA” , ”DI”);
a. 2 b. 3 c. -2 d. -3
11. Predict the output of the following query:
SELECT LCASE(MONTHNAME(‘2023-03-05’));
a. May b. March c. may d. march
12. What will be returned by the given query?
Select Round(153.669,2);
a. 153.6 b. 153.66 c.153.67 d. 153.7
13. What will be returned by the given query?
Select month(‘2020-05-11’);
a. 5 b. 11 c. May d. November
14. Predict the output for the following query.
Select MOD(9,0);
a. 0 b. NULL c. NaN d. 9
15. To display third element of a Series object S, you will write ________
a. S[:3] b. S[2] c.S[3] d. S[:2]
16. To display the first three elements of a Series object S, you may write ______
a. S[:3] b. S[3] c. S[3rd] d. all of these
17. Missing data in Pandas object is represented through:
a. Null b. None c. Missing d. NaN
18. What type of error is returned by the following statement?
import pandas as pd
pd.Series([1,2,3,4],index=[‘a’,’b’,’c’])
a. value error b. Syntax error c. Name error d. Logical error
SECTION – B
Answer the following Questions [ 7 X 2 = 14 ]
Str=”GIIS UPPAL”
19. Rewrite the following code using while loop: i=0
Str=”GIIS Uppal” while i<len(Str):
for i in str: print(Str)
print(Str) i=i+1
20. What will be the output of the following code:
import pandas as pd
Ser=pd.Series(data=[10,20,30,40,50]) 70
print(Ser[2]+Ser[3])
21. Predict the output for the following code.
Str=”GIIS Uppal” y= lappU SIIG
x=len(Str) x= 10
y=””
for i in str:
y=i+y
print(y) 0 6
print (x) 1 6
2 6
22. What will be the output of the following code? 3 6
import pandas as pd 4 6
s = pd.Series(6,index=range(0,5)) dtype: int64
print(s) 0 i
1 am
23. Write the output of the following code fragment. 2 a
import pandas as pd 3 student
s2=pd.Series(["i","am", "a","student"]) dtype: object
print(s2)
10 20
11 22
12 24
24. Write the output of the following code fragment. 13 26
import pandas as pd 14 28
import numpy as np dtype: int64
x=np.arange(10,15) 10 100
s3=pd.Series(index=x, data=x*2) 11 121
s4=pd.Series(x**2,x) 12 144
print(s3) 13 169
print(s4) 14 196
dtype: int64
25. State whether True or False a. F
A series object is size mutable.
A tuple object is immutable.
T
SECTION – C
Answer the following Questions [ 5 X 3 = 15 ]
26. Based on table EMP given here,write suitable SQL queries for the following:
Table:EMP
EmpNo EmpName City Designation DOJ Sal Comm
8369 Sunil Mumbai Clerk 1990-12-18 25000.00 NULL
8499 Aakash Varanasi SalesManager 1991-02-20 30000.00 3000.00
8521 Sarthak Jaipur SalesManager 1991-02-22 32000.00 5000.00
8566 Mohit Delhi Manager 1991-04-02 50000.00 NULL
a. Display the designation-wise list of employees with name,salary and date of joining.
Select empname,sal,doj from emp order by designation;
b. Show the minimum and maximum salary of managers.
Select min(sal),max(sal) from emp where designation=”Manager”;
c. Count the number of Sales managers in the organization.
Select count(empname) from emp where designation=”Sales Manager”;
27. What is the difference between Order by clause and Group by clause in SQL? Explain with an
example
The ORDER BY clause sorts the data in ascending or descending order. Whereas
the GROUP BY clause groups the tuples(rows) based on the similarities of columns.
Example:
select ename from emp order by ename; it will be display all employees name in
ascending manner
select count(ename) from emp group by dname; it will display total employee
present department wise.
28. Difference between append and extend function List. Explain with suitable example.
In Python, both append() and extend() are methods used to add elements to a list,
but they behave differently.
append()
Usage: Adds a single element to the end of a list.
Example:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list) # Output: [1, 2, 3, 4]
my_list.append([5, 6])
print(my_list) # Output: [1, 2, 3, 4, [5, 6]]
extend()
Usage: Takes an iterable (like a list) and adds each of its elements to the end of the
list.
Example:
my_list = [1, 2, 3]
my_list.extend([4, 5])
print(my_list) # Output: [1, 2, 3, 4, 5]
29. Write outputs for SQL queries (a) to (c) which are based on the given table TEACHER.
Table:TEACHER
ID Name Department Hiredate Category Gender Salary
1. TanyaNanda SocialStudies 2012-03-17 TGT F 32389.780
2. SaurabhSharma Art 2014-02-12 PRT M 26895.732
3. NanditaArora English 2012-05-16 PGT F 30578.876
4. JamesJacob English 2022-10-16 TGT M 25647.765
5. JaspreetKaur Hindi 2018-08-01 PRT F 21899.856
6. DishaSehgal Math 2022-03-17 PRT F 29876.890
7. SonaliMukherjee Math 2022-11-17 TGT F 36987.666
a. SELECT Right(Department,3) FROM TEACHER WHERE Category=’TGT’;
ies
-----
ish
----
ath
b. SELECT Name FROM TEACHER WHERE Year(Hiredate)=2022;
JamesJacob
----------------
DishaSehgal
-----------------
SonaliMukherjee
c. SELECT Round(Salary,2) FROM TEACHER WHERE Gender=’F’;
32389.78
30578.88
21899.86
29876.89
36987.67
30. Given the following Series1
Write the command to create above Series and then double the value in series and store in another
series named Series2
import pandas as pd
idx=['A','B','C','D','E']
val=[100,200,300,400,500]
series1=pd.Series(val,idx)
print(series1)
series2=series1*2
print(series2)
SECTION – D
Answer the following Questions [2X4=8]
31. Explain the following SQL functions using suitable examples:
(a) Now() => this function is used to display present/system date and time.
Example : Select now();
(b)Substr() =>this function is used to slice the part of the string from a main string.
(c)Length() => it is used to calculate length of a string.
(d)Mod() => the MOD() function is used to return the remainder of a division
operation.
32. Consider the following Series object, S
IP 95
Physics 89
Chemistry 92
Math 95
i. Write the Python syntax which will display only IP.
ii. Write the Python syntax to increase marks of all subjects by 10.
Code:
import pandas as pd
idx=['IP','Physics','Chemistry','Math']
val=[95,89,92,95]
s=pd.Series(val,idx)
print(s)
print(s.index[0])
s=s+10
print(s)
SECTION – E
Answer the following Questions [ 3 X 5 = 15 ]
33. Consider the Series object S1 that stores the contribution of each section, as shown below:
A 6700
B 8000
C 5400
D 3400
Write code to create the series and display those sections that made the contribution more than Rs.
5600/-
Code:
import pandas as pd
idx=['A','B','C','D']
val=[6700,8000,5400,3400]
s1=pd.Series(val,idx)
print(s1)
print(s1[s1>5600])
34 Table name: Sports / S.M.SportsAcademy
CoachID CoachName Game FeeCharged No_of_students Total_Amount
C101 NupurYadav Cricket 2000 50 100000
C102 VipinKumar Skates 2500 30 75000
C103 SoorajKapoor Taekwondo 3000 35 105000
C104 NareshBhatia Cricket 2500 70 175000
C105 PoojaGarg Badminton 3000 65 195000
a. Write a query to display Coach names in uppercase.
Select upper(coachname) from Sports;
b. Write a query to display the name of the coach who charged highest fees.
Select coachname from sports where feecharged=(select max(feecharged) from
sports);
c. Write a query to count total number of coaches for every game.
Select count(coachname),game from sports group by game;
d. Write a query to calculate total fees charged by cricket and badminton coaches
Select sum(total_amount) from sports where game in
(‘Cricket’,’Badminton’);
e. Write a query to calculate the total amount if no of students will increase 20% for each
coach.
Select (no_of_students+((no_of_students*20)/100))*feecharged as
“Total Amount New” from sports;
35. Number of students in class 11 and 12 in three streams( 'Science', 'Commerce' and 'Humanities') are stored
in two series objects c11 and c12. write code to find total number of students in class 11 and 12 , stream wise.
Code:
import pandas as pd
stream=['Science','Commerce','Humanities']
stu1=[40,42,52]
stu2=[50,35,60]
c11=pd.Series(stu1,stream)
c12=pd.Series(stu2,stream)
print("Total number of students")
print(c11+c12)