BTCS 510-18 Programming in Python — important questions

100 questions that keep coming back in Programming in Python (BTCS 510-18) PTU exams, picked from 6 past papers. Questions asked more often, and more recently, are listed first.

Most asked

  1. What is Global Interpreter lock. — 2 marks · asked 3× (Mid Sem 2 2026, Mid Sem 2 2025, End Sem 2022)
  2. Write a note on Object Relational Managers (ORMs). — 2 marks · asked 2× (Mid Sem 2 2026, End Sem 2022)
  3. Explain the concept of Package and Module in Python with an example. — 8 marks · asked 1× (Mid Sem 1 2026)
  4. Write a Python program to demonstrate file handling by reading and writing data into a text file. — 8 marks · asked 1× (Mid Sem 1 2026)
  5. Differentiate between error and exception. What happens when an exception is raised in a Python program? Explain any three built-in Python exceptions with relevant examples. Write a python program that has multiple except blocks. — 8 marks · asked 1× (Mid Sem 2 2026)
  6. Write a Python program using re.findall() to extract all email addresses from a given text. Validate a mobile phone number containing exactly 10 digits, where the first digit must be between 6 and 9. Explain the regular expression pattern used in your program. — 8 marks · asked 1× (Mid Sem 2 2026)
  7. Identify the difference between sets, list and tuples. — 4 marks · asked 1× (Mid Sem 1 2026)
  8. Illustrate how the "with" statement is used in file handling and why it is preferred over explicitly calling close(). — 4 marks · asked 1× (Mid Sem 1 2026)
  9. What is the significance of Namespaces in Python programming. — 4 marks · asked 1× (Mid Sem 1 2026)
  10. Explain connect(), cursor(), execute(), commit(), and close(), with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)

