0% found this document useful (0 votes)
2 views4 pages

Programming With Python - Mca 1102 - 2023

The document outlines the examination structure for the Programming with Python course (MCA 1102), including time allotted, full marks, and instructions for answering questions. It consists of multiple groups with various types of questions, including multiple-choice, fill-in-the-blank, and coding tasks. The course outcomes detail the skills students are expected to develop upon completion, such as programming, data representation, control flow, object-oriented concepts, file handling, and using Python libraries.

Uploaded by

Saptarshi Mandal
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)
2 views4 pages

Programming With Python - Mca 1102 - 2023

The document outlines the examination structure for the Programming with Python course (MCA 1102), including time allotted, full marks, and instructions for answering questions. It consists of multiple groups with various types of questions, including multiple-choice, fill-in-the-blank, and coding tasks. The course outcomes detail the skills students are expected to develop upon completion, such as programming, data representation, control flow, object-oriented concepts, file handling, and using Python libraries.

Uploaded by

Saptarshi Mandal
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

MCA/1ST SEM/MCA 1102/2023

PROGRAMMING WITH PYTHON


(MCA 1102)

Time Allotted: 2½ hrs Full Marks: 60


Figures out of the right margin indicate full marks.
Candidates are required to answer Group A and
any 4 (four) from Group B to E, taking one from each group.
Candidates are required to give answer in their own words as far as practicable.

Group – A
1. Answer any twelve: 12 × 1 = 12
Choose the correct alternative for the following
(i) What will be the output from the following Python code snippet?

(a) 11 (b) 10 (c) 12 (d) 13.


(ii) What is the sequence of integers produced by the object returned from
range(100, 50, -10)?
(a) 50 60 70 80 90 (b) 50 60 70 80 90 100
(c) 100 90 80 70 60 (d) 100 90 80 70 60 50.
(iii) What will be the output from the following Python code snippet?

(a) KAT (b) LKAT (c) TUBKAT (d) KITKAT.


(iv) How can we check whether a key is present in a dictionary?
(a) Using the in keyword (b) Using the has_key() method
(c) Using the key_exists() method (d) Using the contains() method.
(v) The default mode for opening a file with open() is
(a) rt (b) rb (c) wt (d) wb
(vi) Which of the following is the correct way to write a string ‘Hello, MCA’ to a file in
Python?
(a) [Link](‘Hello, MCA’) (b) [Link](‘Hello, MCA’)
(c) [Link](‘Hello, MCA’) (d) [Link](‘Hello, MCA’).
(vii) Correct way of inheriting a derived class from a base class is
(a) class Base(Derived) (b) class Derived(Base)
(c) class (Base) Derived (d) class (Derived) Base.

1
(viii) Which among the following does not support slicing?
(a) String (b) List (c) Tuple (d) Set.
(ix) What will be the output from the following Python code snippet?

(a) [3 7] (b) [1 2 7] (c) [2 7] (d) [1 2 5 6].


(x) Which among the following statements is false?
(a) When defining a function, a default value can be specified for a parameter.
(b) The default value of a function parameter is evaluated at the time the
function is defined.
(c) The default value of a function parameter is evaluated only once.
(d) The default value of a function parameter is evaluated during function call.
Fill in the blanks with the correct word
(xi) The __________ method updates a set with the union of itself and others.
(xii) Every package in Python is a directory which must have a file called __________.
(xiii) Anonymous functions can be created with the __________ keyword.
(xiv) If a function does not have an explicit return value, the value returned by the
function is __________.
(xv) The base class of all exceptions is __________.

Group - B

2. (a) What is the importance of indentation in Python scripts? [(CO1)(Understand/LOCQ)]


(b) Workout the output from the following code snippet with explanation

[(CO3)(Analyze/IOCQ)]
(c) Write a Python script that accepts an integer from a user, and prints the number
of digits in the integer and also the sum of the digits of the integer. The script
should only do the said calculation if the input is an integer, else report to the
user “Input must be an integer”. [(CO1,CO3)(Apply/IOCQ)]
2 + 4 + 6 = 12

3. (a) Explain with a relevant example the utility of having an else block associated
with a loop. [(CO3)(Understand/LOCQ)]
(b) Write a Python script to print the following pattern
of alphabets, where the no. of rows is user input. It
should only print the pattern if the user input is
odd.
E.g. for no. of rows=7, the pattern is
[(CO1, CO3)(Apply/IOCQ)]
4 + 8 = 12
2
Group - C

