0% found this document useful (0 votes)
10 views9 pages

Python Programming Exam Paper

....................mmmm

Uploaded by

tanmayop200
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views9 pages

Python Programming Exam Paper

....................mmmm

Uploaded by

tanmayop200
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

COMPUTER SCIENCE (083)

Time aliowed: 3Hours Maximum Marks: 70

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, Dand E.
Section Aconsists of 21 questions (1 to 21). Each question carries 1 Mark.
Section Bconsists of 7questions (22 to 28). Each question carries 2 Marks.
Section Cconsists of 3 questions (29 to 31). Each question carries 3 Marks.
Section Dconsists 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.
Allprogrammingquestions are to be answered using Python Language only.
In case of MCQ, text of the correct answer should also be written,

QNo. Section-A (21 x 1= 21 Marks) Marks

State True or False:


Python does not allows same variable to hold different data literals / (1)
data types.
What willthe following expression be evaluated to in Python?
2
print( (-33 I/ 13) (35 %-2)* 15/3)
a. 10.0
b. -15.0 (1)
c 150
d -10.0

3 What will be the value of y when following expression be evaluated in


Python?
x10.0 (1)
y-(x<100 0) and x>=10
(A) (a)110(b) False (c)Error (d)True
4
Select the correct output of the code
n="Post on Twitter is trending"
q=nsplit(t) (1)
print( q{0+q(2]+q[3]+q{411|)
a Pos on witter is rending
b. Pos on Twitter is ending
G. Poser witter is ending
.. Poser is ending
5 Given is a Python string declaration.
(1)
Wish ="## Wishing All Happy Diwali @#$"
Write the output of Wish[ -6 ::-6]
6 What will be the output of the following code?
tuplel = (1, 2, 3)
tuple2 = tuplel
tuple1 t= (4,)
print (tuple1 tuple2) (1)
(A) True
(B) False
(C) tuple1
(D) Error
7 If my dict is a dictionary as defined below, then which of the following
statements will raise an exception?
my dict = {'apple': 10, 'banana': 20, 'orange': 30}
(A) my_dict.get('orange') (1)
(B) print(my_dict['apple', 'banana'])
(C) my_dict['apple']=20
(D) print(str(my_dict)
Write the importance of passing file mode while declaring a file object in (1)
data file handling.
Differentiate between Bps &bps. (1)
10. Write the missing statement to complete the following code:
file = open ("example. txt", "r")
data [Link](100)
#Move the file pointer to the (1)
beginning of the file
next data = [Link] (50)
[Link] ()

11. State whether the following statement is True or False:


The finally block in Python is executed only if no exception occurs
in the try block. (1)

12. Flnthemissng blank nthe codegivento [Link] af [Link] [Link]


at words tromit.
fob opentnotestx
data-fobj read()
stNords
[Link])
(1)
13 Which is knoun as rargs psrator in My07
14 What wil! be the output of the query?
SELZCT FRM roducts WALPZ tuct iae LIT2
App
(A) Details ofall products uhose narnes start wth App
(B)Details of all products whoe narnes end wtn App
(GjNames of all products wioE narnes start witrn App'
(D)Narries of all products wose rarnes erd viith 'App'
15
Whichof the foliowing connector is ued for thernes cales in a LAN?
(A) a) RJ11 b) RJ45 c) ETHO d) F Connector
16. Which two of the following queries are not valid in MySQL?
a)select gender, count(*} fon students having age >15;
b)select gender, count(*) from students where age>15 group by gender, (1)
c) select gender, sum(age) from students group by gender having
surn(age)25;
d) select gender, max(age) from students group by gender arder by
max(age):
17. Rohit has purchased a new Smart TV and wants to cast a video from his (1)
mobile to his new Smart TV. Identify the type of network

18 Which network device is used to connect two networks that use different
protocols?
(A) Modem
(B)Gateway (1)
(C) Switch
(D)Repeater
Which switching technique breaks data into smaller packets for
19.
transmission, allowing multiple packets to share the same network (1)
resources.

