SET-1 QP
SET-1 QP
2. In a table in MYSQL database, an attribute ABC of datatype int with constraint NOT NULL and 1
another attribute XYZ of datatype varchar(10) with constrain UNIQUE. Which attribute will
allow duplicate data values during insertion of records?
a. ABC b. XYZ c. both ABC and XYZ d. None of these
3. What will be the output of the following statement: 1
print(pow(2,3)//8*(1+2)+3**2**2)
a. 0 b. 84.0 c. 84 d. 0.0
Page 1 of 9
8. Consider the statements given below and then choose the correct output from the given 1
options:
x = 'PM Shri KV'
str1=x[::-1]
for y in str1:
print(y,end='')
x.lower()
9. Which of the following statement(s) would give an error during execution of the following code? 1
tuple1 = (10,20,30,40,50,60)
list1 =list(tuple1) # Statement -1
new_list = [] # Statement -2
for i in list1:
if i%3==0:
new_list.append(i) # Statement -3
new_list.append(tuple1)
print(new_list[3]) # Statement -4
10. What possible outputs(s) will be obtained when the following code is executed? 1
import random
List = ['CTC', 'BBSR', 'KDML', 'PURI']
for y in range (4):
x = random.randint (1,3)
print (List[x], end = '#')
Options are:
a) KDML#PURI#BBSR#PURI# b) KDML#KDML#PURI#PURI#
11. A Router is a network device that forwards data packets along networks. A _______________ 1
is networking device that connects computers in a network by using packet switching to
receive, and forward data to the destination.
a. Hub b. Switch c. Repeater d. Modem
12. Consider the statements given below and then choose the correct output from the given options: 1
def fun2():
global x
print(x, end=":")
x=500
print(x, end=":")
x=x+1
Page 2 of 9
13. try: 1
n=int(eval(input("Enter any value: ")))
if n<=0:
raise Exception("Zero/Negative ")
else:
print(" Positive Number")
_______________
print("Zero Entered/ Negative Number")
finally:
print("End of try ..... except with finally clause ")
14. Which of the following statements is TRUE about keys in a relational database? 1
a. The number of tuples/rows in a relation is called the Degree of the relation.
b. The number of attribute/columns in a relation is called the Cardinality of the relation.
c. Primary key allows Unique and Null values only.
d. Domain is a set of values from which an attribute can take a value in each row. Usually, a
data type is used to specify domain for an attribute.
15. ____________ is a set of rules that need to be followed by the communicating parties in 1
order to have successful and reliable data communication.
16. Which of the following File Open modes opens the file in append and read mode. If the file 1
doesn’t exist, then it will create a new file.
a. “a+” b. “r+” c. “a+r” d. “r+a”
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
17. Assertion (A):- A Python sequence is an ordered collection of items, where each item is 1
indexed by an integer.
Reasoning (R):- The Strings, Lists and Tuples are not sequence data types available in Python.
18. Assertion (A):- A function may or may not return a value when called. The return statement 1
returns the values from the function.
Reasoning (R):- The return statement does the following: • returns the control to the calling
function. • return value(s) or None.
SECTION B
20. The given Python code to print all Prime numbers in an interval (range) inclusively. The given 2
code accepts 02 number (low & high) as arguments for the function Prime_Series() and
return the list of prime numbers between those two numbers inclusively. Observe the following
code carefully and rewrite it after removing all syntax and logical errors. Underline all the
corrections made.
Page 3 of 9
def Prime_Series(low, high)
primes = []
for i in range(low, high + 1):
flag = 0
if i < 2:
continue
if i = 2:
primes.append(2)
continue
for x in range(2, i):
if i % x == 0:
flag = 1
break
if flag == 0:
primes.append(x)
return primes
low=int(input("Lower range value: "))
high=int(input("High range value: ")
print(Prime_Series(low, high))
21. Write a function seq_to_dict(ls, tp) in Python that takes one list and one tuple as two 2
arguments. The function will return a dictionary with an update of key-value pairs with keys
from a list and values from a tuple.
For example, Consider the following:
List ls=[1,2,3,4] Tuple tp=("Pranay", "Shuvam", "Snehant","Swasat"))
The returned dictionary will be: {1: 'Pranay', 2: 'Shuvam', 3: 'Snehant', 4: 'Swasat'}
OR
Write a function dict_seq(dict) in Python that takes a dictionary (keys as numbers and values
as strings) as an argument and returns a list and a tuple. The list will have keys from the
dictionary, and the tuple will have values from the dictionary, but the values from the
dictionary should be converted to upper case if those are in lower case and uppercase if
those are in lowercase.
even_odd ((9,10,11,13,13,14))
Page 4 of 9
23. Write the Python statement for each of the following tasks using BUILT-IN functions/methods 1+1=
only: 2
(i) To counts and return how many times a value 98 is occurred in a tuple TP.
(ii)To replace all the occurrences of the old string “THE” with the new string “the” in the string
named LINE.
OR
An arithmetic expression is required to calculate the area of the circle as (Area=πr2) with r as
the radius of 8cm. Write the Python command to import the required module and use the built-
in function or object to find the area of the circle.
24. Mr. Pranaya has just created a table named “DEPARTMENT” containing columns Deptno, 2
Dname, Location, and Phone. After creating the table, he realized that he needed to remove
the Phone column from the table. Help him to write a SQL command to remove the column
Phone from “DEPARTMENT” table. Thereafter, write the command to modify the location of
Deptno-101 as “ Odisha” in the table:
OR
Mr. Swasat is working as a database administrator in Micron Semiconductor MNC. He wants
to create a database named “MICROINDIA”. After creating the database, he will create a table
named MICRONSW with the following descriptions:
Field Name Type with (size) Constraints
ENO INTEGER ( 4) PRIMARY KEY
ENAME VARCHAR (15) NOT NULL
JOB CHARACTER (10) UNIQUE
SALARY FLOAT(10,2) DEFAULT VALUE 5000
25. Predict the output of the Python code Given below: 2
def Sum(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1
lst= [20,25,24,34,35]
for C in range (3,0,-1):
A=lst[C]
B=lst[C-1]
print(Sum(A,B),end='#')
else:
print("\nend of the program".title())
SECTION C
26. Predict the output of the Python code Given below: 3
def fun_para(x=5,y=10,z=1005):
z=x/2
res=y//x+z
return res
a,b,c=20,10,1509
print(fun_para(),fun_para(b),sep='#')
res=fun_para(10,20,6015)
print(res, "@")
print(fun_para(z=999,y=b,x=5), end="#@")
Page 5 of 9
27. Consider the table GAMES given below and write the output of the SQL queries that follow. 1*3=
TABLE: GAMES 3
GCODE GNAME STADIUM P_NO P_MONEY DATE
1001 Relay Star Annex 16 10000 2001-01-23
1002 High Jump Super Power 12 12000 2003-02-14
1003 Shot Put Star Annex 11 8000 2002-07-07
1008 Discuss Throw Star Annex 12 9000 2003-03-19
1005 Long Jump Super Power 10 11000 2002-12-20
(i) SELECT MAX(P_MONEY), MIN(P_MONEY) FROM GAMES;
(ii) SELECT GCODE, GNAME FROM GAMES
WHERE PNO IN (16,12,11) AND DOJ>’2001-01-23’;
(iii) SELECT DISTINCT STADIUM FROM GAMES WHERE GNAME NOT LIKE “H%d”;
28. Write a function, WordCount() in Python to read a text file, “story.txt”, and display those words 3
in it that begin with consonants and end with vowels. Also, the function will count those words
and return how many such numbers are in the same text file.
OR
Write a function, LineCount(), in Python to count and return the number of lines in “letter.txt”
that have a numeric value. Also, the function will display those lines in the same text file.
30. A dictionary, StudRec, contains the records of students in the following pattern: 3
{admno: [m1, m2, m3, m4, m5]}, i.e., Admission No. (admno) as the key and 5 subject
marks in the list as the value.
Each of these records is nested together to form a nested dictionary. Write the following user-
defined functions in the Python code to perform the specified operations on the stack named
BRIGHT.
(i) Push_Bright(StudRec): it takes the nested dictionary as an argument and pushes a list of
dictionary objects or elements containing data as {admno: total (sum of 5 subject marks)}
into the stack named BRIGHT of those students with a total mark >350.
(ii) Pop_Bright(): It pops the dictionary objects from the stack and displays them. Also, the
function should display “Stack is Empty” when there are no elements in the stack.
Page 6 of 9
For Example: if the nested dictionary StudRec contains the following data:
StudRec={101:[80,90,80,70,90], 102:[50,60,45,50,40], 103:[90,90,99,98,90]}
Thes Stack BRIGHT Should contain: [{101: 410}, {103: 467}]
The Output Should be: {103: 467}
{101: 410}
If the stack BRIGHT is empty then display: Stack is Empty
SECTION D
31. Table Name: TRADERS 4
TCODE TNAME CITY
T01 RELIANCE DIGITAL MUMBAI
T02 TATA DIGITAL BHUBANESWAR
T03 BIRLA DIGITAL NEW DELHI
(i) Display the SNAME, QTY, PRICE, TCODE, and TNAME of all the stocks in the STOCK
and TRADERS tables.
(ii) Display the details of all the stocks with a price >= 35000 and <=50000 (inclusive).
(iii) Display the SCODE, SNAME, QTY*PRICE as the “TOTAL PRICE” of BRAND “NEC” or
“HP” in ascending order of QTY*PRICE.
(iv) Display TCODE, TNAME, CITY and total QTY in STOCK and TRADERS in each TCODE.
32. Mr. Snehant is a software engineer working at TCS. He has been assigned to develop code 4
for stock management; he has to create a CSV file named stock.csv to store the stock details
of different products.
The structure of stock.csv is : [stockno, sname, price, qty], where stockno is the stock serial
number (int), sname is the stock name (string), price is stock price (float) and qty is quantity
of stock(int).
Mr. Snehant wants to maintain the stock data properly, for which he wants to write the following
user-defined functions:
AcceptStock() – to accept a record from the user and append it to the file stock.csv. The
column headings should also be added on top of the csv file. The number of records to be
entered until the user chooses ‘Y’ / ‘Yes’.
StockReport() – to read and display the stockno, stock name, price, qty and value of each
stock as price*qty. As a Python expert, help him complete the task.
Page 7 of 9
SECTION E
33. The USA-based company, Micron, has selected Tata Projects to build the semiconductor 1*5=
assembly and test facility in Sanand Town, near Ahmedabad in Gujurat. It is planning to set 5
up its different units or campuses in Sanand Town and its head office campus in New Delhi.
Shortest distance between various locations of Sanand Town blocks and Head Office
at New Delhi:
Training Campus Research Campus 3 KM
Business Campus warehousing 4.5 KM
Manufacturing Research Campus 1.5 KM
Campus
Warehousing Training Campus 9.5 KM
Research Campus Business Campus 3.5 KM
Warehousing Campus Research Campus 2.6 KM
Research Campus New Delhi Head Office Campus 962KM
Number of computers installed at various locations are as follows:
Warehousing Campus 20 computers
Research Campus 200 computers
Business Campus 10 computers
Training Campus 25 computers
Manufacturing Campus 15 Computers
Ahmedabad Admin Campus 15 Computers
As a network consultant, you have to suggest the best network related solution for their
issues/problems raised :
(i) Suggest the most appropriate location of the SERVER to get the best and effective
connectivity. Justify your answer.
(ii) Suggest the best wired medium and draw the cable layout (location to location) to
efficiently connect various locations
(iii) Which hardware device will you suggest to connect all the computers within each
location?
(iv) Suggest a system (hardware/software) to prevent unauthorized access to or from the
network.
(v) Which type of network out of the following is formed by connecting the computers of New
Delhi Head Office and Sanand Town Units? a) LAN b) MAN c) WAN d) PAN
34. (i) What are the similarities and difference between a+ and w file modes in Python. 2+3=
5
(ii) (ii) A binary file “product.dat” has structure [PNO, PNAME, BRAND_NAME, PRICE] to
maintain and manipulate Product details.
*Write a user defined function CreateFile() to input data for a record and add to “product.dat”
file. The number of records to be entered until the user chooses ‘Y’ / ‘Yes’.
*Write a function CountData(BRAND_NAME) in Python which accepts the brand name as
parameter and count and return number of products by the given brand are stored in the binary
file “product.dat”.
OR
(i) What is the difference between seek() and tell()?
Page 8 of 9
(ii) A binary file “STUD.DAT” has structure (admission_number, Name, total_mark) with
student details.
Write a user defined function WriteFile() to create a file input data for a record and write
to “stud.dat” file. The number of records to be entered until the user chooses ‘Y’ / ‘Yes’.
Write a function ReadFile() in Python that would read the contents of the file
“STUD.DAT” and display the details of those students whose total mark is less than or
equal to 250 under the printed heading "REMEDIAL STUDENT LIST “. Also display
and the number of students scoring above 250 marks as Bright Student.
35. (i) What is the difference between degree and cardinality with respect to RDBMS. Give one 1+4=
example to support your answer. 5
(ii) Mr. Shuvam wants to write a program in Python to Display the following record in the table
named EMP in MYSQL database EMPLOYEE with attributes:
EMPNO (Employee Number ) - integer ENAME (Employee Name) - string size(30)
SAL (Salary) - float (10,2) DEPTNO(Department Number) - integer
OR
(ii) Mr. Pranay wants to write a program in Python to update the particular record by accepting
its Department Number value in the table named DEPT in MYSQL database EMPLOYEE with
attributes:
-end-
Page 9 of 9