GR12-CS
GR12-CS
5 If column “Marks” contains the data set {25, 35, 25, 35, 38}, what will be the output after
the execution of the given query? SELECT DISTINCT MARKS FROM STUDENTS;
(a) 25, 35, 25, 35, 38 (b) 25, 25, 35, 35 (c) 25, 35, 38 (d) 25, 25, 35, 35
7 Which SQL statement do we use to find out the total number of records present in the
table EMP?
(a) SELECT * FROM EMP; (b) SELECT COUNT (*) FROM EMP;
(c) SELECT FIND (*) FROM EMP; (d) SELECT SUM () FROM EMP;
8 What is the result of the following expression?
s=’0123456789’
print(s[3],”,”,s[0:3],”-“,s[2:5])
(a) 3 , 012 - 234 (b) 3 , 0123 - 2345
(c) 4 , 0123 - 2345 (d) 4 , 012 - 234
12 Which of the following function is used with the csv modules in Python to read the content
of a csv file into an object?
(a) readrow() (b) readrows() (c) reader (d) load()
14 Which SQL function is used to display length of string values from attributes?
(a) Len() (b) Length() (c) Sum() (d) None of the above
16 ________ is the act of copying another person’s ideas, words or work and pretending they
are your own.
(a) Online copying (b) Plagiarism (c) Patent (d) Digital phishing
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as
19 Re-write the following program after removing errors, if any, and underline all the
corrections made.
a = input("Enter a number:")
b = int(input("Enter a number:"))
if a = b:
a+b=a
else
b=b+a
print(a,b)
OR
Differentiate between router and gateway
20 Mahesh, a database administrator needs to display house wise total number of records of
‘Green’ and ‘Orange’ house. She is encountering an error while executing the following query:
SELECT HOUSE, COUNT (*) FROM STUDENT GROUP BY HOUSE WHERE HOUSE=’Green’ OR HOUSE=
‘Orange’;
Help her in identifying the reason of the error and write the correct query by suggesting the possible
correction (s).
22 Write a Python function that takes two lists and returns True if they have at least one
common member
23 Write the Python statement for each of the following tasks using BUILT-IN
functions/methods only:
(i) To insert an element 100 at the Second position, in the list L1.
(ii) To check whether all the characters in the string S1 are digits or not.
OR
How the pop( ) function is different from remove( ) function working withlist in python ? Explain with
example.
24 Mr.Shyam has created a FLIGHT table with FNO, START, REMARKS, FDATE and FARE with
appropriate data type. Now he wants to delete the attribute REMARKS and to add a new column
END with string data type and it should not contain NULL value. Please help Mr.Shyam to complete
this task.
OR
Categorize the following commands as DDL and DML: INSERT, ALTER, DROP, DELETE, UPDATE,
CREATE
T = (9,18,27,36,45,54)
T1 = tuple()
for i in T:
if i%6==0:
T1=T1+(i,)
print(T1)
SECTION – C
Text = "gmail@com"
L=len(Text)
Ntext=""
for i in range(0,L):
if Text[i].isupper():
Ntext=Ntext+Text[i].lower()
elif Text[i].isalpha():
Ntext= Ntext+Text[i].upper()
else:
Ntext=Ntext+'bb'
print(Ntext)
27 Consider the following table ‘Transporter’ that stores the order details about items to be
Table: Transporter
28 Write a function COUNT_AND( ) in Python to read the text file “STORY.TXT” and count the
number of times “AND” occurs in the file. (include AND/and/And in the counting)
OR
What is the difference between the following set of statements (a) and (b):
a) P = open(“practice.txt”,”r”)
P.read(10)
b) with open(“practice.txt”, “r”) as P:
x = P.read()
SECTION C
CUSTOMER
CUSTID NAME PRICE QTY CID
101 ROHAN SHARMA 70000 20 222
102 DEEPAK KUMAR 50000 10 666
103 MOHAN KUMAR 30000 5 111
104 SAHIL BANSAL 35000 3 333
105 NEHA SONI 25000 7 444
106 SONAL AGGARWAL 20000 5 333
107 ARUN SINGH 50000 15 666
i. Define CID in CUSTOMER table as Foreign Key that refers to CID i.e. Primary Key of COMPANY
table.
ii. Display the ‘CUSTOMER NAME’, ‘PRODUCT NAME’ who have purchased any product from the
‘COMPANY NAME’ ‘SONY’.
iii. Increase the QTY by 15 for the products with PRICE below 40,000.
30 A list, NList contains following record as list elements: [City, Country, distance from Delhi]
Each of these records are nested together to form a nested list.
Write the following user defined functions in Python to perform the specified operations on the
stack named travel.
(i) Push_element(NList): It takes the nested list as an argument and pushes a list object
containing name of the city and country, which are not in India and distance is less than
3500 km from Delhi.
(ii) Pop_element(): It pops the objects from the stack and displays them. Also, the function
should display “Stack Empty” when there are no elements in the stack.
For example: If the nested list contains the following data:
NList=[["New York", "U.S.A.", 11734],
["Naypyidaw", "Myanmar", 3219],
["Dubai", "UAE", 2194],
["London", "England", 6693],
["Gangtok", "India", 1580],
["Columbo", "Sri Lanka", 3405]]
The stack should contain:
['Naypyidaw', 'Myanmar'],
['Dubai', 'UAE'],
['Columbo', 'Sri Lanka']
The output should be:
['Columbo', 'Sri Lanka']
['Dubai', 'UAE']
['Naypyidaw', 'Myanmar']
Stack Empty
OR
State any two differences between single row functions and multiple row functions with examples.
SECTION D
31 A relation Vehicles is given below :
V_no Type Company Price Qty
AW125 Wagon Maruti 250000 25
J0083 Jeep Mahindra 4000000 15
S9090 SUV Mitsubishi 2500000 18
M0892 Mini van Datsun 1500000 26
W9760 SUV Maruti 2500000 18
R2409 Mini van Mahindra 350000 15
32 Given the following CSV file named "inventory.csv": What will be the output of the following
Python program? If there is any error, identify and correct it.
total_cost = 0
with open('inventory.csv', 'r') as file:
reader = csv.reader(file)
next(reader) # Skip header row
for row in reader:
quantity = int(row[1])
price = float(row[2])
total_cost += quantity * price
print('Total inventory cost:', total_cost)
OR
Write a Python program that opens a CSV file named "students.csv" in write mode using the
csv.writer() object. The program should prompt the user to enter student names and their
respective grades, and then write this data into the CSV file. Ensure appropriate error handling for
incorrect input.
SECTION E
33 Trine Tech Corporation (TTC) is a professional consultancy company. The company is planning to
set up its new offices in India with its hub at Hyderabad. As a network advisor, you have to
understand their requirements and suggest to them the best available solutions. Their queries are
mentioned as (i) to (iv) below.
Block Computers
Human Resource 25
Finance 120
Conference 90
(i) What will be the most appropriate block, where TTC should plan to install their server?
(ii) Draw a block diagram showing a cable layout to connect all the buildings in the most
appropriate manner for efficient communication
(iii) What will be the best possible connectivity out of the following, you will suggest
connecting the new setup of offices in Begaluru with its London based office.
• Satellite Link
• Infrared
• Ethernet Cable
(ii) Consider a binary file “employee.dat” containing details such as(empno, ename, salary).
Write a python function to display details of those employees who are earning between 20000 and
30000 (both values inclusive).
OR
(ii) Write a Python function in Python to search the details of the employees [name, designation,
salary] whose salary is greater than 5000.
The records are stored in the file “emp.dat”. consider each record in the file emp.dat as a list
containing name, designation and salary.
35 (i) How many candidate key and primary key a table can have in a Database?
(ii) Manish wants to write a program in Python to create the following table named “EMP” in MYSQL
database, ORGANISATION:
The values of fields eno, ename, edept and Sal has to be accepted from the user. Help Manish to
write the program in Python to insert record in the above table.
OR