Other questions

  1. What is Global Interpreter lock. — 2 marks · asked 3× (Mid Sem 2 2026, Mid Sem 2 2025, End Sem 2022)
  2. Write a note on Object Relational Managers (ORMs). — 2 marks · asked 2× (Mid Sem 2 2026, End Sem 2022)
  3. Explain the concept of Package and Module in Python with an example. — 8 marks · asked 1× (Mid Sem 1 2026)
  4. Write a Python program to demonstrate file handling by reading and writing data into a text file. — 8 marks · asked 1× (Mid Sem 1 2026)
  5. Differentiate between error and exception. What happens when an exception is raised in a Python program? Explain any three built-in Python exceptions with relevant examples. Write a python program that has multiple except blocks. — 8 marks · asked 1× (Mid Sem 2 2026)
  6. Write a Python program using re.findall() to extract all email addresses from a given text. Validate a mobile phone number containing exactly 10 digits, where the first digit must be between 6 and 9. Explain the regular expression pattern used in your program. — 8 marks · asked 1× (Mid Sem 2 2026)
  7. Identify the difference between sets, list and tuples. — 4 marks · asked 1× (Mid Sem 1 2026)
  8. Illustrate how the "with" statement is used in file handling and why it is preferred over explicitly calling close(). — 4 marks · asked 1× (Mid Sem 1 2026)
  9. What is the significance of Namespaces in Python programming. — 4 marks · asked 1× (Mid Sem 1 2026)
  10. Explain connect(), cursor(), execute(), commit(), and close(), with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)
  11. Discuss ., ^, $, *, +, ?, {}, [], and | metacharacters used in python regular expressions with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)
  12. Discuss the commonly used Tkinter widgets used with python programming. — 4 marks · asked 1× (Mid Sem 2 2026)
  13. Explain the difference between string indexing and string slicing with examples — 2 marks · asked 1× (Mid Sem 1 2026)
  14. Explain the utility of 'Break' statement with the help of an example. — 2 marks · asked 1× (Mid Sem 1 2026)
  15. Differentiate between remove(), pop() and del functions in Python with examples. — 2 marks · asked 1× (Mid Sem 1 2026)
  16. Illustrate with an example how a dictionary stores data. — 2 marks · asked 1× (Mid Sem 1 2026)
  17. Define the following used in Python Programming: (a) Exceptions (b) DB-API. — 2 marks · asked 1× (Mid Sem 2 2026)
  18. Explain how multiprocessing is different from multithreading in Python. — 2 marks · asked 1× (Mid Sem 2 2026)
  19. Explain the importance DB-API and Object Relational Managers (ORMs). Write an example using SQL Alchemy to define a model, insert records, and query them. — 10 marks · asked 1× (End Sem 2025)
  20. Analyze the use of built-in modules versus user-defined modules in terms of reusability, performance, and scalability. — 10 marks · asked 1× (End Sem 2025)
  21. Identify the difference between various types of GUI's. — 10 marks · asked 1× (End Sem 2025)
  22. Elaborate the role of web servers (HTTP Servers) in managing client-server communication efficiency in Python web programming. — 10 marks · asked 1× (End Sem 2025)
  23. Explain briefly the concepts of precedence and associativity. Using these concepts explain how python evaluates complex expressions. — 10 marks · asked 1× (End Sem 2025)
  24. What is multithreading? What are the advantages and challenges associated with multithreading and how are these challenges addressed? — 10 marks · asked 1× (End Sem 2025)
  25. What is Tkinter in Python? Explain Geometry managers with examples. — 8 marks · asked 1× (Mid Sem 2 2025)
  26. Explain different functions provided by the re module in Python with examples and write a Python Program to define it. — 8 marks · asked 1× (Mid Sem 2 2025)
  27. Identify the difference between strings, list and tuples. — 5 marks · asked 1× (End Sem 2025)
  28. Compare the behavior of code execution when using try-except alone versus try-except-else. — 5 marks · asked 1× (End Sem 2025)
  29. Explain the difference between threads and processes in Python with suitable examples. — 5 marks · asked 1× (End Sem 2025)
  30. Construct a menu in Tkinter applications and explain with an example. — 5 marks · asked 1× (End Sem 2025)
  31. Discuss the role of operators in Python and provide examples of arithmetic, logical and comparison operators. — 5 marks · asked 1× (End Sem 2025)
  32. What are sequences in Python, and why are they important? Discuss various types of sequences and provide use cases for each of them. — 5 marks · asked 1× (End Sem 2025)
  33. What is an assertion? Describe a scenario where using an assertion would be beneficial with the help of an example. — 5 marks · asked 1× (End Sem 2025)
  34. What is GUI Programming? Explain how the functionality of GUI application can be extended by integrating third party libraries. — 5 marks · asked 1× (End Sem 2025)
  35. Explain the role of Object-Relational Managers (ORMs) in simplifying database operations. Provide an example showing the usage of ORM in conjunction with DB-API. — 5 marks · asked 1× (End Sem 2025)
  36. What is GUI Programming and write different types of events with examples. — 4 marks · asked 1× (Mid Sem 2 2025)
  37. What is Web Surfing? Explain any three Python web frameworks. — 4 marks · asked 1× (Mid Sem 2 2025)
  38. What is Thread in Python and write brief syntax to create and start a thread in Python. — 4 marks · asked 1× (Mid Sem 2 2025)
  39. Name two built-in Python modules commonly used in data analysis. — 2 marks · asked 1× (End Sem 2025)
  40. Explain the difference between string indexing and string slicing with examples. — 2 marks · asked 1× (End Sem 2025)
  41. Name two methods used to write data into a file in Python. — 2 marks · asked 1× (End Sem 2025)
  42. Illustrate how the "with" statement is used in file handling and why it is preferred over explicitly calling close ( ). — 2 marks · asked 1× (End Sem 2025)
  43. Which Python statement is used to start a new thread using the thread module? — 2 marks · asked 1× (End Sem 2025)
  44. Explain the acronym GIL in Python. — 2 marks · asked 1× (End Sem 2025)
  45. Name any one Python library used for web clients. — 2 marks · asked 1× (End Sem 2025)
  46. Demonstrate the process of establishing a client-server connection. — 2 marks · asked 1× (End Sem 2025)
  47. Why do we need Python for database programming? — 2 marks · asked 1× (End Sem 2025)
  48. Explain two Python modules that support DB-API. — 2 marks · asked 1× (End Sem 2025)
  49. Define reGEX module in Python — 2 marks · asked 1× (Mid Sem 2 2025)
  50. Write special symbols in Python with its meaning. — 2 marks · asked 1× (Mid Sem 2 2025)
  51. HTTP — 2 marks · asked 1× (Mid Sem 2 2025)
  52. What are the main features of Python set types? Discuss two operations that can be performed on them. — 2 marks · asked 1× (End Sem 2025)
  53. Differentiate between an operator and an operand. — 2 marks · asked 1× (End Sem 2025)
  54. Write a short note on Python standard file objects discussing their importance. — 2 marks · asked 1× (End Sem 2025)
  55. Define the term 'module reloading'. — 2 marks · asked 1× (End Sem 2025)
  56. Differentiate between a process and a thread. — 2 marks · asked 1× (End Sem 2025)
  57. How can you use regular expressions to search for specific patterns in a string using Python? — 2 marks · asked 1× (End Sem 2025)
  58. What is CGI? How can CGI assist servers in handling client data? — 2 marks · asked 1× (End Sem 2025)
  59. Explain briefly the concept of client-server architecture. — 2 marks · asked 1× (End Sem 2025)
  60. Describe the role of the cursor in database programming with Python. — 2 marks · asked 1× (End Sem 2025)
  61. What is the role of transactions in database programming, and why are they important? — 2 marks · asked 1× (End Sem 2025)
  62. Explain the following term: Pooling — 2 marks · asked 1× (End Sem 2025)
  63. Explain the following term: API — 2 marks · asked 1× (End Sem 2025)
  64. Explain the following term: Module — 2 marks · asked 1× (End Sem 2025)
  65. Explain the following term: Interface — 2 marks · asked 1× (End Sem 2025)
  66. Explain the following term: Transaction — 2 marks · asked 1× (End Sem 2025)
  67. What are Literals & Data types in Python and explain them with examples? — 10 marks · asked 1× (End Sem 2024)
  68. What is the process of compilation and linking in Python? Does Python have OOPs concepts? — 10 marks · asked 1× (End Sem 2024)
  69. Describe the different access modes of the files with an example. Consider a line "From Stephen. marquard\@uct.ac.za Sat Jan 5 09:14:16 2008" in the file email.txt. Write Python code to read the file and extract email address from the lines starting from the word "From". Use regular expressions to match email address. — 10 marks · asked 1× (End Sem 2024)
  70. What is difference between error and exception? Explain exception handling in Python with example. — 5 marks · asked 1× (End Sem 2024)
  71. Describe the syntax for the following functions and explain with an example: len() — 5 marks · asked 1× (End Sem 2024)
  72. Write a Python GUI program to create three push buttons using Tkinter. The background colour of the frame should be different when different buttons are clicked. — 5 marks · asked 1× (End Sem 2024)
  73. Discuss inheritance in Python programming language. Write Python Program to demonstrate Multiple Inheritance with Method Overriding. — 5 marks · asked 1× (End Sem 2024)
  74. Describe the need for catching exceptions using try and except statements. — 5 marks · asked 1× (End Sem 2024)
  75. Explain built-in data types of Python. — 2 marks · asked 1× (End Sem 2024)
  76. What are the key features of Python? — 2 marks · asked 1× (End Sem 2024)
  77. Explain the need for continue and break statements. — 2 marks · asked 1× (End Sem 2024)
  78. Describe list slicing with examples. — 2 marks · asked 1× (End Sem 2024)
  79. How filter is used in Python program? Explain with a suitable example. — 2 marks · asked 1× (End Sem 2024)
  80. Explain raw_input() and input() in Python. — 2 marks · asked 1× (End Sem 2024)
  81. Discuss the need and importance of function in python. — 2 marks · asked 1× (End Sem 2024)
  82. Identify what are the packages in python. — 2 marks · asked 1× (End Sem 2024)
  83. Demonstrate the various expressions in python with suitable examples. — 2 marks · asked 1× (End Sem 2024)
  84. Discuss the various operation that can be performed on a tuple and Lists (minimum 5) with an example. — 2 marks · asked 1× (End Sem 2024)
  85. Describe the syntax and semantics of any two loop structures provided by Python. — 10 marks · asked 1× (End Sem 2022)
  86. Write a note on Python Database Application Programmer's Interface (DB-API). — 10 marks · asked 1× (End Sem 2022)
  87. Differentiate between thread module, threading module and related module. — 10 marks · asked 1× (End Sem 2022)
  88. Differentiate between function and module in Python. — 5 marks · asked 1× (End Sem 2022)
  89. Test whether a given year is leap year or not. — 5 marks · asked 1× (End Sem 2022)
  90. Write code to print Fibonacci series. — 5 marks · asked 1× (End Sem 2022)
  91. Differentiate between simple and advanced web clients. — 5 marks · asked 1× (End Sem 2022)
  92. Define pickling. — 2 marks · asked 1× (End Sem 2022)
  93. Python Interpreter. — 2 marks · asked 1× (End Sem 2022)
  94. Intermediate mode and script mode. — 2 marks · asked 1× (End Sem 2022)
  95. Lists in Python. — 2 marks · asked 1× (End Sem 2022)
  96. Define exceptions. — 2 marks · asked 1× (End Sem 2022)
  97. Define Recursion. — 2 marks · asked 1× (End Sem 2022)
  98. String lower function. — 2 marks · asked 1× (End Sem 2022)
  99. Define HTTP. — 2 marks · asked 1× (End Sem 2022)
  100. Special symbols in Python. — 2 marks · asked 1× (End Sem 2022)

Related