22CS2ESPYP
22CS2ESPYP
Instructions: 1. Answer any FIVE full questions, choosing one full question from each unit.
2. Missing data, if any, may be suitably assumed.
3. Write expected output for all programs
UNIT - I CO PO Marks
Important Note: Completing your answers, compulsorily draw diagonal cross lines on the remaining
b) CO2 PO2 6
relevant explanation along with the final output.
i=0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
c) Define operator and operand. List all Arithmetic, Comparison and CO1 PO1 8
Logical operators used in Python with example
UNIT – II
2 a) Illustrate the following string methods with a relevant example CO1 PO1 4
i) len() ii)capitalize() iii) upper() iv) strip()
b) Develop a python program that inputs list elements from user and CO3 PO3 6
makes a new list that has only the even elements of this list in it.
c) Develop a Python Program to input a string to check whether it is CO3 PO3 6
a Palindrome string or not.
d) a=[‘hello’, ‘how’, [1,2,3], [[10,20,30]]] CO2 PO2 4
Analyze the above statement and predict the output for following
commands
(i) print( a[ : : ] )
(ii) print(a[-3][0])
(iii) print(a[2][ : -1])
(iv) print(a[0][ : : -1])
UNIT – III
3 a) Summarize functions in python with syntax for function definition CO1 PO1 8
and a relevant example.
b) Develop a python code to count the number of characters in the CO3 PO3 6
string and store them in a dictionary data structure.
c) Illustrate the difference between lists, tuples and dictionaries. CO1 PO1 6
OR
4 a) Elucidate tuple by demonstrating the creation of a single element CO1,3 PO1,3 7
in a tuple and develop a python program to find the common
elements between two tuples.
b) Analyze the below code which demonstrates user defined function CO2 PO2 6
to interchange first and last elements in a list. Complete the code
by filling in the missing values marked as “?” and explain the code
along with the expected output.
# Swap function
? swapList(List1):
size = ?(List1)
# Swapping
temp = List1[?]
List1[?] = List1[?]
List1[?] = temp
return List1
list1=[1,2,3,4,5]
list2=swapList(?)
print(list?)
c) Develop a program that combines two lists into a dictionary CO3 PO3 7
without using builtin function “zip”.
UNIT - IV
5 a) Create a class Employee to have the following: CO3 PO3 10
• Variables: emp_id, designation
• A constructor to initialize these values
• A method salary_calc that accepts basic salary as
parameter, adds 10000 if designation is “clerk” and adds
12000 if designation is “Manager”.
******