Q20 and Q21 are Assertion(A) and Reason{R) based questions. Mark
the correct choice as:
(A) Both A and Rare true and R is the correct explanation for A
(B) Both Àand R are true and R is not the correct explanation
for A
(C)Ais True but R is False
(D)A is False but R is True
definition can have Zero
Assertion (A): A function
20. parameters/formal arguments.
Reasoning (R): Parenthesis are not mandatory
to call a (1)
function with zero arguments
Assertion (A) The expression "HELLO". sort () in
21. Python will give an error.
Reason (R) sort () does not exist as a method/function for strings in
Python. (1)
Q No Section-B (7 x2=14Marks) Marks
22.
Rewrite the following code in ython after remnoving all syntas eror(s).
each coLrection done in the code. Underin

Y=integer(input("Enter 1or 10") (2)


ifY'==10
for Yin nge(1,11):
print()
else:
fot m in range(5,0,-l):
print(thank you)
23. Give two examples of each of the following:
(1) Arithmetic operators (1) Relational operators (2)
24. Consider a List L=[10,20,30,[40,50,60],70,80]
Write a single line python statement (using List methods
i.
Insert an element 55 as the second last element of only) to:
the inner list, so that
L becomes (10,20,30,[40,50,55,601,70,80]
i. Delete the inner list so the L becomes (2)
[10,20,30,70,801
25. What possible outputs(s) are
execution of the program fromexpected to be displayed on screen at the
the following code? Also specify time of
values that can be assigned toeach of the variables BEG and END. the maximum

inport random

HEIGHTS=[10,20,30,40,50)
BEG=[Link] (0,2) (2)
END=random. randint (2,4)
for X in range (BEG,
END) :
print (HEIGHTS (X], end="@")
(a) 30@
(6) 10@20@sO@40@50@
() 20@30
(d) 40@30@
Iind and write lie output of he following Pyttion code:
ConVErt (01d)
l-]en(91d),
foL i in tange (0, 1) :
if 01d |i].isupper ():
New=lea*01d[i].lower ) (2)
l1f old[[Link] ():
NewNew+0ld[i).uppr()
elif 01d[i). isdigit () :

iew-New+""

Older"lnDlaG2020n
Newer(Convert (0lder)
print ("New string is : " Newer)
27. ()
A) What constraint should be applied on a table column so that
duplicate values are not allowed in that column. but NULL is
allowed.
OR
B) What constraint should be applied on a table column so that (2)
NULL 0s not allowed in that column, but duplicate values are
allowed.

i)
|(b)Iable Employee
Sales Jobld
Employeid Nane
SumitSinlha 110000 102
Vijay Suigiu 150000 10i-
Tonar
E3 AjayRajpal 140000
E4 Mohit Kumar 125000 102
ES Sailja Singh 145000 A03
Table: Job

Jobld JobTitle Saiary


