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
- What is Global Interpreter lock. — 2 marks · asked 3× (Mid Sem 2 2026, Mid Sem 2 2025, End Sem 2022)
- Write a note on Object Relational Managers (ORMs). — 2 marks · asked 2× (Mid Sem 2 2026, End Sem 2022)
- Explain the concept of Package and Module in Python with an example. — 8 marks · asked 1× (Mid Sem 1 2026)
- 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)
- 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)
- 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)
- Identify the difference between sets, list and tuples. — 4 marks · asked 1× (Mid Sem 1 2026)
- 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)
- What is the significance of Namespaces in Python programming. — 4 marks · asked 1× (Mid Sem 1 2026)
- Explain connect(), cursor(), execute(), commit(), and close(), with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)
Other questions
- What is Global Interpreter lock. — 2 marks · asked 3× (Mid Sem 2 2026, Mid Sem 2 2025, End Sem 2022)
- Write a note on Object Relational Managers (ORMs). — 2 marks · asked 2× (Mid Sem 2 2026, End Sem 2022)
- Explain the concept of Package and Module in Python with an example. — 8 marks · asked 1× (Mid Sem 1 2026)
- 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)
- 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)
- 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)
- Identify the difference between sets, list and tuples. — 4 marks · asked 1× (Mid Sem 1 2026)
- 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)
- What is the significance of Namespaces in Python programming. — 4 marks · asked 1× (Mid Sem 1 2026)
- Explain connect(), cursor(), execute(), commit(), and close(), with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)
- Discuss ., ^, $, *, +, ?, {}, [], and | metacharacters used in python regular expressions with suitable examples. — 4 marks · asked 1× (Mid Sem 2 2026)
- Discuss the commonly used Tkinter widgets used with python programming. — 4 marks · asked 1× (Mid Sem 2 2026)
- Explain the difference between string indexing and string slicing with examples — 2 marks · asked 1× (Mid Sem 1 2026)
- Explain the utility of 'Break' statement with the help of an example. — 2 marks · asked 1× (Mid Sem 1 2026)
- Differentiate between remove(), pop() and del functions in Python with examples. — 2 marks · asked 1× (Mid Sem 1 2026)
- Illustrate with an example how a dictionary stores data. — 2 marks · asked 1× (Mid Sem 1 2026)
- Define the following used in Python Programming: (a) Exceptions (b) DB-API. — 2 marks · asked 1× (Mid Sem 2 2026)
- Explain how multiprocessing is different from multithreading in Python. — 2 marks · asked 1× (Mid Sem 2 2026)
- 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)
- 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)
- Identify the difference between various types of GUI's. — 10 marks · asked 1× (End Sem 2025)
- 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)
- Explain briefly the concepts of precedence and associativity. Using these concepts explain how python evaluates complex expressions. — 10 marks · asked 1× (End Sem 2025)
- 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)
- What is Tkinter in Python? Explain Geometry managers with examples. — 8 marks · asked 1× (Mid Sem 2 2025)
- 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)
- Identify the difference between strings, list and tuples. — 5 marks · asked 1× (End Sem 2025)
- Compare the behavior of code execution when using try-except alone versus try-except-else. — 5 marks · asked 1× (End Sem 2025)
- Explain the difference between threads and processes in Python with suitable examples. — 5 marks · asked 1× (End Sem 2025)
- Construct a menu in Tkinter applications and explain with an example. — 5 marks · asked 1× (End Sem 2025)
- Discuss the role of operators in Python and provide examples of arithmetic, logical and comparison operators. — 5 marks · asked 1× (End Sem 2025)
- 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)
- 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)
- 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)
- 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)
- What is GUI Programming and write different types of events with examples. — 4 marks · asked 1× (Mid Sem 2 2025)
- What is Web Surfing? Explain any three Python web frameworks. — 4 marks · asked 1× (Mid Sem 2 2025)
- 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)
- Name two built-in Python modules commonly used in data analysis. — 2 marks · asked 1× (End Sem 2025)
- Explain the difference between string indexing and string slicing with examples. — 2 marks · asked 1× (End Sem 2025)
- Name two methods used to write data into a file in Python. — 2 marks · asked 1× (End Sem 2025)
- 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)
- Which Python statement is used to start a new thread using the thread module? — 2 marks · asked 1× (End Sem 2025)
- Explain the acronym GIL in Python. — 2 marks · asked 1× (End Sem 2025)
- Name any one Python library used for web clients. — 2 marks · asked 1× (End Sem 2025)
- Demonstrate the process of establishing a client-server connection. — 2 marks · asked 1× (End Sem 2025)
- Why do we need Python for database programming? — 2 marks · asked 1× (End Sem 2025)
- Explain two Python modules that support DB-API. — 2 marks · asked 1× (End Sem 2025)
- Define reGEX module in Python — 2 marks · asked 1× (Mid Sem 2 2025)
- Write special symbols in Python with its meaning. — 2 marks · asked 1× (Mid Sem 2 2025)
- HTTP — 2 marks · asked 1× (Mid Sem 2 2025)
- 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)
- Differentiate between an operator and an operand. — 2 marks · asked 1× (End Sem 2025)
- Write a short note on Python standard file objects discussing their importance. — 2 marks · asked 1× (End Sem 2025)
- Define the term 'module reloading'. — 2 marks · asked 1× (End Sem 2025)
- Differentiate between a process and a thread. — 2 marks · asked 1× (End Sem 2025)
- How can you use regular expressions to search for specific patterns in a string using Python? — 2 marks · asked 1× (End Sem 2025)
- What is CGI? How can CGI assist servers in handling client data? — 2 marks · asked 1× (End Sem 2025)
- Explain briefly the concept of client-server architecture. — 2 marks · asked 1× (End Sem 2025)
- Describe the role of the cursor in database programming with Python. — 2 marks · asked 1× (End Sem 2025)
- What is the role of transactions in database programming, and why are they important? — 2 marks · asked 1× (End Sem 2025)
- Explain the following term: Pooling — 2 marks · asked 1× (End Sem 2025)
- Explain the following term: API — 2 marks · asked 1× (End Sem 2025)
- Explain the following term: Module — 2 marks · asked 1× (End Sem 2025)
- Explain the following term: Interface — 2 marks · asked 1× (End Sem 2025)
- Explain the following term: Transaction — 2 marks · asked 1× (End Sem 2025)
- What are Literals & Data types in Python and explain them with examples? — 10 marks · asked 1× (End Sem 2024)
- What is the process of compilation and linking in Python? Does Python have OOPs concepts? — 10 marks · asked 1× (End Sem 2024)
- 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)
- What is difference between error and exception? Explain exception handling in Python with example. — 5 marks · asked 1× (End Sem 2024)
- Describe the syntax for the following functions and explain with an example: len() — 5 marks · asked 1× (End Sem 2024)
- 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)
- Discuss inheritance in Python programming language. Write Python Program to demonstrate Multiple Inheritance with Method Overriding. — 5 marks · asked 1× (End Sem 2024)
- Describe the need for catching exceptions using try and except statements. — 5 marks · asked 1× (End Sem 2024)
- Explain built-in data types of Python. — 2 marks · asked 1× (End Sem 2024)
- What are the key features of Python? — 2 marks · asked 1× (End Sem 2024)
- Explain the need for continue and break statements. — 2 marks · asked 1× (End Sem 2024)
- Describe list slicing with examples. — 2 marks · asked 1× (End Sem 2024)
- How filter is used in Python program? Explain with a suitable example. — 2 marks · asked 1× (End Sem 2024)
- Explain raw_input() and input() in Python. — 2 marks · asked 1× (End Sem 2024)
- Discuss the need and importance of function in python. — 2 marks · asked 1× (End Sem 2024)
- Identify what are the packages in python. — 2 marks · asked 1× (End Sem 2024)
- Demonstrate the various expressions in python with suitable examples. — 2 marks · asked 1× (End Sem 2024)
- 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)
- Describe the syntax and semantics of any two loop structures provided by Python. — 10 marks · asked 1× (End Sem 2022)
- Write a note on Python Database Application Programmer's Interface (DB-API). — 10 marks · asked 1× (End Sem 2022)
- Differentiate between thread module, threading module and related module. — 10 marks · asked 1× (End Sem 2022)
- Differentiate between function and module in Python. — 5 marks · asked 1× (End Sem 2022)
- Test whether a given year is leap year or not. — 5 marks · asked 1× (End Sem 2022)
- Write code to print Fibonacci series. — 5 marks · asked 1× (End Sem 2022)
- Differentiate between simple and advanced web clients. — 5 marks · asked 1× (End Sem 2022)
- Define pickling. — 2 marks · asked 1× (End Sem 2022)
- Python Interpreter. — 2 marks · asked 1× (End Sem 2022)
- Intermediate mode and script mode. — 2 marks · asked 1× (End Sem 2022)
- Lists in Python. — 2 marks · asked 1× (End Sem 2022)
- Define exceptions. — 2 marks · asked 1× (End Sem 2022)
- Define Recursion. — 2 marks · asked 1× (End Sem 2022)
- String lower function. — 2 marks · asked 1× (End Sem 2022)
- Define HTTP. — 2 marks · asked 1× (End Sem 2022)
- Special symbols in Python. — 2 marks · asked 1× (End Sem 2022)