SECOND HALF PORTION - Q WITH ANS ds__ dbms and sql 22.10.24
SECOND HALF PORTION - Q WITH ANS ds__ dbms and sql 22.10.24
General Instructions:
● This question paper contains 37 questions.
● All questions are compulsory. However, internal choices have been
provided in some questions. Attempt only one of the choices in such
questions
● The paper is divided into 5 Sections- A, B, C, D and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of the correct answer should also be written.
2. 3. While popping the element from the stack, a condition will be raised, this condition is known
as ___UNDERFLOW_________.
a) Underflow b) Overflow c) List is Empty d) Blank List
4. Which of the following is not a compound data structure?
(1)
a) Stack
b) Queue
c) Array
d) Tree
3. 5. Inspecting the value at the stack’s top without removing it.
a) peak operation
b) insert operation (1)
c) pop operation
d) push operation
6. Which of the following statement is incorrect for stack?
a) Peek <stack>[top]
b) Push <stack>.append(<item>)
c) Pop <stack>.pop()
d) Plus <stack>plus()
1. ______ is a communication methodology designed to deliver both voice and multimedia
4. communications over Internet protocol.
(A) SMTP (B) VoIP (C) PPP (D) HTTPPage: 1/12 (1)
2. Which of the following is used to receive emails over Internet?
a) SMTP b) POP
3. What is the size of IPv4 address?
5. (a)32 bits (b) 64 bits (c) 64 bytes (d) 32 bytes
4. _________protocol provides access to command line interface on a remote computer. (1)
a)FTP b)Telnet c)VoIP d)SMTP
5. ______is a communication methodology designed to deliver electronic mail (E-mail) over
6. the internet.
. (a) VoIP (b) HTTP (c) PPP (d) SMTP (1)
6. Which protocol is used for transferring files over a TCP/IP network?
a) FTP b) SMTP c) PPP d) HTTP
7. Network in which every computer is capable of playing the role of a client, or a server or
7. both at same time (1)
is called
a) local area network b) peer-to-peer network c) dedicated server network d) wide
area network
8. ........................is a communication methodology designed to establish a direct and
dedicated communication between an internet user and his/her ISP.
a) VoIP (b) SMTP (c) PPP (d)HTTP
Identify the device on the network which is responsible for forwarding data from one
8. device to another (1)
(a) NIC (b) Router (c) RJ45 (d) Repeater
10. Which of the following device send data to every connected node?
a)Switch b)Repeater c)Router d) Hub
11. In which type of switching first the connection is established between sender
9. and receiver and then the data is transferred?
a) Circuit b)Message c)Packet d)None
12. Identify the cable which consists of an inner copper core and a second (1)
conducting outer sheath:
(i)Twisted Pair (ii) Co-axial (iii) Fiber Optical (iv) Shielded Twisted Pair
An attribute in a table is foreign key if it is the _________key in any other table.
10. a) Candidate b) Primary c) Unique d) Alternate (1)
2. What is the domain of an attribute?
(a) The set of possible values that the attribute can take
(b) The name of the attribute
(c) The data type of the attribute
(d) None of the above
Which of the following is not a database constraint?
11. a. CHECK b. DEFAULT c. UNIQUE d. NULL
4. The data types CHAR (n) and VARCHAR (n) are used to create _______ and (1)
_______ types of string/text fields respectively in a database.
a) Fixed, equal b) Equal, variable c) Fixed, variable d) Variable, equal
Q. No. 12 t& 13 are ASSERTION ( A ) and REASONING ( R ) 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 correct explanation for A.
c. A is true but R is false.
d. A is false but R is true
Assertion (A): A foreign key in the relational data model is a set of attributes in
12. one
relation that references the primary key of another relation. (1)
Reason (R): Foreign keys are used to establish relationships between tables.
Page: 2/12
ANs : A
18. Assertion(A): DBMS is an application package which arranges the data in orderly
manner in a tabular form.
Reason(R): It is an interface between database and the user. It allows the users to
access and perform various operations on stored data using some tools
Ans :A
Assertion(A): Aggregate function AVG() calculates the average of a set of values
13. and produces a single value as result. (1)
Reason(R): The aggregate functions are used to perform some basic calculations
like sum, max, min, etc on a set of numbers.
Ans : b
20. Assertion(A): While inserting records in EMP table, value of DateOfBirth field
must be enclosed withing quotes ‘ ‘.
Reasoning(R): Date is represented as char / varchar always.
Ans : C
15. MySQL statement to delete a table STUDENT from the database SCHOOL is
14. DELETE TABLE STUDENT; ( True / False) (1)
16. Where and Having clauses can be used interchangeably in SQL queries ( True / False)
Which SQL statement is used to display all the data from ITEMS table where
15. INAME is ending with ‘L’?
a. SELECT * FROM ITEMS WHERE INAME LIKE ‘L%’;
b. SELECT * FROM ITEMS WHERE INAME LIKE ‘%L’; (1)
c. SELECT * FROM ITEMS WHERE INAME LIKE ‘%L%’;
d. SELECT * FROM ITEMS WHERE INAME LIKE ‘_L_’;
14. Which join combines each row from the first table with every row from the
second table to make the result set?
a. CROSS JOIN b. OUTER JOIN c. INNER JOIN d. EQUI JOIN
1. To establish a connection with MySQL from Python which of the following functions is
16. used?
(a) connection()
(b) connect() (1)
(c) open()
(d) cursor()
2. execute() method can execute ________ .
(a) DDL statements
(b) DML statements
(c) DDL and DML statements.
(d) Select statement only
3. To establish a connection between Python and sql database, connect() is used. Which of
17. the (1)
following arguments may not necessarily be given while calling connect()?
(a) host
(b) database
(c) user
(d) password
4. What is the purpose of the `rowcount` attribute in Python-Mysql database connectivity?
(a) Number of rows affected by the last executed command
(b) Total number of rows in the database
(c) Total number of columns in the database
Page: 3/12
(d) Number of tables in the database
5. Which method is used to retrieve N number of records
18. (a) fetchone() (1)
(b) fetchall()
(c) fetchmany()
(d) fetchN()
6. To make the changes made by any SQL Queries permanently in database, which function
is used
after execution of the query?
(a) save()
(b) commit()
(c) execute()
(d) dump()
10. Which of the following is not a valid method to fetch records from database in python.
(a) fetchmany()
(b) fetchone()
(c) fetchmulti()
(d) fetchall()
11. Which attribute of cursor is used to get number of records stored in cursor (Assumeg
21. cursor (1)
name is mycursor)?
(a) mycursor.count
(b) mycursor.row_count
(c) mycursor.records
(d) mycursor.rowcount
12. Which of the following package must be imported in Python to create a database
connectivity
application?
(a) mysql.connector
(b) mysql.connect
(c) sql.connector
(d) sql.execute
Q No Section-B ( 7 x 2=14 Marks) Marks
(2)
22.
Page: 4/12
1. What are the underflow and overflow conditions?
ANS :
Underflow is the condition which occurs when stack is empty while trying to delete elements.
Overflow is the condition which occurs while inserting an element when memory is exhausted
4. Write the python script to read the whole data from the table emp and display all the (2)
23. records.
Ans: import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="sch
ool")
print (mydb)
mycursor=mydb.cursor()
numrow=mycursor.execute("select * from student")
print(mycursor.fetchall())
mydb.close()
5. Write the main difference among fetchone(),fetchmany() and fetchall().
24. Ans: fetchone() fetches a single record or row from the resultset. (2)
fetchmany () method returns blocks of results according to a set limit. It will fetch n records
at a
time from the table.
fetchall() fetches all the records or rows at a time from the table.
Ans:
a) Degree - no. of attributes in a table, Cardinality – no. of records in a table.
b) Degree – 4, cardinality – 6
Ans:
27.DML - INSERT, UPDATE
DDL - ALTER, DROP
28. A MySQL table, sales have 10 rows. The following queries were executed on
the sales table.
SELECT COUNT(*) FROM sales;
COUNT(*)
10
SELECT COUNT(discount) FROM sales;
COUNT(discount)
6
Write a statement to explain as to why there is a difference in both the counts
Ans :
28. Count(*) will return the number of records in the table sales. Count(discount) will
return the number of records having not null values in the discount field of sales
table.
Write two points of difference between Bus topology and star topology. (2)
28.
Q Marks
No.
Section-C ( 3 x 3 = 9 Marks)
Consider a list named Nums which contains random integers.
29. Write the following user defined functions in Python and perform the specified (3)
operations on a stack named BigNums.
(i) PushBig(): It checks every number from the list Nums and pushes all
such numbers which have 5 or more digits into the stack, BigNums.
(ii) PopBig(): It pops the numbers from the stack, BigNums and displays
them. The function should also display “Stack Empty” when there are
no more numbers left in the stack.
For example: If the list Nums contains the following data:
Nums=[213, 10025, 167, 254923, 14, 1297653, 31498, 386, 92765]
Then on execution of PushBig(),the stack BigNums should store:
[10025, 254923, 1297653, 31498, 92765]
And on execution of PopBig(), the following output should be displayed:
92765
31498
Page: 6/12
1297653
254923
10025
Stack Empty
ANS
def PushBig(Nums,BigNums):
for N in Nums:
if len(str(N))>=5:
BigNums.append(N)
def PopBig(BigNums):
while BigNums:
print(BigNums.pop())
else:
print(“Stack Empty”)
Write output of the SQL queries based on the following table Employee: (3)
30. (i) select name, project from employee order by project;
(ii) select name, salary from employee where doj like '2015%';
(iii) select min(doj), max(dob) from employee
Ans:
DOJ DOB
31. (3)
Q Section-D ( 4 x 4 = 16 Marks) Marks
No.
1. The code given below inserts following record in to a table EMPLOYEE
32. EMPNO – Integer (4)
ENAME – string
SALARY - Integer
BONUS - Integer
DEPTID – string
Help your friend Sonia in writing the following missing statements to complete the code:-
import ______________ # Statement1
mydb=mysql.connector.connect(host="localhost",user="root",passwd='root',database="class12
")
mycursor= _____________ # Statement 2
mycursor.execute("INSERT INTO EMPLOYEE VALUES(114,'BP Singh',56400,800,'D01')")
___________________ # Statement 3
print(mycursor.rowcount, "Record inserted")
___________________ # Statement 4
Ans:
Statement 1: mysql.connector
Statement 2: mydb.cursor()
Page: 7/12
Statement 3: mydb.commit()
Statement 4: mydb.close()
2. Avni is trying to connect Python with MySQL for her project. Help her to write the python
statement on the following:
i. Name the library, which should be imported to connect MySQL with Python.
ii. Name the function, used to run SQL query in Python.
iii. Name the function required to make the changes permanent.
iv. Name the fuction to clear the environment.
Ans:
i. mysql.connector
ii. execute()
iii. commit()
iv. close()
(a) A list contains the following record of customer: (4)
33. [Customer_name, Room Type]
Write the following user-defined functions to perform given operations on the stack
named ' Hotel':
i) Push_Cust () - To Push customers names of those customers who are staying in
Delux' Room Type.
ii) Pop_Cust ()- To Pop the names of customers from the stack and display them.
Also, display "Underflow" when there are no customers in the stack.
For example: If the lists with customer details are as follows:
["siddarth", "Delux"] ["Rahul", "Standard"] ["Jerry", "Delux"]
The stack should contain
Jerry
Siddharth
The output should be:
Jerry
Siddharth
Underflow
b) Write a function in Python, Push (Vehicle) where, Vehicle is a dictionary
containing details of vehicles - {Car_Name: Maker}.
The function should push the name of car manufactured by "TATA' (including all
the possible cases like Tata, TaTa, etc.) to the stack.
For example:
If the dictionary contains the following data:
Vehicle={"Santro" : "Hyundai", "Nexon": "TATA", "Safari" : "Tata"}
The stack should contain
Safari
Nexon
ANS
a)
customer=[["Siddarth", "Delux"], ["Rahul", "Standard"], ["Jerry", "Delux"]]
hotel=[]
def push_cust():
for i in customer:
if i[1]=='Delux':
hotel.append(i[0])
return hotel
def pop_cust():
if hotel==[]:
return "Underflow"
else:
Page: 8/12
return hotel.pop()
push_cust()
while True:
if hotel==[]:
print(pop_cust())
break
else:
print(pop_cust())
ANS :
i. WHERE clause allows to filter data from individual rows of a table based on
certain conditions. In contrast, the HAVING clause allows to filter data from a
group of rows in a query based on conditions involving aggregate functions.
ii.
a)
SEX AVG(SALARY)
M 68666
F 65000
b)
SUBJECT COUNT(*)
Computer Science 2
c)
SUBJECT MIN(SALARY)
Computer Science 75000
English 55000
Economics 71000
Page: 9/12
35. Aryan Infotech Solutions has set up its new center at Kamla Nagar for its office and web
based activities. The company compound has 4 buildings as shown in the diagram below:
(4)
Sol: i)
(i) Suggest the most appropriate block/location to house the SERVER in the Surajpur
center (out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
(ii) Suggest why should a firewall be installed at the Surajpur Center?
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to
most efficiently connect various blocks within the Surajpur Center.
(iv) Suggest the placement of the following devices with appropriate reasons:
a) Switch/Hub b) Router
(v) Suggest the best possible way to provide wireless connectivity between Surajpur Center
and Raipur Center.
iii)
iv) a) Switch/Hub – In every block to interconnect the devices within every block
b) Router -In development block because server is going to be placed here
Page: 11/12
v) Satellite
3. Write the python function to accept the name as parameter and find out whether record
present
in the table or not. Table Student columns are rollno, name, age.
Ans: import mysql.connector
def check_name(name):
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",
database="school")
cur=mydb.cursor()
cur.execute("select * from student")
s=cur.fetchall()
for k in s:
if((k[1]==name)):
print("Record Found",k)
break
Page: 12/12