0% found this document useful (0 votes)
7 views4 pages

Unit 3 Previous Year Paper

The document contains a series of previous year questions divided into short answer and long answer sections, focusing on Python programming concepts. Topics include string manipulation, data structures like lists and dictionaries, function definitions, and various built-in methods. It also includes programming tasks that require writing functions and explaining concepts with examples.

Uploaded by

sattyam349
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)
7 views4 pages

Unit 3 Previous Year Paper

The document contains a series of previous year questions divided into short answer and long answer sections, focusing on Python programming concepts. Topics include string manipulation, data structures like lists and dictionaries, function definitions, and various built-in methods. It also includes programming tasks that require writing functions and explaining concepts with examples.

Uploaded by

sattyam349
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/ 4

Unit - 03 (Previous Year Questions)

**************************************

# Short Answers (2 Marks)

[1]. Define traversing of string . Give an example.

[2]. What are different methods used in deleting elements from dictionary ?

[3]. What are two properties of keys in dictionary ?

[4]. What are user-defined functions ? Give the syntax .

[5]. Define the return statement in a function. Give the syntax .

[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.

[8]. Give an examples for len , max , and min methods.

[9]. What are the types of arguments used for calling a function ?

[10]. What is slicing ? Also define the docstring in function .

[11]. What is the difference between list and tuples in Python ?

[12]. What are differences between Python arrays and lists ?

[13]. Which of the following statements produce an error in Python ?

x , y , z = 1 ,2 , 3 #s1

a , b = 4 ,5 ,6 #s2

u = 7, 8 ,9 #s3

[14]. Consider the program :

x = [ '12' , 'hello' , 456]

x[0]* = 3

x[1] [1] = 'bye'

Explain why this program generates an error.

[15]. What will be the output of the following Python code ?

def cube(x) :

return x * x * x

x = cube(3)
print (x)

[16]. Explain the output of the following function .

def printalpha (abc_list , num_list) :

for char in abc_list :

for num in num_list :

print(char , num)

return

print(['a' , 'b' ,'c'] , [1 , 2, 3])

[17]. Describe the concept of List Slicing with a suitable example.

[18]. Explain the difference between 'append' and 'extend' in Python ?

[19]. What will be the output of the following Python code :

def count_1 (s) :

vowels = "AEIOUaeiou"

count = 0

for c in s :

if c in vowels :

count + = 1

return count

print (count1 ('I love India'))

[20]. What will be the output of the following code ?

list1 = [ 'M' ,'n' , 'k' , 'y' ]

print ("@".join(list1))

[21]. Compare list and Dictionary data structure .

[22]. What is Dictionary in Python ?

[23]. What are local variables and global variables in Python ?

[24]. Describe the concept of list comprehension with a suitable example.

[25]. What will be the output :

def count(s) :

for str in string.split() :


s = "&".join(str)

return s

print(count("Python is fun to learn. "))

# Long Answer (7 Marks )

[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.

[3]. Explain the list comprehension with any suitable example .

[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 :

lessthan ([1, -2, 0, 5, -3], 0 ) returns [ -2 , -3 ]

[5]. Defines tuples . How are tuples created in Python ?

[6]. Write a Python program to add an item in a tuple.

[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 :

removekth ("PYTHON" , 1) returns "PTHON"

removekth ("PYTHON" , 3) returns "PYTON"

removekth ("PYTHON" , 0) returns "YTHON"

removekth ("PYTHON" , 20) returns "PYTHON"


[13]. Write a Program factors(N) that returns a list of all positive divisors of N (N >=1) . For Example :

factors(6) returns [1,2,3,6]

factors(1) returns [1]

factors(13) returns [1,13]

[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])

returns [(1,2) , (3,4) , (5,6) , (7,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 :

searchMany ([10 , 17 , 15, 12] , 15 , 1) returns True

searchMany ([10 , 12, 12 , 12] , 12 , 2) returns False

searchMany ([10 , 11 , 15, 12] , 10 , 1) returns True

You might also like