Professional Documents
Culture Documents
Answer Sheet
PRN: 21030122043
___________________________________________________________________________
Instructions: Save file in your record and give file name as mentioned below:
PRN_Seat Number_Course name in full form_Programme
Q1)
c) Accept a number N and display all the EVEN factors of the number N.
g)
character = 'M'
a = ord(character)
print('The ASCII value of letter M is', a)
for j in range(65,a+1):
print(chr(j))
Page 1 of 5
F ) Write a function, which accepts a string as a parameter and returns how
many times
vowel ‘a’ occurs in the string.
for i in str:
if i in letter:
sum += 1
print("vowel a is repeating:", sum ,"many times")
lis = [a,b,c,d,e,f,g,h,i,j]
lis.sort()
D) Accept a numbers N1. Pass N1 to a user defined function, which returns the sum of
digits of N1.
Page 2 of 5
def Sum(n):
sum = 0
while (n != 0):
return sum
2) Python’s list pop(): This function removes and returns the final value from
a List or the supplied index value. The value at index is popped out and re-
moved using the parameter index (optional). The last element is popped out and
eliminated if the index is not provided.
For example :
numbers = [2, 3, 5, 7, 9]
element = numbers.pop(2)
print('Removed Element:', element)
print('Updated List:', numbers)
find() is a Python library function that returns the index of a substring's first oc-
currence from a specified string. If find() fails to discover the substring, it re-
turns -1 rather than throwing an exception.
Page 3 of 5
For example :
The set Union() function in Python creates a new set with all of the items from
the original set.
For example :
The smallest set that contains all of the items of two given sets is the union of
the two sets. A set consisting of all the elements of A and all the elements of B
with no element duplicated is called a union of two given sets A and B.
f) is operator :
Python operator “is” used to check whether a value exist in a set of value .
They're used to see if two values (or variables) are in the same memory loca-
tion. The fact that two variables are equal does not mean they are identical.
Eg – 10 is (1,2,3,4,5)
Output - false
Page 4 of 5
Page 5 of 5