12TH IP SET A
12TH IP SET A
Page 1 of 7
13. Which statement will give answer 2035.3.
a) select year(curdate())+truncate(12.345,1);
b) select year(curdate())+truncate(12.345,2);
c)select year(curdate())+truncate(12.345,-1);
d) select year(curdate())+truncate(12.345);
14. _____ Keyword eliminates duplicate values from query result.
a) unique b)distinct c)only d)primary
15. Answer of the following command is :
year(curdate())+round(12.345,-2) |
a)2023 b)2123 c)2023.34 d)None
16. Select the mysql statement that will not produces the following output:
chapter 6
MY WORlD |
+----------+
| 15 |
+----------+
a) select length(trim(leading '$' from '$$$$my little world')) "MY WORlD";
b) select length(trim(leading '$' from '$$$$my little world')) ;
c) select length(trim(leading '$$$$' from '$$$$my little world')) "MY WORlD";
d) All of these
17. Assertion (A):-To create series from array, we have to import the numpy module and
then use array method.
Reasoning (R): - Numpy is numerical python library. Numpy contains a single
and multidimensional array.
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
18. Assertion (A):- The ORDER BY clause of SELECT statement is carried out in the last after
execution of other clauses of select command.
Reasoning (R):- ORDER BY clause is carried out on the final result of the select
query.
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
SECTION B 7X2=14M
19. Explain any two features of pandas..
OR
Differentiate between loc() and iloc() functions.
20. Explain bar() function in detail with its arguments.
21. Explain alter table and update commands.
22. Write difference between having and where in select command.
23. Write code to create csv file “MYFILE.CSV from given dataframe DF. Make sure null values
are handled properly.
Page 2 of 7
24 Consider table product with the following structure
(pno, pname, price)
programmer has to make table in such a way that all columns must contain value.
But when he is entering null in any column it is getting accepted. Tell him what mistake he
has done and also give him solution so that null cannot be entered
25. Consider table given below
Empl(eno,ename,job,sal,comm,hiredate,deptno)
write query to show avg salary of each department that has max salary >3000 .
SECTION C (5 X 3 = 15M)
26. Write a Python code to create a S e r i e s “ T e r m 1 ” a n d “ T e r m 2 ” t o s t o r e m a r k s o f
Term exams for 5 students (marks out of 500). Calculate percentage of
each term.
OR
Consider the given Data Frame ‘Exam’:
solve questions given below:
Name UT1 UT2
0 Nancy Drew 15 18
1 Hardy boys 18 22
2 Diary of a wimpy kid 22 11
3 Harry Potter 21 23
Write command for b and c
a) Write output of the command:
Exam.shape
b) Add column TOTAL to show total of UT1 and UT2.
c) Drop column UT2.
27. Write output of the following program
import pandas as pd
data={'first':pd.Series(['abc','xyz','pqr'],index=[11,12,13]),
'second':pd.Series(['The','That','This','ok'],index=[11,12,13,14])}
value=pd.DataFrame(data)
print(value)
28. Based on the SQL table CAR_SALES, write suitable queries for the following:
+ + + + + +
| NUMBER | SEGMENT | FUEL | QT1 | QT2 |
+ + + + + +
| 1 | Compact HatchBack | Petrol | 56000 | 70000 |
| 2 | Compact HatchBack | Diesel | 34000 | 40000 |
| 3 | MUV | Petrol | 33000 | 35000 |
| 4 | MUV | Diesel | 14000 | 15000 |
| 5 | SUV | Petrol | 27000 | 54000 |
| 6 | SUV | Diesel | 18000 | 30000 |
| 7 | Sedan | Petrol | 8000 | 10000 |
| 8 | Sedan | Diesel | 1000 | 5000 |
+ + + + + +
(a)Display petrol segment cars having QT1 between 50000 to 60000
(b)Delete row of Number 8
Page 3 of 7
(c) Display total quantity with heading “Total Quantity” with segment name of all the cars.
29. Explain the following functions with examples:
a) round()
b) sign()
c) power()
OR
Write Output of the following based on the table CAR_SALES given in Q.28
a) select substring(segment,2,3) from CAR_SALES where segment like ‘Compact%’;
b) select upper(right(segment,3)) from CAR_SALES where QT2<50000;
c)select instr(segment,”Com”)+mod(QT1,4) from CAR_SALES where QT1<30000;
30. Based on the SQL table CAR_SALES, write suitable queries for the following:
+ + + + + +
| NUMBER | SEGMENT | FUEL | QT1 | QT2 |
+ + + + + +
| 1 | Compact HatchBack | Petrol | 56000 | 70000 |
| 2 | Compact HatchBack | Diesel | 34000 | 40000 |
| 3 | MUV | Petrol | 33000 | 35000 |
| 4 | MUV | Diesel | 14000 | 15000 |
| 5 | SUV | Petrol | 27000 | 54000 |
| 6 | SUV | Diesel | 18000 | 30000 |
| 7 | Sedan | Petrol | 8000 | 10000 |
| 8 | Sedan | Diesel | 1000 | 5000 |
+ + + + + +
Write Output
a) select count(distinct FUEL) from CAR_SALES;
b) Select max(QT1) from CAR_SALES group by SEGMENT
c) Show QT2 of all cars in descending order.
Write Output
a) df.index
b) df.dtypes
c) Add new column last_school- [‘kids nursery’,’Daisy nursery’, NaN]
d) show Gender of index 3.
OR
Predict the output of the following statement
a)df.loc[:, ‘Sname’]
Page 4 of 7
b)df.at[3,’Std’]
c)df[[‘Sname’,’Section’]]
d)df.loc[2]
SECTION E (5 X 3 = 15M)
33. Write commands for the following questions
a) Write statement to calculate your age.
b) Display day name of your date of birth
c) show square root of 121.
Write output
d) select mod(truncate(13.9675432,3),2);
e) select left(“Country”),right(“Manager”);
34. Rajesh is new to python and he wants to show data in cumulative histogram with 4 bins in
it. Help him write program for the same.
Data
Marks1=[200,450,300,400,420]
Marks2=[250,300,430,234,500]
OR
Complete the following graph
Page 5 of 7
35. a) write commands for the following questions based on the Series given below:
Series:s1
a 97
b 98
c 99
d 100
e 101
a) Set NaN to index ‘c’
b) Create copy of s1
c) Check datatype of s1 series.
d) Divide all values of s2 by 2
e) Show values more than 95.
Page 6 of 7
Page 7 of 7