Python Programming Questions BCA
Python Programming Questions BCA
26. Name the file mode used to append data to an existing file.
43. What is the difference between `w` and `a` file modes?
5-Marks Questions
1. Explain the key features of Python.
2. How is a Python program executed? Include the role of PVM.
3. Differentiate between Python and C.
4. Compare Python and Java.
5. Explain the memory management system in Python.
6. What are frozen binaries? Why are they used?
7. Discuss Python tokens with examples.
8. Differentiate between keywords and identifiers.
9. What are literals in Python? Explain with examples.
10. List and explain Python operators.
11. How are comments written in Python? Illustrate with examples.
12. Discuss variables and multiple assignments in Python.
13. Explain mutable and immutable data types with examples.
14. How are negative numbers handled in Python arithmetic?
15. Write a Python program to demonstrate type casting.
16. Explain the flow of control using the if statement.
17. How does if...else work in Python? Write a code example.
18. Discuss the if...elif...else statement with an example.
19. Explain the use of the range() function in loops.
20. Differentiate between while and for loops in Python.
21. Explain the use of nested loops in Python.
22. Illustrate the use of the break and continue statements.
23. Write a Python program to demonstrate the return statement in a function.
24. How do you traverse a string in Python?
25. Explain string concatenation and replication with examples.
26. Discuss membership operators in strings with examples.
27. How do you determine the Unicode value of a character in Python?
28. Explain string slicing with examples.
29. Write a program to demonstrate the use of find() and index() methods.
30. Discuss the purpose of isalpha(), isdigit(), and isspace() methods.
31. Explain the strip(), lstrip(), and rstrip() methods with examples.
32. Discuss the use of join() and split() methods in Python strings.
33. Differentiate between functions and methods in Python.
34. How are functions defined and called in Python?
35. Explain how default arguments work in Python functions.
36. What are keyword arguments? Illustrate with an example.
37. Discuss variable-length arguments in Python functions.
38. Write a program to demonstrate the use of local and global variables.
39. Explain recursion with an example program.
40. How are lambda functions used with filter() and map()?
41. Explain how lists are created and accessed in Python.
42. How can lists be indexed and sliced? Give examples.
43. Discuss the difference between append() and extend() methods in lists.
44. Write a program to demonstrate list replication and comparison.
45. Explain the process of creating a true copy of a list.
46. How does the sort() method differ from the sorted() function?
47. Discuss two-dimensional lists in Python.
48. How are tuples created and accessed in Python?
49. Write a program to traverse a tuple and find its maximum and minimum values.
50. Differentiate between tuples and lists.
51. Explain how dictionaries are created and used in Python.
52. Discuss the keys(), values(), and items() methods in dictionaries.
53. Explain how elements are added and deleted from a dictionary.
54. Write a program to demonstrate the use of the update() method in dictionaries.
55. Explain shallow and deep copies in dictionaries.
56. Discuss file opening modes in Python.
57. Write a program to read data from a text file using read() and readline().
58. Explain the use of the write() and writelines() methods.
59. What is the purpose of the with clause in file handling?
60. How are seek() and tell() used in file handling?
61. Discuss the features of object-oriented programming (OOP).
62. Explain how classes are created in Python.
63. Discuss the purpose of the self variable in class methods.
64. What is the difference between instance variables and class variables?
65. Explain the use of constructors in inheritance.
66. Discuss the types of inheritance supported in Python.
67. What is method resolution order (MRO)?
68. Explain operator overloading with examples.
69. Write a program to demonstrate polymorphism.
70. What is an abstract class? How is it implemented in Python?
71. Discuss the concept of namespaces in Python.
72. Explain the difference between instance methods and static methods.
73. Illustrate how the super() function is used in inheritance.
74. Write a program to demonstrate multi-level inheritance.
75. Discuss the startswith() and endswith() methods in strings.
76. Explain how a nested list is accessed and traversed.
77. How can a Python dictionary be converted into a list?
78. Write a program to demonstrate key-value pair addition in a dictionary.
79. What is the purpose of the partition() method in strings?
80. Explain how the count() method works in strings.
81. Discuss list comprehensions with examples.
82. How can a tuple be converted into a list?
83. Write a program to find the sum of dictionary values.
84. What is the purpose of capitalize() and title() methods in strings?
85. Explain the process of creating a nested dictionary.
86. Discuss the use of isupper() and islower() methods in strings.
87. Explain the difference between pop() and popitem() in dictionaries.
88. Write a program to demonstrate the clear() method in dictionaries.
89. What is the purpose of max() and min() methods in dictionaries?
90. Explain the working of the join() method in strings.
91. Discuss the difference between positional and keyword arguments.
92. Write a program to demonstrate recursion for finding the factorial of a number.
93. How is exception handling implemented in file handling?
94. Explain how the split() method is used to tokenize a string.
95. Write a Python program to count the number of vowels in a string.
96. How are two lists joined in Python?
97. Discuss the use of nested tuples.
98. Write a program to sort a dictionary by its keys.
99. How can the update() method be used with two dictionaries?
100. Discuss the role of the enumerate() function in Python loops.
15-Marks Questions
1. Discuss in detail the features of Python.
2. Explain the execution process of a Python program with an example.
3. Compare the memory management in Python and C.
4. Write a program to demonstrate different file handling operations in Python.
5. Explain string manipulation in Python with examples of at least five methods.
6. Discuss the process of inheritance with a multi-level inheritance example.
7. Write a Python program to implement operator overloading for addition.
8. Explain dictionary operations in Python with examples of at least five methods.
9. Discuss the advantages of OOP in Python with suitable examples.
10. Compare and contrast Python lists and tuples.
11. Write a program to create and manipulate a two-dimensional list.
12. Explain the role of constructors in Python classes.
13. Discuss polymorphism and its implementation in Python.
14. Write a Python program to demonstrate exception handling.
15. Explain the different types of arguments in Python functions with examples.
16. Write a program to demonstrate lambda functions with filter() and map().
17. Discuss file handling in Python with an example of reading and writing operations.
18. Explain the use of list comprehensions with examples.
19. Compare mutable and immutable types with examples.
20. Write a Python program to find the maximum and minimum of a list of numbers.
21. Discuss the use of recursive functions with an example.
22. Explain how Python handles negative number arithmetic with examples.
23. Write a program to implement the partition() method in strings.
24. Discuss the use of startswith() and endswith() methods with examples.
25. Compare Java and Python in terms of syntax, performance, and memory management.
26. Write a Python program to demonstrate nested loops with the break statement.
27. Discuss namespaces and scope in Python.
28. Write a Python program to demonstrate the join() method for string concatenation.
29. Explain shallow and deep copies in Python with examples.
30. Discuss different types of inheritance in Python with examples.
31. Write a Python program to sort a dictionary by its values.
32. Explain method resolution order (MRO) with examples.
33. Discuss the purpose of abstract classes and how they are implemented in Python.
34. Write a Python program to create and manipulate a nested dictionary.
35. Compare and contrast Python’s while and for loops.
36. Discuss the significance of the super() function in inheritance.
37. Explain operator overloading and its advantages in Python.
38. Write a Python program to reverse a string without using built-in functions.
39. Discuss the use of membership operators in Python strings.
40. Explain how Python handles Unicode characters.
41. Write a program to count the frequency of each character in a string using dictionaries.
42. Discuss the significance of the __init__() method in Python classes.
43. Write a program to demonstrate sorting of a list of tuples based on the second element.
44. Explain the use of the zip() function in Python.
45. Discuss the types of methods in Python classes with examples.
46. Write a program to demonstrate operator overloading for string concatenation.
47. Explain the difference between file handling modes r+ and w+ with examples.
48. Write a Python program to find the maximum and minimum of dictionary values.
49. Discuss the working of seek() and tell() methods with examples.
50. Write a Python program to implement a custom exception class.
Programming Questions
2. Write a Python script to swap two numbers without using a temporary variable.
12. Write a program to count the number of vowels and consonants in a string.
18. Write a Python script to remove all non-alphanumeric characters from a string.
20. Write a program to find the Unicode value of each character in a string.
24. Write a Python program to merge two lists into one without duplicates.
27. Write a Python program to sort a list of tuples by the second element.
Dictionaries
31. Write a program to create a dictionary from two lists (keys and values).
32. Write a Python script to count the frequency of each word in a sentence.
34. Write a Python script to find the maximum and minimum values in a dictionary.
35. Create a program to update a dictionary with another dictionary or key-value pair.
39. Write a Python script to find the sum of all values in a dictionary.
Files
41. Write a Python program to read a text file and display its content.
45. Create a Python script to copy content from one file to another.
47. Create a program to read a file line by line and print it.
50. Write a program to replace a specific word in a file with another word.
Functions
51. Write a Python function to find the greatest common divisor (GCD) of two numbers.
62. Create a program to calculate the sum of squares of the first n natural numbers.
64. Create a program to find the GCD of two numbers using loops.
65. Write a Python program to generate a diamond pattern using stars (*).
66. Create a program to find the sum of odd and even numbers in a range.
68. Create a program to find the smallest number divisible by all numbers in a given range.
70. Create a Python script to print the factorial of all numbers from 1 to n.
71. Create a class to represent a bank account and implement deposit and withdrawal
methods.
72. Write a class to represent a rectangle and calculate its area and perimeter.
73. Create a class to represent a student with attributes for name, age, and marks, and
methods to display the details.
74. Write a Python script to demonstrate inheritance using a parent and child class.
75. Create a class to represent a circle and implement methods to calculate its area and
circumference.
76. Write a class to handle a list of books and implement methods to add, remove, and search
for books.
77. Create a class to represent complex numbers and implement addition and subtraction
methods.
79. Create an abstract class with a method to calculate the area of a shape and implement it in
derived classes.
Miscellaneous
81. Write a program to create a generator that yields the squares of numbers.
88. Create a Python script to count the frequency of each digit in a number.