4. (a) What is deep copy of a list? How is it different from shallow copy? What happens
when a list having a nested list undergoes shallow copy? [(CO2)(Understand/LOCQ)]
(b) The [Link]() method counts the number of non-overlapping occurrences of a
specified substring in a string. e.g., if myStr = ‘Banana’, [Link](‘an’) returns
2, but [Link](‘ana’) returns 1. Write a Python script that includes the
overlapping cases also. [(CO2)(Apply/IOCQ)]
(c) Explain packing and unpacking of tuples with suitable examples.
[(CO2)(Apply/IOCQ)]
(1 + 1 + 2) + 5 + 3 = 12

5. (a) Can a dictionary have a list as a key or a value? Can it have any tuple as a key?
[(CO2)(Analyse/IOCQ)]
(b) Use a dictionary to count the frequency of words in an input string. Only words
should be counted, not blank spaces, numbers, or punctuation. Upper case
should be considered the same as lower case. [(CO2)(Apply/IOCQ)]
(c) Sort a list of roll numbers by the last three digits of the roll number.
For example, if sample input is
[20223005, 20222342, 20229000, 20220002, 20222345, 20229329], then, the
output should be
[20229000, 20220002, 20223005, 20229329, 20222342, 20222345]
[(CO2)(Apply/IOCQ)]
(1 + 2) + 5 + 4 = 12

Group - D

6. (a) Why is super() used in object oriented programming with Python? What are the
alternatives to the use of super()? When is it recommended to use super()
instead of its alternatives?. [(CO4)(Understand/LOCQ)]
(b) Explain with a suitable example multiple inheritance in Python. [(CO4)(Apply/IOCQ)]
(2 + 1 + 2) + 7 = 12

7. (a) List three common exception types and mention when they occur.
[(CO4)(Remember/LOCQ)]
(b) Write Python scripts that imports re and achieves the following:
(i) accept a mobile number as input, and if it starts with 00, replace the 00 with
91.
(ii) takes a word as input and satisfy the requirements that it should be of 5
letters, starts with ‘c’ and ends with ‘r’. [(CO4)(Apply/IOCQ)]
(c) What are modules and packages in Python? When are module-level code
executed? How do we execute a function of a module, only when the module is
executed as a script, but not when it is being imported? [(CO4)(Understand/LOCQ)]
3 + (2 + 2) + (2 + 1 + 2) = 12

3
Group - E

8. (a) Use NumPy to randomly generate an array with 250 values, where the mean is
120, and the standard deviation is 12. Use Matplotlib to create a histogram on
that generated data. [(CO6)(Apply/IOCQ)]
(b) What is pickling and unpickling in Python? Explain with relevant examples.
[(CO5)(Understand/LOCQ)]
(c) Explain with example(s) the working of the seek() method on a file object.
[(CO5)(Understand/LOCQ)]
(2 + 2) + 5 + 3 = 12

9. (a) Given a dictionary of lists containing data in the following format

(i) Create a dataframe and


(ii) select all rows in which ‘Percentage’ is less than 80
(iii) select all rows where ‘Stream’ is ‘Chemistry’ or ‘Geography’
(iv) select 3 minimum marks from the dataset. [(CO6)(Apply/IOCQ)]
(b) Write a Python script to find the number of characters, words, and lines in a file.
[(CO5)(Apply/IOCQ)]
6 + 6 = 12

Cognition Level LOCQ IOCQ HOCQ


Percentage distribution 32.29 67.71 0

Course Outcome (CO):

After the completion of the course students will be able to


CO1: Develop simple Python programs using Python statements and expressions.
CO2: Demonstrate use of lists, tuples, sets and dictionaries to represent compound data.
CO3: Explain control flow and functions in Python for solving problems.
CO4: Articulate object-oriented programming concepts such as encapsulation, inheritance and polymorphism as used in
Python.
CO5: Illustrate the commonly used operations involving file systems handling in Python.
CO6: Explore Python libraries like NumPy, Matplotlib and Pandas for mathematical functions, visualization, and data access.

*LOCQ: Lower Order Cognitive Question; IOCQ: Intermediate Order Cognitive Question; HOCQ: Higher Order Cognitive Question.

You might also like