10 Piesident 200000
102 Vice Piesident 125000
103 Adnsnisrator Assistant 80000
104 Accountring Manager 70000
105 Accountant 65000
106 Sales Maager So000
|Chrve the ouupt of follow ing SQL statehient:
U)Select Nane: JobI1tie. Sales tiomEnployee. Jab
wbere Etiployee Jobld=Job Jobld and obld in (101.102)
G) Seleet obld, count(* fiom Enplayee g oup by Jobld
28 Give difference between
Video Conterencing and
(a) Write the full
forms of the Chatting O*
(i)GSM (ü)XML following (2)
Kb) What is the use of
Modem?
Q No.
SectionC(3x39 Marks) Marka
29. A) Write a function COUNTLINES )
which eads
and then count and display the nurnbor of the a text file STORY. TX
ends with samo letter irrespective of its lines which starts and
content of the text file [Link] is : [Link] exarnple f the
(3)
The person has asent a lovely tweet
Boy standing at station is very disturbed
Even when there is no light we can
see
How lovely is the situation
The expected output is:
The Number of lines starting with same letter is 2
OR
B) Write a Python function that finds and displays all the words longer
than
5 characters from atext file "[Link]"
30. Pramod has created a dictionary containing EMPCODE and SALARY a
key value pairs of 5 Employees
of Parthivi Constructions.
Write a program, with separate user defined functions to performn the
following operations:
"Push the keys (Employee code) of the dictionary into a stack, where the
corresponding value (Salary) is
less than 25000.
"Pop and peek the content of the stack. For example: If the sample
content of the dictionary is as
follows:
EMP="EOP1":16000, "EOP2":28000, "EOP3":19000, "EOP4":15000,
EOP5":30000}
The output from the program should be: EOP4 EOP3 EOP1 (3)
OR
Write a function POP(Arr), where Arr is a stack implemented by a list of
numbers The furnction returns the value deleted from the stack.
31. Predict the outot of the foiing
ie
d= {apple: 15, "banana" : ,
*chrr7 31

for key in d:
stri stri + str (d(key]) + "g + "n"
str2 = stri[:-1]
print (str2)
(3)
OR
Predict the output of the foilowing code
line=[4,9,12,6,20]
for I in line:

for j in range (1,I%5) :


print(j,'#end=")
print ()
Q No. Section-D(4x4= 16 Marks) Marks

Consider the table given below aud write the output of SQL queries (ij to(11)
32.
IABLE: PLAYERS

P ID Name Gane Gender DoB Salary


101 Virat Kohli Cicket M 1994-1248 12500
102 PV Sindhu Badminton 1993-01-12 9000
103 Palhul Sharn:a Cricket 1983-0145 10000
104 Saina Kelw a! Badminton F 1990-12-25 856
105 Pankaj Ad. ars Snooker 1985-06-16 10000
106 Harnmaprset Crncket 1994-10-10 12500 (4)
107 Sardar Singh Hockey 1982-11-9 9000
108 VAnand Chess 1982-11-01 12000

i Seiect Nause. Salary from playess where Gane not in ("cricket'. "chess"k
1i Seleet stuu( Salary) fiom playe1s wheie Nane like 9i':
i Select countfdistinct Game) from players:

33 Write aPython program to perform the following using functions as follows


copytocsv0 ACSV file"[Link]" has name, class andmarks separated byy [Link] t
Python furncion to copy only the narme and cdass to another CSV file "[Link]".
COpyselected) The CSV Ele "[Link]" which has name, ciass and marks separated by
Comna. Write the Python furction to copy only rows of students of cdass 2to another CSV 6
"cdass csv",
(4)
B) )How many exsept hlxsks can be wrftten, agaiista tr7 ky s
j1) What output wl te tollowéng ende pruuse
[Link]
[Link]*AIGLE2625")
fclosei
fopent"t1tit, r
Sfreagc)
printks
except F1leNotFayrdError:
print(F1le does 1 ext)
else:
printt EJle _uccessful1y procestedij
1nally:
priat("F1le haridling çodé ends)
the followirg
35 Atable, named STATIONERY, in ITEMDB database, has
structure:

Field Type
iternNo int(11)
itemName varchar(15)
price float
gty int(11)
(4)
Write the following Python function to perfom the specified operation:
AddAndDisplay(): To input details of an item and store it in the table
STATIONERY. The function should then retrieve and display all records
from the STATIONERY table where the Price is greater than 120.

Assume the following for Python-Database connectivity:


Host: localhost, User: root, Password: Pencil

[Link]. SECTION E(2 X5=10 Marks) Marks


36
A binary file "[Link]" exists storing details of hotel customers as
structure: per tollog
Roomid CustornerName Days
Mr. Varun the deveioper of the hotel maintains the details of
write a program in Python for adding and displaying recordscustoners.
from the
Help Fim to
binary file using
following functions:
() Reserve) To add data of
ustoners to birary hle.
(i) ShowReservations() To open the file the
[Link] and display all the records.
(ü) What are the advantages of
Binary files over text hies.
Stalwart Solutions Pvi Lid is
setting up is campus in Norda. The compauy camps wiül have
four blocks - Shivaji
(S). Tagore (T), Ashoka (A) and Ranan (R). Tae coaupany L2s conted
you for networking at the canpus. Suggest the best
possibie solutions fo ther ques0
(e) based on the information
given below.
Block No, of Distance
Blocks
Computers (n)
Shivaji (S) 75 Shivaji to Tagore 25
Tagore (T) 125 Shivaji to Ashoka 150
Ashoka(A) 25 Shivajito Raman 125 A

Raman (R)|20 Tagore to Ashoka 75


Tagore to Raman 90

a) Suggest the most appropriate block to house the FTP server. Justify vour answer.
b) Which Hardware/Softvare can be installed preveat umauthorized 2ccess to FIP server?
c) Suggest the best econonical wired transmission mediun and draw the cable layout
diagram to connect the four blocks.
d) The company doesn't want to use any wied media for connecting the computers winin
the Raman block. Which device can be used to provide wireless access. givea that all the
machines in this block are wi-fi enabled.

e) The company wishes to minimize the broadcast traffic in the LAN established.
Kecping this in mind, which device wil! you suggest to connect the computers inside
every block - hub or switch? Why?

You might also like