MID - TERM EXAMINATION
BCA THIRD SEMESTER November 2023
Paper Code: BCA-211
Subject: Basics of Python Programming
Time: 2 Hours
Maximum Marks: 60
Note: Q. 1 is compulsory. Attempt any 3 from the rest. Each question carries 15 marks.
Q.1 Attempt any 5 questions. Each question carries 3 marks.
- (a) List down the key features of Python programming language. 3
- (b) Explain the dynamic typing feature of Python. 3
- (c) What is the difference between indexing and slicing in Python? 3
- (d) Differentiate between sort() and sorted() for lists. 3
- (e) Differentiate between copy() and deepcopy() for list. 3
- (f) What is the difference between interactive mode and script mode in Python? 3
- (g) How do you write a multiline statement in Python? 3
Q.2
- (a) Explain the following list methods with example. a) append() b) extend() c) clear() d) count() e) reverse() 5
- (b) What is list comprehension? What are its components/parts? Write a program to create a list with elements 1, 2, 3, 4, and 5. Display even elements of the list using list comprehension. 5
- (c) Explain the difference between any() and all() functions of list. Explain with example. 5
Q.3
- (a) Write a program which inputs a list of numbers and swaps the elements of 1st Half of the list with the 2nd Half of the list ONLY if the sum of 1st Half is greater than 2nd Half of the list. Sample Input Data for the list is [100, 200, 300, 40, 50, 60]. Output is [40, 50, 60, 100, 200, 300] 5
- (b) Explain the need for continue, pass and break statements. Write proper code to explain the same. 5
- (c) Write a program that accepts numbers from the user and displays the sum of all even numbers from the ones entered. The loop should continue till the user enters a zero. 5
Q.4
- (a) Explain the use of join() and split() string methods with examples. Describe with an example "how strings are immutable". 5
- (b) Write a program that reads a string and checks if it is a palindrome or not. 5
- (c) Differentiate between isalnum(), isalpha() and isascii() for strings. 5
Q.5
- (a) What is Tuple? How are Tuples different from Lists. Discuss the utility and significance of Tuples. 5
- (b) Discuss zip() function with an example. Make use of a list/tuple/dictionary to explain. 5
- OR
- (c) What is the difference between dictionary and list? How can you merge two dictionaries? What is the difference between del and clear()? 5
- (d) Write code to rename a key of a dictionary (hint: use pop()). 5