Unit 3 Previous Year Paper
Unit 3 Previous Year Paper
**************************************
[2]. What are different methods used in deleting elements from dictionary ?
[6]. An email address is provided : [email protected] . Using tuple assignment , split the username
and domain from the email address.
[7]. Write a function called sumall that takes any number of arguments and returns their sum.
[9]. What are the types of arguments used for calling a function ?
x , y , z = 1 ,2 , 3 #s1
a , b = 4 ,5 ,6 #s2
u = 7, 8 ,9 #s3
x[0]* = 3
def cube(x) :
return x * x * x
x = cube(3)
print (x)
print(char , num)
return
vowels = "AEIOUaeiou"
count = 0
for c in s :
if c in vowels :
count + = 1
return count
print ("@".join(list1))
def count(s) :
return s
[1]. Demonstrate five different built in functions used in the string. Write a program to check
whether a string is a palindrome or not .
[2]. Discuss list data structure of python . Explain various inbuilt methods of list with suitable
examples of each.
[4]. Write a function lessthan (lst , k) to return list of numbers less than k from a list lst . The
function must use list comprehensions .
Example :
[7]. Compare list and dictionary data structure. Explain various dictionary methods with suitable
examples of each.
[8]. How can you randomize the items of a list in place in Python ?
[9]. Discuss the different types of argument-passing methods in Python . Explain the variable length
argument with any suitable example .
[10]. Show an example where both keyword arguments and Default arguments are used for the same
function in a call . Show both the definition of the function and its call.
[11]. Discuss functions in Python with its parts and scope . Explain with example. (Take simple
calculator with add , subtract , division and multiplication .)
[12]. Write a Python function removekth(s,k) that takes as input a string 'a' and an integer k >= 0 and
removes the character at index 'k' . If 'k' is beyond the length of 's' , the whole of 's' is returned. For
example :
[14]. Write a function makePairs that takes as input two lists of equal length and returns a single list
of same length where k-th element is the pair of k-th elements from the input lists. For example ,
makePairs([1,3,5,7] , [2,4,6,8])
makePairs([ ] , [ ])
returns [ ]
[15]. Explain higher-order function with respect to lambda expression. Write a Python code to count
occurrences of an element in a list.
[16]. Write a Python function , searchMany(s,x,k), that takes as argument a sequence s and integers
'x' , 'k' (k > 0). The function returns True if there are at most 'k' occurances of ' x ' in ' s ' .Otherwise, it
returns False . For example :