RN SHETTY TRUST®
RNS INSTITUTE OF TECHNOLOGY
Autonomous Institution Affiliated to Visvesvaraya Technological University, Belagavi
Approved by AICTE, New Delhi, Accredited by NAAC with 'A+' Grade
Channasandra, Dr. Vishnuvardhan Road, Bengaluru - 560 098
Ph: (080) 28611880, 28611881 URL: [Link]
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
Question Bank
SUBJECT CODE AND TITLE BPLCK105B, Python Programming
SCHEME 2025 - 26 BATCH 2025-29
SEMESTER & SECTION I Semester
FACULTY NAME Ms. Sushma A
[Link]. Question Marks RBT* COs
Module 1
Explain what a program is with a suitable example. Define debugging and
1 6 L2 CO1
describe the three types of program errors."
Write a Python program to print all numbers from 1 to 20 using a for loop.
Skip the numbers divisible by 3 and stop the loop if a number greater than
2 6 L3 CO1
15 is encountered. Use range(), continue, and break statements
appropriately."
4 Explain logical operators with examples. 3 L2 CO1
5 Explain rules and constraints for defining variable names with examples. 3 L2 CO1
Explain the concept of conditional execution in Python using the if, elif,
and else statements.
6 8 L2 CO1
Describe how these statements help in decision-making with the help of
a suitable example
Explain the working of the following Python code snippets and Draw
flowcharts representing the flow of control in the program.
i) num = int(input("Enter a number: "))
if num % 2 == 0:
print("The number is even.")
else:
7 6 L2 CO1
print("The number is odd.")
ii)num = 1
while num <= 10:
print(num, end=' ')
num += 1
Explain functions in Python — definition, arguments, return values, and
8 10 L2 CO1
composition — with examples.
Write a Python program that uses nested loops to print a 2D
9 10 L2 CO1
multiplication table. Explain step by step.
Convert the following English statement into a Boolean expression in
10 Python and explain your reasoning: 4 L2 CO1
“A student passes if marks ≥ 40 and attendance ≥ 75.”
Describe the difference between = and == operators in Python with
11 4 L2 CO1
examples.
Write a Python program to generate the Collatz sequence for any
positive integer entered by the user. The program should repeatedly
apply the following rules until the number becomes 1:
• If the number is even, divide it by 2.
12 8 L3 CO1
• If the number is odd, multiply it by 3 and add 1.
Display each number in the sequence on the same line separated by
commas."
Given a list of students and their subjects, write a nested loop to count
13 how many students take “CompSci”. Extend the code to skip any 6 L2 CO1
students with no subjects using the continue statement
a. Develop a Python program to generate Fibonacci sequence of
length (N). Read N from the console.
b. Write a python program to create a list and perform the
following operations
• Inserting an element
14 8 L3 CO1
• Removing an element
• Appending an element
• Displaying the length of the list
• Popping an element
• Clearing the list
Differentiate between break and continue statements. Provide suitable
15 6 L2 CO1
examples to show how control flow differs when each is executed.
Write and explain a Python program that uses if–elif–else structure to
16 determine the grade of a student based on marks. Discuss how execution 6 L2 CO1
flows through the conditions.
Write a Python Program to
a. Read N numbers from the console and create a list. Develop a
program to print mean,variance and standard deviation with
17 suitable messages. 8 L3 CO1
b. Read a multi-digit number (as chars) from the console. Develop
a program to print the
frequency of each digit with a suitable message.
Describe how the continue statement works inside a for or while loop.
18 Write a small program to display only even numbers between 1 and 10 6 L2 CO1
using continue.
Evaluate the following expressions step-by-step showing operator
precedence and associativity rules: Compare both outputs and justify the
difference.
19 6 L2 CO1
result = 10 + 2 * 3 ** 2
result2 = (10 + 2) * 3 ** 2
Write a python program to read 2 numbers from the keyboard and
perform the basic arithmetic operations based on the choice. (1-Add, 2-
Subtract, 3-Multiply, 4-Divide.
b. Develop a program to read the name and year of birth of a person.
20 8 L3 CO1
Display whether the person is a senior citizen or no.
c. Write a python program to add 10 numbers by inputting each from the
keyboard using for loop
2
[Link]. Question Marks RBT* COs
Module 2
1. L2 CO2
Explain the purpose and working of the following list methods in Python
with suitable examples and output:
append(), insert(), count(), extend(), index(), reverse(), sort(), and 8
remove().
Describe how each method affects the list.
3. Explain List of Tuples and Tuple of Lists. How do you create an empty 8 L2 CO2
tuple and a single element tuple?
4. Write a program in python to search and replace multiple occurrences of L2 CO2
a substring in a main string. 4
5. Illustrate with example, how string can be traversed using slicing L2 CO2
4
operator.
6. Explain how tuples help in returning multiple values from a Python L2 CO2
2
function with the help of the circle_stats(r) function.
7. Describe how composability and heterogeneity are demonstrated. Explain L2 CO2
with examples how tuples and lists are combined to represent complex 6
real-world information.
8. Explain the purpose and working of the following string methods in L2 CO2
Python
With suitable example
6
upper(), lower(), find(), split(), join(), and format().
Describe how each method transforms or operates on a string.
9. Explain the difference between mutable and immutable data types in L2 CO2
4
Python with examples.
10. Explain the use of in and not in operator in strings with example. L2 CO2
2
11. Write a function count_char(word, ch) that counts how many times a
character appears in a string without using .count(). 6 L3 CO2
Apply it on "banana" to count occurrences of 'a'.
12. Write a Python program to:
Create a tuple containing a student’s name, roll number, and marks.
Unpack the tuple into individual variables and display them. 8
L3 CO2
Then, pack new data into another tuple and print both tuples.
Explain how tuple packing/unpacking helps in returning multiple values.
13. Define a custom function my_find(haystack, needle) that returns the
index of the first occurrence of a character needle inside string haystack
(like the built-in find() method). L3
If not found, return -1. 8 CO2
Apply your function to the string "Bananarama" for the character 'a'.
Also compare the result with the built-in find() method.
14. Create a tuple student = ("Alice", 20, "CSE").
Unpack it into three variables and print them separately.
Then, using tuple assignment, swap two numbers a and b without using 8
L3 CO2
3
a temporary variable.
Show the output before and after swapping.
15. Write a Python function count_vowels(text) that counts how many
vowels are present in a given string.
Use a for loop to traverse each character and an if condition to check for
membership.
Also print the number of vowels and consonants separately for the word 6 L3 CO2
"banana”
16. Write a program that:
i)Creates a list nums = [1,2,3,4,5].
ii)Replaces the middle three elements with [10,20,30] using slicing.
iii)Prints the updated list.
L3 CO2
17. Explain how slice assignment differs from normal indexing. 8
Given the nested list:
students = [
("John", ["CompSci", "Physics"]),
("Vusi", ["Maths", "CompSci", "Stats"]),
("Jess", ["CompSci", "Accounting", "Economics", "Management"]),
] L3
CO2
Write a program to count how many students are taking "CompSci".
Create an empty list nums.
Add numbers 5, 10, 15, 20 using append() and insert() methods.
Then perform the following:
L3
19 8 CO2
• Reverse the list
• Sort it
• Remove one element
• Display the list after each operation and explain the purpose of
each method used.
4
20. Consider the following nested list used to represent a matrix: L2 CO2
mx = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
(a) Write Python statements to: 6
1. Display the first row of the matrix.
2. Display the last element of the second row.
3. Display the middle element of the matrix (value 5).
21. Write a function double_stuff(values) that modifies the list by doubling L2 CO2
each element.
Use the list [2, 5, 9] and show the result before and after function 8
execution.
Explain whether this function is a modifier or a pure function.
22. Develop a Python program to read 6 subject marks from the keyboard
for a student. Generate a report that displays the marks from the highest L3 CO2
to the lowest score attained by the student. [Read the marks into a 1- 6
Dimesional array and sort using the Bubble Sort technique].
[Link]. Question Marks RBT* COs
Module 3
What is a dictionary in Python? Explain how it differs from a list with
1 2 L2 CO3
suitable examples.
2 What are dictionary operations? Give examples of any two. 3 L2 CO3
3 Explain aliasing and copying in dictionaries with examples. 4 L2 CO3
Course Co-ordinator Module Co-ordinator Program Co-
ordinator/HOD