INDERPRASTHA ENGINEERING COLLEGE, GHAZIABAD
Department of Computer Science and Engineering(AI)
Session : 2025 – 2026
CLASS ASSIGNMENT
Course : [Link] CSE(AI) Semester : III
Subject Name: Python Programming Subject Code : BCC-302
Date of Submission : November 12, 2025
Q. Explain the working of while loop, for loop with syntax and examples.
Q. Explain the purpose and working of loops. Discuss pass, continue and break with example.
Q. Write a python program to change a given string to a new string where the first and last chars
have been exchanged.
Q. How do you randomise the items of a list in place in Python.
Q. Differenciate between :
a) / and // Operator
b) Difference & Symmetric Difference
c) ! and &
d) append and extend
Q. Explain the concept of List Comprehension with example.
Q. 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.
Q. Describe the concept of List slicing with suitable example.
Q. In some languages, every statement ends with a semi-colon(;). What happens if you put a semi-
colon at the end of a python statement.
Q. Write a Python program to print even length words in a string.
1
Q. Illustrate different list slicing constructs for the following operations on the following List
L=[1, 2, 3, 4, 5, 6, 7, 8, 9]
1. Return a list of numbers starting from the last to second item of the list
2. Return a list that start from 3rd item to second last item.
3. Return a list that has only even position elements of list L to list M.
4. Return a list that starts from the middle of the list L.
5. Return a list that reverses all the elements starting from element at index 0 to middle index only
and return the entire list.
6. Divide each element of the list by 2 and replace it with the remainder.
Q. Compute the output of the following python code:
def count(s):
for str in [Link]():
s = "&".join(str)
return s
print(count("Python is fun to learn.”))
Q. Write a Python program that unpacks the tuple
Student = ("Aditya", 25, “Computer Science”)
into three variables - name, age, and course and then prints them in this format:
Expected Output:
Name: Aditya
Age: 25
Course: Computer Science
1
Q. Write a function lessthan(1st, k) to return list of numbers less than from a list lst. The function
must use list comprehension.
Example:
lessthan ([1, -2, 0, 5, -3]
returns [-2, -3]
Q. Write a program factors (N) that returns a list of all positive divisors of N (N>=1 ).
Example:
factors (6) returns [1,2,3,6]
factors (1) returns [1]
factors (13) returns turns [1,13]
Q. Write a Python function replace_char(s, n, ch) that replaces the character at index n in string s
with the character ch.
If n is out of range, return the original string.
Example:
replace_char("HELLO", 1, "A") → "HALLO"
replace_char("WORLD", 10, "Z") → “WORLD”
Q. Write a Python program that accepts a comma-separated list of names and prints them in
alphabetical order after removing duplicates.
Example Input: Chirag, Aditya, Priyanka, Piyush, Priya, Samiksha, Aditya, Priya
Expected Output: Aditya, Chirag, Priyanka, Piyush, Priya, Samiksha
1
Q. Write a function to find the factorial of a number n. n is the parameter.
Q. Write a function in Python to generate Fibonacci series.
Q. Write a function in Python to check whether a string is palindrome or not.
Q. What is the difference between Nested Function & Recursion. Explain with the help of examples.
Q. Define Recursion and the different Types of Recursion with examples.
Q. Discuss the different types of argument passing methods in Python with example.
Q. Which of the following statements produce an error in Python?
p, q, r = 11, 12, 13 #s1
s, t = 14, 15, 16 #s2
v = 17, 18, 19 #s3
(List all the statements that have error)
Q. Write a recursive Python function "rprint" to print all elements list in reverse.
rprint([]) prints nothing
rprint ([1,2,3]) prints 3 2 1