0% found this document useful (0 votes)
15 views3 pages

Adobe Scan 08 Oct 2024

Uploaded by

ck2842816
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)
15 views3 pages

Adobe Scan 08 Oct 2024

Uploaded by

ck2842816
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
You are on page 1/ 3

U.S.N.

LaMal9llalo
B.M.S. College of Engineering, Bengaluru-560019
Autonomous Institute Afffliated to VTU

July / August 2024 Semester End Main Examinations


Programme: B.E. Semester: I/II
Branch: Common to all Branches Duration: 3 hrs.
Course Code: 22CSIESPYP /22CS2ESPYP Max Marks: 100
Course: Introduction to Python Programming

Instructions: 1. Answer any FIVE full questions, choosing one full question from ach unit.
2. Missing data, if any, may be suitably assumed.
the
remaining
blank
UNIT - I CO PO Marks
a) Predict the output and justify the answer: CO1 PO1 08
i) -11%9 ii) 7.7/I7 ii) (200-7) *10/5 iv) not "falae"
) 5*1**2
cross
lines
on Give the general syntax of while loop iñpythonDesign a Python
malpractice. b) CO1,3 PO13 06
program to calculate the sum of numbers until the user enters 0.
(using While loop)
Develop a Python program tÛnd the largest of three numbers. CO3 PO3 06
diagonal
as
treated UNIT - II
draw 2 a)
compulsorily What is a list? Explain insert0, index) and extend) methods COI PO1
07
be with examples
will
b) Design a PythÓnprogranm thattakes a list of strings as input. The CO3 PO3 06
evaluator program should pèrfom the following tasks:
i. Sort the li_t in ascending order of string length.
i i ftwo strings have the same length, sort them alphabetically
yourto
answers, in asceHding order.
appeal ii,Output the sorted list
c) Jlústrate the use of find) and replace) string methods with CO1,3 PO1,3 07
identification,
Pxamples. Develop a Python program that accepts a hyphen
Completing separated sequence of words as input and prints the words in a
hyphen-separated sequence after sorting them alphabetically.
UNIT - II
ofRevealing
pages.
Note: a) What are tuples in Python, and how are they defined? Discuss the COl POI 08
immutability of tuples. Compare dictionaries and tuples in
Important Python.
b) Given a list of elements, develop a program to perform grouping CO3 PO3 06
of similar elements, as different key-value list in dictionary.
Sample Input: testlist = [5, 6, 6, 5, 3, 3, 5, 7, 5, 7,8]
Output: 5: [5, 5, 5], 6: [6, 6], 3: (3, 3], 7: [7, 7], 8: [81}
Design a Python program to unzip a list of tuples into individual CO3 PO3
06
lists.

OR
4 a) Illustrate with an example function call and passing arguments to COI PO1 06
a function in Python.
b) Define a Python function with suitable parameters to generate CO2,3 PO2,3 06
first N Fibonacci numbers. The first two Fibonacci numbers are 0
and 1 and the Fibonacci sequence is defined as a function F as
Fn = Fn-1 + Fn-2. Design a Python program which
value for N (where N >0) as input and pass this value accepts a
to the
function. Display suitable error message if the condition for input
value is not followed.
c) Develop a Python program using a function that takes a list of C3PO3 08
tuples as input, where each tuple contains a student's name a
string) and their scores in different subjects (a variable number of
integers). The program should do the following:
Calculate and print the total score for each studeñt.
Find and print the student with the lowest total
score
s
Find and print the subject with the lowest average score
across all students.

UNIT - IV
5 a) Define class, class variable, instaDe vaiable, method, object. CO1 PO1
05
b) Develop a Python program tô cre¥teaclass Person with member CO3 PO3
08
variables nameand age.Derivè a syb-class Student from Person.
Student has member váriables stud id and marks scored. Create
a Student object. Calculateand display the average marks scored
by the Student.
c) Develop a PythÍn program to overload the 4* operator to CO3 PO3 07
demonstrate the three different operations.
OR

6 a) Dermonstrate with an example how multiple except blocks can be COI POI
08
written foia single try block to handle multiple exceptions.
bDey lop an interactive calculator! User input is assumed to be a CO2,3 PO2,3 12
formula that consists of a number, an operator (at least + and -),
and another number, separated by white space (e.g. 1+ 1).
Split user input using str.split), and check whether the resulting
list is valid:
If the input does not consist of 3 elements, raise a
FormulaError, which is a user-defined Exception,
Try to convert the first and third input to a float (like so:
float_ value = float(str_value). Catch any ValueError that
occurs, and instead raise a FormulaError.
If the second input is not 4 or , again raise a
FormulaError.
If the input is valid, perform the calculation and print out the
result. The user is then prompted to provide new input, and so
on, until the user enters quit.
UNIT -V
a) Explain the re.search) and re.findall) methods of python regular COI PO1
06
expression library with programming examples.
b) Design a program to count the frequency of characters in a given CO3 PO3 06
file.
c) Explain the importance of 'with statement'. Develop a Python|CO
program to reverse the content of a file and store it in another
file. 2 0 2 3 - 2 4

**** **

S E M

- E V E N

B . M S . C . E .

You might also like