Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
70 views

Python Programming Questions BCA

Uploaded by

mikey2op2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

Python Programming Questions BCA

Uploaded by

mikey2op2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Python Questions For Semester Examination

Python Theoretical Questions


1-Marks Questions
1. What is the Python Virtual Machine (PVM)?

2. Define a token in Python.

3. What is the difference between a keyword and an identifier in Python?

4. Name two immutable data types in Python.

5. What is the use of the `range()` function in Python?

6. What is slicing in Python?

7. Define the `len()` function.

8. What is the output of `5 // 2` in Python?

9. What is the role of the `self` keyword in Python classes?

10. How is a single-line comment written in Python?

11. Define a literal in Python.

12. Name two built-in string methods in Python.

13. What is the default mode when opening a file in Python?

14. Define a lambda function.

15. What does `isalpha()` method do in Python?

16. What is the purpose of the `break` statement in loops?

17. What is the use of the `id()` function in Python?

18. Name the built-in function to convert a string to lowercase.

19. What is the use of `continue` in a loop?

20. What is the type of data returned by the `input()` function?

21. What does the `startswith()` method check in a string?


22. Define a shallow copy of a list.

23. What does the `extend()` method do in lists?

24. Mention one difference between a list and a tuple.

25. What is the use of the `pop()` method in dictionaries?

26. Name the file mode used to append data to an existing file.

27. Define a class in Python.

28. What is the purpose of the `super()` function in inheritance?

29. Name the types of methods in Python classes.

30. What is an abstract class?

31. What is operator overloading?

32. Mention the use of the `is` operator in Python.

33. Define mutable objects with an example.

34. What does the `rstrip()` function do in strings?

35. What is the output of `3**2` in Python?

36. Name the method used to reverse a list.

37. Define a dictionary in Python.

38. What does the `get()` method do in dictionaries?

39. What is the use of the `fromkeys()` method in dictionaries?

40. What does the `read()` method do for files in Python?

41. Define polymorphism.

42. Mention one key feature of Python.

43. What is the difference between `w` and `a` file modes?

44. What does `isdigit()` check in a string?

45. Define recursion in Python.

46. What is the purpose of the `split()` method in strings?

47. What is a nested loop?


48. Name a method to create a tuple from an existing list.

49. Define method overloading.

50. What is the role of `__init__()` in Python classes?

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

Basics and Syntax

1. Write a program to print "Hello, World!".

2. Write a Python script to swap two numbers without using a temporary variable.

3. Create a program to find the maximum of three numbers.

4. Write a program to check if a number is positive, negative, or zero.

5. Create a program to calculate the factorial of a number.

6. Write a program to generate the Fibonacci sequence up to n terms.

7. Write a Python program to check if a year is a leap year.

8. Create a program to print the multiplication table of a number.

9. Write a Python program to find the sum of digits in a number.

10. Write a program to reverse a given number.

Data Types and Strings

11. Write a program to check if a string is a palindrome.

12. Write a program to count the number of vowels and consonants in a string.

13. Create a program to find the longest word in a sentence.

14. Write a program to convert a string to uppercase and lowercase.

15. Write a program to replace all occurrences of a substring in a string.

16. Create a program to find the frequency of each character in a string.

17. Write a program to concatenate two strings using different methods.

18. Write a Python script to remove all non-alphanumeric characters from a string.

19. Create a program to sort the characters of a string alphabetically.

20. Write a program to find the Unicode value of each character in a string.

Lists and Tuples


21. Write a program to find the largest and smallest numbers in a list.

22. Write a Python script to count the occurrences of an element in a list.

23. Create a program to reverse a list without using built-in functions.

24. Write a Python program to merge two lists into one without duplicates.

25. Create a program to find the sum of all elements in a list.

26. Write a program to find common elements in two lists.

27. Write a Python program to sort a list of tuples by the second element.

28. Create a program to flatten a nested list.

29. Write a program to find the index of an element in a list.

30. Write a Python script to generate a list of even numbers up to n.

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.

33. Create a program to merge two dictionaries.

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.

36. Write a program to check if a key exists in a dictionary.

37. Write a Python script to remove a key-value pair from a dictionary.

38. Create a program to iterate over keys and values of a dictionary.

39. Write a Python script to find the sum of all values in a dictionary.

40. Write a program to sort a dictionary by keys and values.

Files

41. Write a Python program to read a text file and display its content.

42. Write a program to append new data to an existing text file.


43. Create a program to count the number of lines, words, and characters in a file.

44. Write a program to find the largest word in a text file.

45. Create a Python script to copy content from one file to another.

46. Write a program to write a list of strings to a file.

47. Create a program to read a file line by line and print it.

48. Write a Python script to search for a specific word in a file.

49. Create a program to count the occurrences of a specific word in a file.

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.

52. Create a recursive function to calculate the factorial of a number.

53. Write a function to find the sum of an arithmetic progression.

54. Create a Python function to check if a number is prime.

55. Write a Python function to generate Pascal's triangle up to n rows.

56. Write a function to check if a string is an anagram of another string.

57. Create a Python function to calculate the compound interest.

58. Write a function to find the LCM of two numbers.

59. Create a Python function to check if a number is an Armstrong number.

60. Write a function to return the nth Fibonacci number.

Loops and Conditionals

61. Write a Python program to print all prime numbers in a range.

62. Create a program to calculate the sum of squares of the first n natural numbers.

63. Write a Python script to check if a number is a perfect square.

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.

67. Write a Python script to print all the divisors of a number.

68. Create a program to find the smallest number divisible by all numbers in a given range.

69. Write a Python program to print Floyd's triangle.

70. Create a Python script to print the factorial of all numbers from 1 to n.

OOP and Classes

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.

78. Write a Python program to demonstrate polymorphism using method overriding.

79. Create an abstract class with a method to calculate the area of a shape and implement it in
derived classes.

80. Write a Python script to demonstrate operator overloading.

Miscellaneous
81. Write a program to create a generator that yields the squares of numbers.

82. Create a Python script to measure the execution time of a function.

83. Write a Python program to create a decorator function.


84. Create a program to solve a quadratic equation.

85. Write a Python script to generate random numbers within a range.

86. Create a program to implement a basic calculator using functions.

87. Write a Python program to calculate the sum of a geometric progression.

88. Create a Python script to count the frequency of each digit in a number.

89. Write a Python program to find the median of a list of numbers.

90. Create a program to generate all possible permutations of a string.

You might also like