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

QB Mod2

This document contains a question bank for the Introduction to Python Programming course with 43 questions related to Python lists, tuples, and dictionaries. The questions cover list and tuple operations like slicing, traversing, inserting, deleting elements as well as dictionary operations like accessing, updating keys and values. Students are asked to write programs demonstrating the use of various Python data structures and their methods.
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)
36 views3 pages

QB Mod2

This document contains a question bank for the Introduction to Python Programming course with 43 questions related to Python lists, tuples, and dictionaries. The questions cover list and tuple operations like slicing, traversing, inserting, deleting elements as well as dictionary operations like accessing, updating keys and values. Students are asked to write programs demonstrating the use of various Python data structures and their methods.
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

KVG COLLEGE OF ENGINEERING, SULLIA, D.K.

DEPARTMENT OF CIVIL ENGINEERING


Module 2 Question Bank
Course Name: Introduction to Python Programming Course Code: BPLCK105/205B
Semester/Section: II
Academic Year: 2023-24
Course
Coordinator: Prof. AJITH B T
Q.No. Questions RBT CO
1 What is list? Explain append (), insert () and remove () methods with examples. L2 CO2
2 What is a list? Explain the concept of list slicing and list traversing with example L2 CO2
3 Discuss the methods that are used to delete items from the list L2 CO2
4 Write a program to create a list of number and display the count of even and odd L2 CO2
number in the list
5 Lists are Mutable. Justify the statement with examples. L2 CO2
What are the different ways of deleting elements from a list? Discuss with
6 L2 CO2
suitable functions.
Give the differences between
7 L2 CO2
a. append () and extend ()
pop () and remove ()
8 Explain the use of in and not in operators in list with suitable examples. L2 CO2
9 Explain the following methods in list with an example. L2 CO2
i. len()
ii. sum ()
iii. max ()
min ()
10 When do we encounter TypeError, ValueError and IndexError while operating L2 CO2
on Lists?
11 Write a Python Program that creates a list of 10 integers. Then create two lists- L3 CO2
Odd List and Even List that has all odd and even values in the list respectively
12 Consider the list scores = [5, 4, 7, 3, 6, 2, 1] and write the python code to L2 CO2
perform the following operations:
i) Insert an element 9 at the beginning of the list. ii) Insert an
element 8 at the index position 3 of the list.
ii) Insert an element 7 at the end of the list.
iii) Delete all the elements of the list.
iv) Delete an element at the index position 3.
Delete an element at the beginning of the list.
13 For the following three questions, let’s say spam contains the list ['a','b', 'c', L2 CO2
'd',[3,4]].
i. What does spam[int('3' * 2) / 11] evaluate to?
ii. What does spam[-2] evaluate to?
iii. What does spam[4][1] evaluate to?
For the following three questions, let’s say bacon contains the list [3.14, 'cat', 11,
14 L2 CO2
'cat', True].
i. What does bacon.index('cat') evaluate to?
ii. What does bacon.append(99) make the list value in bacon look like?
iii. What does bacon.remove('cat') make the list value in bacon look like?
15 Develop a program to find mean, variance and standard deviation. L2 CO2
16 Write a Python Program that counts the number of times a value appears in the L2 CO2
list without using built in function.
17 Write Python program to swap two numbers using functions. (Write without L3 CO2
using intermediate/temporary variables). Prompt the user for input
18 Write a Python Program that creates a list of 20 numbers and then create a list L3 CO2
that contains all the numbers from the original list that are divisible by 3
19 Describe any two list operations and list methods. Write a python program to L2 CO2
accept ‘n’ numbers from user. Find sum all even numbers and product of all odd
numbers in entered list
How tuple is different from a list and which function is used to convert list to
20 L2 CO2
tuple
Explain the concept of comparing tuples. Describe the working of sort function
21 L2 CO2
with python code
22 How do you create a tuple using a string and using a list? Explain with example. L2 CO2
23 How do you create an empty tuple and a single element tuple L2 CO2
Compare and contrast tuples with lists. Explain the following operations in
24 L2 CO2
tuples
i. Sum of two tuples
ii. Slicing operators
iii. Compression of two tuples
Assignments to variables
25 How tuples can be used as a key for dictionaries? Discuss with example. L2 CO2
26 Demonstrate how dictionary items can be represented as list of tuples L2 CO2
27 Create a function to print out a blank tic_tac_toe board. L2 CO2
28 Explain get () and setdefault () method in a dictionary. L2 CO2
What is dictionary? How it is different from List? Write a program to count the
29 L2 CO2
number of occurrences of character in a string
Discus get (), item (), keys () and values () Dictionary methods in python with
30 L2 CO2
examples.
What are Dictionaries? Explain with examples how the dictionaries are created.
31 L2 CO2
Differentiate between Key and value of the Dictionary element. Mention the
properties of Key. Discuss the following Dictionary operations and functions
with examples
1. Accessing, Traversing, Updating, Deleting
2. Traversing a Dictionary using looping
32 Write a program to demonstrate the use of pretty function. L2 CO2
33 With example program illustrate how the Dictionary can be used as counters L2 CO2
What is the difference between copy. copy () and copy. deepcopy () function
34 L2 CO2
applicable to a list or Dictionary in python? Give suitable example for each.
How is the dictionary different from list? Assume a dictionary containing city
35 L2 CO2
and population as key and value respectively. Write a program to traverse the
dictionary and display most populous city.
36 List merits of dictionary over list. Write a python program to accept USN and L2 CO2
marks obtained. Find maximum, minimum and students USN who have scored
in the range 100-85, 85-75,75-60 and below 60 marks separately
What is dictionary? How is it different from list? Write a python program to
37 L3 CO2
count occurrence of characters in a string and print the count
38 Write a Python program to get the maximum and minimum value in a dictionary L3 CO2
Write a Python program to get the top three items in a shop. Sample data:
39 L3 CO2
{'item1': 45.50, 'item2':35, 'item3': 41.30, 'item4':55, 'item5': 24}
Expected Output:
item4 55
item1 45.5
item3 41.3
40 Consider a dictionary with strings as keys and numbers as values. Write a L3 CO2
program to sort the elements of this dictionary based on keys.
Read a string from keyboard input. Create a list containing tuples, where each
41 L3 CO2
tuple represents a word in the input string and length of that string. Write a
program sort the words in descending order of their length
42 If S= ‘Hello World’, explain and write the output of the following statements.\: L2 CO2
S[1:5] ii.S[:5] iii.S[3:-1] ivS[:]
Write a Python program to add 'ing' at the end of a given string (length should be
43 L3 CO2
at least 3). If the given string already ends with 'ing' then add 'ly' instead. If the
string length of the given string is less than 3, leave it unchanged
i. Sample String : 'abc' Expected Result : 'abcing'
ii. Sample String : 'string' Expected Result : 'stringly‘

You might also like