Python 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Total No. of Questions : 5] SEAT No.

:
PA-2556 [Total No. of Pages : 6
[5948]-201
M.C.A. - I (Management )
IT - 21 : PYTHON PROGRAMMING
(2020 Pattern) (Semester - II)
Time : 2½ Hours] [Max. Marks : 50
Instructions to the candidates:
1) All questions are compulsory.
2) Figures to the right indicate full marks.
3) Answer all sub questions at one place.

Q1) Choose the correct option. (½ mark each) [10]


a) If zoo = [‘lion’, tiger’], what will be zoo*2?
i) [‘lion’, ‘lion’, ‘tiger’, ‘tiger’]
ii) [‘lion’]
iii) [‘tiger’]
iv) [‘lion’, ‘tiger’, ‘lion’, ‘tiger’]
b) For dictionary d = {plum : 0.66, pears : 1.25, oranges : 0.49} which of
the following statement correctly updates the price of oranges to 0.52?
i) d [oranges] = 0.52 ii) d[0.49] = 0.52
iii) d [2] = 0.52 iv) d [plum] = 0.52
c) What is the correct syntax for creating single valued tuple?
i) (a) ii) ( , )
iii) ( a, ) iv) {a}
d) The length of sys. argv is
i) Only file name
ii) Total number of arguments including pythan command
iii) Total number of arguments including filename
iv) Total number of excluding the file name
e) Which of these definitions correctly describes a module?
i) Denoted by triple quotes for providing the specification of certain
program elements.
ii) Defines the specification of how it is to be used.
iii) Design and implementation of specific functionality to be
incorporated into a program.
iv) Any program that reuses code
[5948]-201 1 P.T.O.
f) To include use of functions which are present in random library, we must
use the option
i) random. h ii) random. random
iii) import. random iv) import random
g) ______is a string literal denoted by triple quote for providing the
specifications of certain program elements.
i) client ii) docstring
iii) modularity iv) Interface
h) The correct way of inheriting a derived class from base class is:
i) Class Derived (Base): ii) Class Base (Devired):
iii) Class (Base) Derived: iv) Class
i) The + operator is overloaded using the method
i) --plus-- ( ) ii) --add-- ( )
iii) --sum-- ( ) iv) --total-- ( )
j) The syntax for using super( ) in derived class__init__( )method definition
looks like
i) init--.super ( )
ii) Super( ).--init--(derived class parameters)
iii) Super( )
iv) Super ( ).--init-- (base class parameters)
k) The character___and___ matches the start and end of the string,
respectively.
i) $ and $ ii) * and &
iii) ^ and ° iv) ^ and $
l) Consider a five 21-12-2016. zip. The regular expression pattern to extract
date from filename is
i) ([0-9] {2} \- [0-9] {2} \- [0-9] {4})
ii) ([0-9] {1} \- [0-9] {2} \- [0-9] {4})
iii) ([0-9] {2} \- [0-9] {1} \- [0-9] {4})
iv) ([0-9] {2} \- [0-9] {2} \- [0-9] {2})

[5948]-201 2
m) When will the else part of the try-except-else be executed?
i) When an exception occurs

ii) Always

iii) When there is no exception

iv) When an exception occurs in try block.

n) When is the finally block executed?

i) only if some conditon that has been specified is satisfied

ii) always

iii) When an exception occurs

iv) When there is no exception

o) Which of the following is not a valid attribute of the file object file-handler.

i) file-handler.closed ii) file-handler.size

iii) file-handler.mode iv) file-handler. name

p) Which of the following command is used in mango shell to show all the
databases.

i) Show databases ii) Show dbs

iii) 1s dbs iv) Show dbs. all

q) The function that returns its arguments with a modified shape and the
method that modifies the arry itself respectively in Numpy are

i) resize, reshape ii) reshape2, resize

iii) reshape2, resize2 iv) reshape, resize

r) Which of the following is used for line graph?

