AKTU Python Programming Question Paper 2026
This page contains the AKTU B.Tech Python Programming Question Paper 2025–26 for BCC302. The complete question paper is given below along with student-oriented answers and solutions.
The questions are arranged according to the original Section A, Section B and Section C structure. The original question numbering, sub-parts and marks distribution are maintained.
AKTU BCC302 Python Programming Question Paper 2025–26
| Particular | Details |
|---|---|
| Course | B.Tech |
| Semester | III Semester |
| Subject Code | BCC302 |
| Subject | Python Programming |
| Examination | Theory Examination 2025–26 |
| Time | 3 Hours |
| Maximum Marks | 70 |
Question Paper Index
The following is the index of questions included in the AKTU BCC302 Python Programming Question Paper 2025–26.
Section A
| Q. No. | Question | Marks |
|---|---|---|
| 1(a) | What are Python variables? Give an example of declaring numeric data types. | 2 |
| 1(b) | Differentiate between for loop using range and while loop in Python. | 2 |
| 1(c) | Explain string slicing in Python with an example. | 2 |
| 1(d) | What is a tuple in Python? How is it different from a list? | 2 |
| 1(e) | Define dictionary in Python and give an example of its manipulation. | 2 |
| 1(f) | What are read() and readline() functions in file handling? | 2 |
| 1(g) | Explain encapsulation in Python OOP. | 2 |
Section B
| Q. No. | Question | Marks |
|---|---|---|
| 2(a) | Explain Python basic operators and data types. Write a program to check if a number is even or odd using if-else. | 7 |
| 2(b) | Describe loop manipulation statements: pass, continue, break. Write a program to print prime numbers between 1 to 50 using for loop. | 7 |
| 2(c) | Discuss string operations and built-in functions. Write a program to count vowels in a string. | 7 |
| 2(d) | Explain list and dictionary built-in functions. Write a program to merge two dictionaries. | 7 |
| 2(e) | Describe file writing functions: write(), writelines(). Write a program to write student records to a file. | 7 |
Section C
| Q. No. | Question | Marks |
|---|---|---|
| 3(a) | Explain Python blocks and conditional statements. Write a program to grade students based on marks using elif. | 7 |
| 3(b) | Discuss for loops with strings and lists. Write a program to sum elements of a list. | 7 |
| Q. No. | Question | Marks |
|---|---|---|
| 4(a) | Explain functions in Python. Write a function to calculate area of a circle. | 7 |
| 4(b) | Describe string manipulation methods. Write a program to replace characters in a string. | 7 |
| Q. No. | Question | Marks |
|---|---|---|
| 5(a) | Explain sets and their operations. Write a program to find difference between two sets. | 7 |
| 5(b) | Discuss tuple and list slicing. Write a program to reverse a tuple. | 7 |
| Q. No. | Question | Marks |
|---|---|---|
| 6(a) | Explain manipulating file pointer using seek(). Write a program to read last n lines from a file. | 7 |
| 6(b) | Describe regular expressions using re module. Write a program to find all digits in a string. | 7 |
| Q. No. | Question | Marks |
|---|---|---|
| 7(a) | Explain inheritance and polymorphism. Write a program showing multiple inheritance. | 7 |
| 7(b) | Discuss Tkinter widgets. Write a program to create a simple window with a label using Tkinter. | 7 |
AKTU Python Programming Question Paper 2026 – Solutions
The detailed answers to the above questions are given below. Answers are written in simple English and are arranged according to the marks assigned in the question paper.
Section A – Answers
Q1(a) What are Python variables? Give an example of declaring numeric data types.
A variable in Python is a name used to store a value in memory. Python variables do not require explicit declaration of their data type. The type is determined automatically from the value assigned to the variable.
Example:
age = 20
marks = 85.5
print(age)
print(marks)
Here, age is an integer variable and marks is a floating point variable.
Q1(b) Differentiate between for loop using range and while loop in Python.
| for loop using range() | while loop |
|---|---|
| It is generally used when the number of iterations is known. | It is generally used when the number of iterations depends on a condition. |
The range() function generates a sequence of values.
|
The loop continues as long as the given condition is true. |
Example: for i in range(5):
|
Example: while i < 5:
|
Q1(c) Explain string slicing in Python with an example.
String slicing is used to obtain a part of a string. The general syntax is:
string[start:stop:step]
The start index is included and the stop index is excluded.
Example:
name = "Python"
print(name[0:3])
Output:
Pyt
Q1(d) What is a tuple in Python? How is it different from a list?
A tuple is an ordered collection of elements in Python. A tuple is immutable, which means its elements cannot be changed after creation.
Example:
t = (10, 20, 30)
| Tuple | List |
|---|---|
| Tuple is immutable. | List is mutable. |
| Usually written using parentheses (). | Usually written using square brackets []. |
Example: (10, 20, 30) |
Example: [10, 20, 30] |
Q1(e) Define dictionary in Python and give an example of its manipulation.
A dictionary is a collection of data stored in the form of
key-value pairs. It is written using curly brackets
{}.
Example:
student = {
"name": "Rahul",
"marks": 85
}
student["marks"] = 90
print(student)
Here, the value of the marks key is changed from 85 to 90.
Q1(f) What are read() and readline() functions in file handling?
The read() function is used to read the contents of a file. It can read the complete file or a specified number of characters.
The readline() function is used to read one line from a file at a time.
Example:
file = open("data.txt", "r")
data = file.read()
print(data)
file.close()
For reading one line, readline() can be used instead.
Q1(g) Explain encapsulation in Python OOP.
Encapsulation is an OOP concept in which data and the methods that operate on that data are combined inside a class. It also helps to restrict direct access to some data members.
Example:
class Student:
def __init__(self):
self.__marks = 90
def show_marks(self):
print(self.__marks)
s = Student()
s.show_marks()
Here, __marks is treated as a private data member and is
accessed through the class method.
Section B – Answers
Q2(a) Explain Python basic operators and data types. Write a program to check if a number is even or odd using if-else.
Python provides different types of operators to perform operations on data. The basic operators are:
| Operator Type | Operators | Purpose |
|---|---|---|
| Arithmetic |
+ - * / % // **
|
Used for mathematical operations. |
| Relational |
== != > < >= <=
|
Used to compare two values. |
| Logical |
and or not
|
Used to combine conditions. |
| Assignment |
= += -= *= /=
|
Used to assign values to variables. |
| Membership |
in, not in
|
Used to check membership in a sequence. |
| Identity |
is, is not
|
Used to compare object identity. |
Python Data Types
Python provides several built-in data types. Some commonly used data types are:
- int – stores integer values.
- float – stores decimal values.
- complex – stores complex numbers.
- str – stores text or strings.
- list – stores an ordered and mutable collection.
- tuple – stores an ordered and immutable collection.
- dict – stores data in key-value pairs.
- set – stores an unordered collection of unique values.
- bool – stores
TrueorFalse.
Program to Check Even or Odd Number
num = int(input("Enter a number: "))
if num % 2 == 0:
print("The number is even")
else:
print("The number is odd")
Example Output:
Enter a number: 12
The number is even
Q2(b) Describe loop manipulation statements: pass, continue, break. Write a program to print prime numbers between 1 to 50 using for loop.
Loop manipulation statements are used to control the execution of a loop. The three important loop manipulation statements in Python are pass, continue and break.
1. pass
The pass statement does nothing. It is used as a placeholder
when a statement is syntactically required but no action is needed.
for i in range(5):
pass
2. continue
The continue statement skips the remaining statements of
the current iteration and moves to the next iteration.
for i in range(5):
if i == 2:
continue
print(i)
3. break
The break statement terminates the loop immediately.
for i in range(10):
if i == 5:
break
print(i)
Program to Print Prime Numbers from 1 to 50
for num in range(2, 51):
prime = True
for i in range(2, num):
if num % i == 0:
prime = False
break
if prime:
print(num)
Output:
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
Q2(c) Discuss string operations and built-in functions. Write a program to count vowels in a string.
A string is a sequence of characters enclosed within single, double or triple quotation marks.
Common String Operations
- Concatenation: Joining two strings using
+. - Repetition: Repeating a string using
*. - Slicing: Extracting a part of a string.
- Indexing: Accessing an individual character.
- Membership: Checking whether a character or substring exists
using
inornot in.
Common Built-in String Functions and Methods
| Function / Method | Purpose |
|---|---|
len() |
Returns the length of a string. |
upper() |
Converts the string to uppercase. |
lower() |
Converts the string to lowercase. |
replace() |
Replaces part of a string. |
find() |
Finds the position of a substring. |
split() |
Splits a string into a list. |
Program to Count Vowels in a String
text = input("Enter a string: ")
count = 0
for ch in text:
if ch.lower() in "aeiou":
count += 1
print("Number of vowels =", count)
Example Output:
Enter a string: Python Programming
Number of vowels = 4
Q2(d) Explain list and dictionary built-in functions. Write a program to merge two dictionaries.
List Built-in Functions and Methods
| Function / Method | Purpose |
|---|---|
len() |
Returns the number of elements in a list. |
append() |
Adds an element at the end of a list. |
insert() |
Inserts an element at a specified position. |
remove() |
Removes a specified element. |
sort() |
Sorts the elements of a list. |
reverse() |
Reverses the elements of a list. |
Dictionary Built-in Functions and Methods
| Function / Method | Purpose |
|---|---|
len() |
Returns the number of key-value pairs. |
keys() |
Returns all keys. |
values() |
Returns all values. |
items() |
Returns key-value pairs. |
update() |
Adds or updates key-value pairs. |
pop() |
Removes a specified key-value pair. |
Program to Merge Two Dictionaries
dict1 = {
"name": "Rahul",
"age": 20
}
dict2 = {
"course": "B.Tech",
"marks": 85
}
dict1.update(dict2)
print("Merged Dictionary:")
print(dict1)
Output:
Merged Dictionary:
{'name': 'Rahul', 'age': 20, 'course': 'B.Tech', 'marks': 85}
Q2(e) Describe file writing functions: write(), writelines(). Write a program to write student records to a file.
write() Function
The write() function is used to write a string into a file.
It writes one string at a time.
Example:
file = open("data.txt", "w")
file.write("Rahul 85")
file.close()
writelines() Function
The writelines() function is used to write a sequence of
strings to a file. It does not automatically add a newline character
between the strings.
Example:
file = open("data.txt", "w")
lines = ["Rahul 85\n", "Amit 90\n"]
file.writelines(lines)
file.close()
Program to Write Student Records to a File
students = [
"Rahul, 101, 85\n",
"Amit, 102, 90\n",
"Priya, 103, 88\n"
]
file = open("students.txt", "w")
file.writelines(students)
file.close()
print("Student records written successfully.")
Output:
Student records written successfully.
Section C – Answers
Q3(a) Explain Python blocks and conditional statements. Write a program to grade students based on marks using elif.
Python Blocks
A block in Python is a group of statements that are written together and executed as a single unit. Python uses indentation to define a block instead of braces.
For example, the statements inside an if statement form an
indented block.
if marks >= 40:
print("Pass")
print("Student is successful")
The statements having the same indentation belong to the same block.
Conditional Statements
Conditional statements are used to execute different statements depending on a condition. Python provides the following conditional statements:
- if – executes a block when the condition is true.
- if-else – executes one block when the condition is true and another block when it is false.
- if-elif-else – checks multiple conditions.
Program to Grade Students Using elif
marks = int(input("Enter marks: "))
if marks >= 90:
grade = "A+"
elif marks >= 80:
grade = "A"
elif marks >= 70:
grade = "B"
elif marks >= 60:
grade = "C"
elif marks >= 50:
grade = "D"
elif marks >= 40:
grade = "E"
else:
grade = "F"
print("Grade =", grade)
Example Output:
Enter marks: 85
Grade = A
Q3(b) Discuss for loops with strings and lists. Write a program to sum elements of a list.
for Loop with Strings
A for loop can be used to access each character of a
string one by one.
name = "Python"
for ch in name:
print(ch)
Output:
P
y
t
h
o
n
for Loop with Lists
A for loop can also be used to access each element of a
list.
numbers = [10, 20, 30, 40]
for num in numbers:
print(num)
Program to Find the Sum of Elements of a List
numbers = [10, 20, 30, 40, 50]
total = 0
for num in numbers:
total = total + num
print("Sum =", total)
Output:
Sum = 150
Q4(a) Explain functions in Python. Write a function to calculate area of a circle.
Functions in Python
A function is a block of reusable code that performs a specific task. Functions help to reduce code repetition and make a program easier to understand and maintain.
A function is defined using the def keyword.
General syntax:
def function_name(parameters):
statements
A function may accept parameters and may return a value using the
return statement.
Program to Calculate Area of a Circle
def area_of_circle(radius):
area = 3.14 * radius * radius
return area
r = float(input("Enter radius: "))
area = area_of_circle(r)
print("Area of circle =", area)
Example Output:
Enter radius: 5
Area of circle = 78.5
Q4(b) Describe string manipulation methods. Write a program to replace characters in a string.
String Manipulation Methods
Python provides several built-in methods for manipulating strings. Some commonly used methods are:
| Method | Purpose |
|---|---|
upper() |
Converts all characters of a string to uppercase. |
lower() |
Converts all characters of a string to lowercase. |
capitalize() |
Converts the first character to uppercase. |
strip() |
Removes leading and trailing spaces. |
replace() |
Replaces one substring or character with another. |
split() |
Splits a string into a list. |
find() |
Returns the position of a specified substring. |
Program to Replace Characters in a String
text = "I like Java"
new_text = text.replace("Java", "Python")
print("Original string:", text)
print("Modified string:", new_text)
Output:
Original string: I like Java
Modified string: I like Python
Q5(a) Explain sets and their operations. Write a program to find difference between two sets.
Sets in Python
A set is an unordered collection of unique elements in Python.
A set does not allow duplicate values. Sets are written using curly
brackets {}.
Example:
numbers = {10, 20, 30, 40}
Set Operations
Python provides several operations for working with sets.
| Operation | Operator | Purpose |
|---|---|---|
| Union | | |
Returns all elements present in either set. |
| Intersection | & |
Returns common elements of two sets. |
| Difference | - |
Returns elements present in the first set but not in the second set. |
| Symmetric Difference | ^ |
Returns elements present in either set but not in both. |
Examples of Set Operations
A = {1, 2, 3, 4}
B = {3, 4, 5, 6}
print("Union:", A | B)
print("Intersection:", A & B)
print("Difference:", A - B)
print("Symmetric Difference:", A ^ B)
Program to Find Difference Between Two Sets
A = {10, 20, 30, 40, 50}
B = {30, 40, 50, 60, 70}
difference = A - B
print("Difference between A and B =", difference)
Output:
Difference between A and B = {10, 20}
Q5(b) Discuss tuple and list slicing. Write a program to reverse a tuple.
List Slicing
List slicing is used to obtain a part of a list. The general syntax is:
list[start:stop:step]
The start index is included and the stop index is excluded. The step specifies the number of positions to move.
Example:
numbers = [10, 20, 30, 40, 50]
print(numbers[1:4])
Output:
[20, 30, 40]
Tuple Slicing
Tuple slicing works in the same way as list slicing. Since tuples are immutable, slicing creates a new tuple instead of modifying the original tuple.
Example:
data = (10, 20, 30, 40, 50)
print(data[1:4])
Output:
(20, 30, 40)
Program to Reverse a Tuple
numbers = (10, 20, 30, 40, 50)
reverse_tuple = numbers[::-1]
print("Original tuple:", numbers)
print("Reversed tuple:", reverse_tuple)
Output:
Original tuple: (10, 20, 30, 40, 50)
Reversed tuple: (50, 40, 30, 20, 10)
Q6(a) Explain manipulating file pointer using seek(). Write a program to read last n lines from a file.
File Pointer
A file pointer indicates the current position from where data
will be read or written in a file. Python provides the
seek() function to move the file pointer to a particular
position.
Syntax:
file.seek(position)
The position specifies the number of bytes from the
beginning of the file.
Example of seek()
file = open("data.txt", "r")
file.seek(5)
data = file.read()
print(data)
file.close()
In this example, the file pointer is moved to position 5 before reading the remaining contents.
Program to Read Last n Lines from a File
n = int(input("Enter number of lines: "))
file = open("data.txt", "r")
lines = file.readlines()
file.close()
for line in lines[-n:]:
print(line, end="")
Here, readlines() reads the lines of the file into a list
and lines[-n:] selects the last n lines.
Q6(b) Describe regular expressions using re module. Write a program to find all digits in a string.
Regular Expressions
A regular expression is a sequence of characters used to search, match or manipulate patterns in text. Python provides the re module for working with regular expressions.
The re module provides functions such as:
| Function | Purpose |
|---|---|
re.search() |
Searches for a pattern anywhere in a string. |
re.match() |
Checks for a match at the beginning of a string. |
re.findall() |
Returns all matching occurrences. |
re.sub() |
Replaces matching patterns. |
Program to Find All Digits in a String
import re
text = "My roll number is 125 and my marks are 85."
digits = re.findall(r'\d', text)
print("Digits:", digits)
Output:
Digits: ['1', '2', '5', '8', '5']
Here, \d is a regular expression pattern used to match
a digit from 0 to 9.
Q7(a) Explain inheritance and polymorphism. Write a program showing multiple inheritance.
Inheritance
Inheritance is an important concept of Object-Oriented Programming in which a new class acquires the properties and methods of an existing class. The existing class is called the parent class and the new class is called the child class.
Inheritance helps in code reusability and reduces duplication of code.
Polymorphism
Polymorphism means "many forms". In Python, the same method or operator can perform different operations depending on the object or data on which it is used.
Example:
print(10 + 20)
print("Hello " + "Python")
The + operator performs addition for numbers and
concatenation for strings.
Multiple Inheritance
In multiple inheritance, one child class inherits properties and methods from more than one parent class.
Program to Demonstrate Multiple Inheritance
class Father:
def father_property(self):
print("Father's property")
class Mother:
def mother_property(self):
print("Mother's property")
class Child(Father, Mother):
def child_property(self):
print("Child's property")
obj = Child()
obj.father_property()
obj.mother_property()
obj.child_property()
Output:
Father's property
Mother's property
Child's property
Q7(b) Discuss Tkinter widgets. Write a program to create a simple window with a label using Tkinter.
Tkinter Widgets
Tkinter is the standard Python library used to create Graphical User Interface (GUI) applications.
A widget is a graphical component used in a GUI application. Tkinter provides different types of widgets.
| Widget | Purpose |
|---|---|
Label |
Displays text or information. |
Button |
Creates a clickable button. |
Entry |
Accepts single-line user input. |
Text |
Accepts multi-line text input. |
Checkbutton |
Provides a checkbox option. |
Radiobutton |
Provides mutually exclusive options. |
Listbox |
Displays a list of selectable items. |
Program to Create a Simple Window with a Label
import tkinter as tk
window = tk.Tk()
window.title("Python GUI")
window.geometry("400x200")
label = tk.Label(
window,
text="Welcome to Python Programming"
)
label.pack()
window.mainloop()
The Tk() function creates the main window,
Label() creates a label and mainloop() keeps
the GUI window running.
Download AKTU Python Programming Question Paper
Students can download the original question paper and the complete question paper with solutions using the options below.