You are on page 1of 3

(iii) Write a Python program to iterate Roll No. .........................

over dictionaries using for loops. (06/21-II)


(iv) Write a Python program to sort a 51322
dictionary by key.
B. Tech. EXAMINATION
(b) Write a detailed note on any six inbuilt
(For Batch 2018 & Onwards)
operations on Tuples. Explain each with
(Fifth Semester)
the help of example. 6
COMPUTER SCIENCE AND ENGINEERING
5. (a) Differentiate between Mutable and PCC-CSE302-T/PCC-IT308-T
immutable datatype. Python Programming
(b) Given a list of tuples, write a Python
Time : Three Hours Maximum Marks : 70
program to sort the tuples by the second
item of each tuple. Note : Attempt Five questions in all. Q. No. 1 will
be compulsory. Attempt the remaining four
Examples :
questions by selecting one question from
Input : [('452', 10), ('256', 5), ('100', 20), each of the four Units. All questions carry
('135', 15)] equal marks.
Output : [('256', 5), ('452', 10), ('135', 15),
1. Attempt the following : 7×2=14
('100', 20)]
(a) Explain command line arguments in
7+7=14
python.

B-51322 4 (3-06/1) B-51322 P.T.O.


(b) Explain the syntax of eval() in python. 3. (a) What are the reasons for python being
(c) Explain any two operations on file in the first programming language for
python.
learners ? 7
(d) What are namespaces in python ?
(e) How to handle multiple exceptions with (b) Python variables do not have specific
single except clause ? types. Justify this statement with the help
(f) Write Python script to print table of a of an example. 7
number and number should be inputted
from user. Unit II
(g) What is the use of pandas in python ?
4. (a) Answer the following : 4×2=8
Unit I
(i) Write a Python script to add a key
2. (a) Write a Python program to find square
to a dictionary :
sum of first n natural numbers. 7
Sample Dictionary : {0 : 10, 1 : 20}
(b) Write a Python program to count the
number of even and odd numbers from a Expected Result : {0 : 10, 1 : 20,
series of numbers. 2 : 30}
Sample numbers : numbers = (1, 2, 3, 4,
(ii) Write a Python script to check
5, 6, 7, 8, 9)
Expected Output : whether a given key already exists
Number of even numbers : 4 in a dictionary.
Number of odd numbers : 5. 7
B-51322 2 (3-06/2) B-51322 3 P.T.O.
Unit IV Unit III

8. Illustrate with the help of python script the DML 6. (a) How to handle an exception using try
and DDL operations with the databases. 14 except block ? Explain. 8

(b) Write a function called oops that


9. Write detailed notes on the following :
explicitly raises a IndexError exception
(a) Matplotlib
when called. Then write another function
(b) Sklearn. 7+7=14
that calls oops inside a try/except
statement to catch the error. What happens
if you change oops to raise KeyError
instead of IndexError ? Where do the
names KeyError and IndexError come
from ? 6

7. (a) How to implement method overloading


In Python ? Explain. 7

(b) Write a script illustrating multilevel


inheritance. 7

B-51322 6 __ (3-06/3) B-51322 5 P.T.O.

You might also like