i) plt. linc ( ) ii) plt. plot ( )

iii) plt. bar ( ) iv) plt. scatter ( )

[5948]-201 3
s) Which of the following statement is false?
i) ndarray is also known as the axis array
ii) in numpy, dimensions are called axes
iii) numpy main object is the homogeneous multidimensional array
iv) ndarry dataitemsize is the buffer containing the actual elements of
the array
t) The method used in pandas to return top 5 rows
i) top ( ) ii) top - rows (5)
iii) row (5) iv) head ( )

Q2) a) Write a program that accept the string from user and display the same
string after removing vowels from it. [3]
b) Explain possitional and keyword arguments in function. Use suitable
example. [3]
c) Describe instance variable, static variable and local variables in python
object oriented programming with example. [4]
OR
a) Compare List and tuple with suitable example. [3]
b) Explain lambda with example. [3]
c) Create class called, library with data attributes like Acc-number publisher,
title and author, the methods of the class should include [4]
i) Read ( ) - Acc- number, title, author, publisher.
ii) Compute ( ) - to accept the number of day late, calculate and display
the fine charged at the rate of Rupees 5/- per day.
iii) Display the data

Q3) a) Develop a program to print the number of lines, words and characters
present in the given file? Accept the file name from user. Handle necessary
exceptions. [2]
b) Illustrate CRUD operations in MongoDB with example [3]
c) Compare SQL Database with No SQL Database. [2]
d) Write aprogram to check whether entered string & number is palindrome
or not. [3]
OR

[5948]-201 4
a) Develop a pythan program to remove the comment character from all the
lines in the given file. Accept the file name from user [2]
b) Write a pythan program to perform following operations. on MongoDB
Database. [5]
i) Create collection “EMP” with fields:
Emp-name, Emp- mobile, Emp, sal, Age
ii) Insert 5 documents.
iii) Find the employees getting salary between 5000 to 10000.
iv) Update mobile number for the employee named as “Riddhi”
v) Display all employees in the order of “Age”
c) Write a pythan program to find the factorial of a given number using
recursion [3]

Q4) a) Write a program to demonstrate: [4]


i) Creating a Thread without using any class
ii) Creating a Thread by extending Thread class.

b) Write a Pythan program to check the validity of a password given by


user. [4]
The password should satisfy following criteria:
i) Contain at least 1 letter between a and z
ii) Contain at least 1 number between 0 and 9
iii) Contain at least 1 letter between A and Z
iv) Contain at least 1 character from $, #, @,*
v) Minimum length of password : 8
vi) Maximum length of password : 20
c) Explain Generators in python with suitable example. [2]
OR

[5948]-201 5
a) Write a program for synchronization of threads using RLOCK. Accept
the two numbers from user and calculate factorial of both numbers
simultaneonly [4]
b) Write a pythan program [4]
i) To remove all leading ‘zeros’ from an IP address
ii) To find all 5 character long words in a string Accept string from
user.
c) Explain decorators in pythan with suitable example [2]

Q5) a) Explain numpy integer indexing, array indexing. boolean array indexing
and slicing with example. [4]
b) Draw bar graph using matplotlib and decorate it by adding various elements
[2]
c) Prepare the pandas dataframe from csv file. [2]
perform following operations.
i) Fill all ‘NaN’ values with the mean of respective column.
ii) Display last 5 rows.
d) Explain constructors in pythan with example. [2]
OR
a) Write a program to illustrate numpy array attributes/functions. [4]
i) ndarray. shape
ii) np. zeros ( )
iii) np. eye ( )
iv) np. random. random ( ) [4]
b) Read data from csv five and create dataframe. Perform following
operations.
i) Display list of all columns.
ii) Display data with last three rows and first three columns [2]
c) Draw line graph using matplot lib and decorate it by adding various
elements. Use suitable data.
d) Explain multiple inheritance in python with suitable example. [2]

  

[5948]-201 6

You might also like