SQP 75 - QP
SQP 75 - QP
SQP 75 - QP
Page 2 of 8
a) a b) r c) w d) w+
15 If a function is defined by the line "defcalculate(p, q=100, r=10):", which of the 1
following istrue?
a) p is an optional parameter
b) q and r are optional parameters
c) q will always have value 100 in the function
d) the above line will cause a syntax error
16 Which of the following SQL statements is used to open a database named 1
“SCHOOL”?
a) CREATE DATABASE SCHOOL;
b) USE DATABASE SCHOOL;
c) USE SCHOOL;
d) SHOW DATABASE SCHOOL;
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(a) Both A and R are true, and R is the correct explanation for A
(b) Both A and R are true, and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17 Assertion (A): Python's pass statement is used for documentation purposes. 1
Reason (R): The pass statement does nothing and acts as a placeholder.
18 Assertion (A): In Python, a variable defined inside a function is local to that 1
function.
Reason (R): Local variables can be accessed outside the function they are
defined in.
SECTION-B
19 a=int{input("ENTER FIRST NUMBER")} 2
b=int(input("ENTER SECOND NUMBER"))
c=int(input("ENTER THIRD NUMBER"))
if a>b and a>c
print("A IS GREATER")
if b>a and b>c:
Print(" B IS GREATER")
if c>a and c>b:
print(C IS GREATER)
20 Differentiate between server side script and client side script. Write one example 2
of each.
Or
What are protocols? Name protocols for sending and receiving e-mail.
21 Differentiate between Alter and Update. 2
Or,
Differentiate between where and having
22 a) Given is a Python string declaration: 2
str="CBSE Examination@2024"
Write the output of: print(str[-1:-15:-2])
(b) Write the output of the code given below:
Page 3 of 8
d = {"name": "Akash", "age": 16}
d['age'] = 27
d['city'] = "New Delhi"
print(d.items())
23 Write the output of the following code: 2
a=20
def calling(x):
global a
if a%3!=0:
x+=a
else :
x-=a
return(x)
print (calling(45),end="&&")
print (calling(35),end="@@")
24 Write a suitable Python statement for each of the following tasksusing built-in 2
functions/methods only:
a) To delete an element Mumbai:50 from Dictionary D.
b) To display words in a string S in the form of a list
OR
Write a Python Program to display alternate characters of a stringmy_str.
For example, if my_str = "Computer Science"
The output should be Cmuecec
25 Write a Python Program containing a function FindWord(STRING,SEARCH), 2
that accepts two arguments : STRING and SEARCH, andprints the count of
occurrence of SEARCH in STRING. Writeappropriate statements to call the
function.
For example, if STRING = "Learning history helps to know abouthistory with
interest in history" and SEARCH = 'history', the functionshould display
The word history occurs 3 times.
SECTION-C
26 a) Differentiate between Natural join and Equi join. 1+
b) Table : Employee 2
EmployeeId Name Sales JobId
E1 SumitSinha 110000 102
E2 Vijay SinghTomar 130000 101
E3 Ajay Rajpal 140000 103
E4 Mohit Kumar 125000 102
E5 Sailja Singh 145000 103
Table: Job
JobId JobTitle Salary
101 President 200000
102 Vice President 125000
103 Administrator Assistant 80000
104 Accounting Manager 70000
105 Accountant 65000
Page 4 of 8
106 Sales Manager 80000
Give the output of following SQL statement:
(i) Select Name, JobTitle, Sales from Employee, Job
where Employee.JobId=Job.JobId and JobId in (101,102)
(ii) Select JobId, count(*) from Employee group by JobId
27 Write a function in python named SwapHalfList(Array), which accepts a list 3
Array of numbers and swaps the elements of 1st Half of the list with the 2nd
Half of the list, ONLY if the sum of 1st Half is greater than 2nd Half of the list.
Sample Input Data of the list
Array= [ 100, 200, 300, 40, 50, 60],
Output Array = [40, 50, 60, 100, 200, 300]
28 Write a function ETCount() in Python, which should read eachcharacter of a text 3
file “TESTFILE.TXT” and then count and displaythe count of occurrence of
alphabets E and T individually (includingsmall cases e and t too).
Or,
Write a method/function DISPLAYWORDS() in python to read lines from a text
file POEM.TXT, and display those words, which are less than 4 characters.
29 Tulasi creates a table RESULT with a set of records to maintain themarks 3
secured by students in Term1, Term2, and their divisions.After the creation of
the table, he entered data of 7 students in thetable.
ADNO ROLLNO SNAME TERM1 TERM2 DIVISION
123 101 KARAN 366 410 I
245 102 NAMAN 300 350 I
128 103 ISHA 400 410 I
129 104 RENU 350 357 I
234 105 ARPIT 100 75 IV
187 106 SABINA 100 205 II
181 107 NEELAM 470 450 I
Based on the data given above answer the following questions:
a) Identify the columns which can be considered as candidate keys?
b) If one more columns are added and 3 rows are deleted from the table
result, what will be the new degree and cardinality of the above table?
c) Write a statement to increase the TERM2 marks by 3% for the students
securing marks between 70 to 100.
30 A nested list contains the data of visitors in a museum. Each of the inner 3
listscontainsthe following data of a visitor:
[V_no (int), Date (string), Name (string), Gender (String M/F), Age (int)]
Write the following user defined functions to perform given operations on the
stacknamed "status":
(i) Push_element(Visitors) - To Push an object containing Gender of visitor who
are in the age range of 15 to 20.
(ii) Pop_element() - To Pop the objects from the stack and count the display the
number of Male and Female entries in the stack. Also, display “Done” whenthere
are no elements in the stack.
For example: If the list Visitors contains:
[['305', "10/11/2022", “Geeta”,"F”, 35],
Page 5 of 8
['306', "10/11/2022", “Arham”,"M”, 15],
['307', "11/11/2022", “David”,"M”, 18],
['308', "11/11/2022", “Madhuri”,"F”, 17],
['309', "11/11/2022", “Sikandar”,"M”, 13]]
The stack should contain
F
M
M
The output should be:
Done
Female: 1
Male: 2
SECTION-D
31 A csv file “Book.csv” has structure [BookNo, Book_Name, Author, Price]. 2+
a. Write a user defined function CreateFile() to input data for a record and add to 2
Book.csv .
b. Write a function CountRec(Author) in Python which accepts the Author name
as parameter and count and return number of books by the given Author are
stored in the file “Book.csv”
32 Write SQL queries for (a) to (d)on the basis of tables given below 4
Table : TRAINS
TNO TNAME START END
11096 Ahimsa Express Pune Junction Ahmedabad Junction
12015 Ajmer Shatabdi New Delhi Ajmer Junction
1651 Pune Hbj Special Pune Junction Habibganj
13005 Amritsar Mail Howrah Junction Amritsar Junction
12030 SwarnaShatabdi Amritsar Junction New Delhi
Table : PASSENGERS
PNR TNO PNAME GENDER AGE TRAVELDATE
P001 13005 R N AGRAWAL MALE 45 2018-12-25
P002 12015 P TIWARY MALE 28 2018-11-10
P003 12015 S TIWARY FEMALE 22 2018-11-10
P004 12030 S K SAXENA MALE 42 2018-10-12
P005 12030 S SAXENA FEMALE 35 2018-10-12
Page 7 of 8
35 a) What is the difference between a Candidate Key and an Alternate Key. 1+
b) Manoj has created a table named TRAVELS in MySQL: 4
Tour_ID – string
Destination – String
Geo_Cond– String
Distance – integer (In KM)
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is kvs
The table TRAVELS exists in a MYSQL database named TOUR.
The details Tour_ID, Destination, Geo_Cond and Distance are to be accepted
from the user.
Manoj wants to display All Records of TRAVELS relation whose Geographical
condition is hilly area and distance less than 1000 KM. Help Manoj to write
program in python.
Or,
(i) Write one point of difference between PRIMARY KEY and UNIQUE KEY
in SQL.
(ii) Aarya has created a table named Emp in MySQL:
EmpNo – integer
EmpName – string
Age– integer
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username - root
Password - kvs
Host - localhost
The Emp table exists in a MYSQL database named company.
The details of Emp table (EmpNo, EmpName, Age and Salary)
Aarya wants to display All Records of Emp relation whose age is greater than
55. Help Aarya to write program in python.
Page 8 of 8