Model Question Paper- I with effect from 2023-24
USN
DAYANANDA SAGAR ACADEMY OF TECHNOLOGY & MANAGEMENT
(An Autonomous Institute under VTU, Belagavi)
Third Semester B.E Semester End Examination – December 2024
Course: Python Programming
Course Code: BAI303
Max Marks: 100 Duration: 03 Hours
Note:
Answer any FIVE full questions, choosing at least ONE question from each MODULE
Module - 1 Marks BL CO
a Explain Local and Global Scopes in Python programs. What are local 6 L1 / CO1
and global variables? How can you force a variable in a function to refer L2
Q.1 to the global variable?
b What is an arithmetic expression? What is the output of this statement
7 L3 CO2
“hello world” + 100 + “how are you” explain the reason if the statement
produces an error.
Explain the syntax of user-defined functions in python. Write a user L3 CO2
c 7
defined function to find the sum of three numbers
OR
Explain how to end a Python program early using [Link](). Write a
a 6 L1 / CO1
program that uses this function and explain its behavior.
L2
Q.2 Explain looping control statements in Python with a syntax and example
b 7 L1 / CO1
to each
L2
Define exception handling. How exceptions are handled in python?
c Write a program to solve divide by zero exception 7 L3 CO2
Module – 2
Define list. Write a python program for the following:
a 7 L1 / CO1
a. Accessing list elements L2
b. Adding new values to list.
Q.3 c. Deleting list element
For a = [‘hello’, ‘how’, [1,2,3], [[10,20,30]]] what is the output of
b 7 L3 CO2
following statement
(i) print( a[ : : ] )
(ii) print(a[-3][0])
(iii) print(a[2][ : -1])
(iv) print(a[0][ : : -1])
How do you iterate over the keys and values of a dictionary? Provide a
c 6 L3 CO2
Python program that demonstrates this iteration.
OR
How can you sort the elements of a dictionary by keys or values? Write a
a 7 L3 CO2
Python program that sorts a dictionary by its values.
Model Question Paper- I with effect from 2023-24
What is dictionary? Illustrate with an example python program the usage
b 7 L1 / CO1
Q.4 of nested dictionary
L2
c Analyze the difference between append() and extend() functions with
6 L4 CO3
respect to lists in Python
Module – 3
Discuss different paths of file system.
a 6 L4 CO3
Explain how to read specific lines from a file? Illustrate with python
program.
Q5
What are the key properties of a file? Explain in detail file reading/writing
b 7 L3 CO2
process with an example of python program
Explain the following Python string handling methods with examples:
c 7 L3 CO2
split(), endswith(), ljust(), center(), lstrip()
OR
Explain how to check for substrings within a string in Python. Write a
a 6 L3 CO2
Python program that checks if a word is present in a given string.
Q.6 Develop a Python program to traverse the current directory by listing
b subfolders and file 7 L3 CO2
Using string slicing operation write python program to reverse each word
c 7 L3 CO2
in a given string (eg: input: “hello how are you”, output: “olleh woh era
uoy”). Also write the string method to that can be used to perform the
same operation
Module – 4
What is logging? How this would be used to debug the python program?
a 6 L1 CO1
Develop a Python program find the total size of all the files in the given
Q.7 b directory. 7 L3 CO2
Develop a program to backing Up a given Folder (Folder in a current
c working directory) into a ZIP File by using relevant modules and suitable 7 L3 CO2
methods
OR
What are exceptions in Python? How do you raise an exception manually
a 6 L1 CO1
using the raise statement? Provide an example.
Explain how to enable and disable assertions in Python. What is the impact
b 7 L1 CO1
Q.8 of disabling assertions on your code?
Write a python program to create a folder PYTHON and under the
c hierarchy 3 files file1, file2 and [Link] the content in file1 as ”VTU” 7 L3 CO2
and in file2 as “UNIVERSITY” and file3 content should be by opening
and merge of file1 and file2. Check out the necessary condition before
write file3
Module – 5
What is array flattening in NumPy? How can you flatten a
a multidimensional array into a 1D array? Provide a code example 7 L1 CO1
Q.9 Write a Python program to load data from a CSV file into a Pandas
b DataFrame, display the first two rows and computes basic statistics (e.g., 6 L2 CO2
mean, median, sum) for numerical columns in a Pandas DataFrame.
What are advanced plotting techniques like histograms, box plots, and
c heatmaps? Provide examples of creating each type of plot using 7 L3 CO2
Matplotlib.
Model Question Paper- I with effect from 2023-24
OR
Discuss the significance of NumPy's [Link]() function. Provide an
a example of how it can be used for conditional selection in arrays. . 7 L1 CO1
Q.10 Explain how to group data in a Pandas DataFrame using the groupby()
b function. Provide an example that groups data by a specific column and 6 L2 CO2
computes aggregate statistics.
How can you customize plots in Matplotlib by adding titles, labels, and
c legends? Write a Python program that demonstrates these customizations. 7 L3 CO2
***