0% found this document useful (0 votes)
243 views2 pages

Python Programming Exam Paper 2024

This document is a question paper for the Python Programming course at Panimalar Engineering College for the April/May 2024 examinations. It outlines the course outcomes, exam structure, and includes various questions covering topics such as Python functions, data structures, file handling, and GUI programming. The paper is divided into three parts with a total of 100 marks, assessing students' understanding and application of Python concepts.

Uploaded by

monish12128h
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
243 views2 pages

Python Programming Exam Paper 2024

This document is a question paper for the Python Programming course at Panimalar Engineering College for the April/May 2024 examinations. It outlines the course outcomes, exam structure, and includes various questions covering topics such as Python functions, data structures, file handling, and GUI programming. The paper is divided into three parts with a total of 100 marks, assessing students' understanding and application of Python concepts.

Uploaded by

monish12128h
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Question Paper Code: 235487

Register No:

PANIMALAR ENGINEERING COLLEGE


An Autonomous Institution, Affiliated to Anna University
CHENNAI - 600 123
B.E/[Link] END SEMESTER EXAMINATIONS APRIL / MAY 2024
Second Semester
Common to all Branches
(Except B.E- Mechanical Engineering &
[Link]. – Computer Science and Business Systems)
23ES1201 – PYTHON PROGRAMMING
(Regulation 2023)
Maximum Marks: 100 Duration: 3 hours
Course Outcome:
CO1: Develop and execute simple Python programs using conditionals and loops for solving problems.
CO2: Express proficiency in the handling of strings and functions.
CO3: Represent compound data using Python lists, tuples, dictionaries, sets etc.
CO4: Read and write data from/to files and handle exceptions in Python programs.
CO5: Implement python packages in data analysis and design GUI.
CO6: Examine various problem solving concepts in python to develop real time applications.
Bloom’s Level: 1 - Remembering, 2 - Understanding, 3 - Applying, 4 - Analyzing, 5 - Evaluating 6 - Creating.
Answer All the Questions
Bloom’s Course Marks
PART A (10 x 2 = 20 Marks) Level Outcome Allotted

1. Differentiate between interactive mode and script mode in Python. [BL3] [CO1] [2]
2. Write a Python function to find the minimum value in a given list. [BL3] [CO1] [2]
3. Write a Python program to calculate area of a circle using functions. [BL3] [CO2] [2]
4. What is lambda function in Python? Give example. [BL1] [CO2] [2]
5. Compare lists and tuples. [BL2] [CO3] [2]
6. What will be the output of the following Python code? [BL1] [CO3] [2]
a={1:5,2:3,3:4}
[Link](3)
print(a)
7. How to open a file in Python? [BL3] [CO4] [2]
8. Distinguish errors and exceptions in python. [BL3] [CO4] [2]
9. What is Tkinter and what is its role in Python GUI programming? [BL1] [CO5] [2]
10. List the different types of charts supported by matplotlib. [BL1] [CO5] [2]

PART B (5 x 13 = 65 Marks)
11.a Develop a python program to illustrate the use of various operators [BL3] [CO1] [13]
and explain its types?
Question Paper Code: 235487

OR
11.b Explain in detail about control flow statements with examples. [BL2] [CO1] [13]
12.a Explain recursion with suitable examples. [BL2] [CO2] [13]
OR
12.b Explain in detail about the operations and methods of strings with [BL2] [CO2] [13]
example.
13.a Outline in detail about lists, list operations and list slices. [BL2] [CO3] [13]

OR
13.b Show how dictionaries are used in python programs. Also discuss [BL3] [CO3] [13]
various operations on dictionaries.
14.a Develop a python program to read and write from a text file. [BL3] [CO4] [13]

OR
14.b Discuss how user-defined exceptions are used in python. Write a [BL3] [CO4] [13]
python program for a banking application to implement a user-defined
exception called ‘InsufficientFundsError’, raised whenever a
withdrawal operation is attempted with insufficient funds in the
account.
15. Analyze the various Tkinter widgets available for creating interactive [BL3] [CO5] [13]
a GUIs in Python, comparing their features and functionalities.
OR
15.b Implement a GUI program using Tkinter to create a mark sheet [BL3] [CO6] [13]
application where users can input student marks and view the
average score.
PART C (1 x 15 = 15 Marks)
16.a Compare the advantages and limitations of lists, tuples, dictionaries, [BL5] [CO3] [15]
and sets.
OR
16.b Write a Python program that reads a sales dataset from a file using [BL5] [CO6] [15]
pandas, performs basic data cleaning and manipulation tasks using
numpy and pandas functions.

**********

Common questions

Powered by AI

Python's file handling capability allows you to perform reading and writing operations using built-in functions such as open(), read(), write(), and close(). Files can be opened in different modes such as read ('r'), write ('w'), append ('a'), and binary ('b'), providing flexibility in data manipulation. Ensuring data integrity during these operations involves handling exceptions that may occur during file I/O operations, using try-except blocks to prevent data corruption or loss. Opening files in 'with' statement context ensures files are properly closed after operations are completed, thus maintaining data integrity and resource management .

Lists and tuples are both sequence data types that can store a collection of items. The key difference is that lists are mutable, allowing for modification such as adding, removing, or changing items after creation, whereas tuples are immutable once defined. This immutability means tuples can be safer to use when you do not want data to be modified, reducing the risk of errors in programs that depend on constants. Performance-wise, tuples can be slightly faster than lists when iterating through them or accessing elements, due to the fixed size. This makes tuples more efficient in terms of iteration and makes them better candidates for keys in dictionaries .

Recursion in Python is implemented through functions that call themselves. Recursive functions require a base case to stop recursion and a recursive case that leads to the base case, thereby forming a loop of function calls. Recursion is particularly beneficial in problems that can be divided into similar sub-problems, such as searching and sorting algorithms, tree traversals, and solutions to problems like the Fibonacci sequence and factorial computation. It simplifies the code and logic models, making them more readable compared to complex iterative counterparts. However, recursion can be less efficient in terms of memory usage due to the call stack, thus it should be used judiciously depending on the problem constraints .

Lists are flexible data structures allowing for ordered data storage and manipulation, suitable for applications requiring frequent data modifications. Tuples, being immutable, are advantageous for storing fixed collections of items that should not change, such as constant definitions. Dictionaries provide a mapping type, well-suited for situations needing fast lookups by unique keys, making them ideal for database-style applications. Sets, which store unordered unique items, are optimal for membership tests and removing duplicates. While lists and dictionaries offer ease of update, they can be less performant due to higher memory consumption, whereas tuples and sets provide faster performance and reduced memory usage .

Dictionaries in Python offer several operations useful for complex data manipulation, including key-value pair addition, deletion, and modification. You can use methods like .get() to safely retrieve values, .keys(), .values(), and .items() to iterate over the dictionary, and .update() to merge dictionaries. Additionally, the pop() method allows for the removal of a specified key and its value, and clear() removes all the items from the dictionary. These operations facilitate complex data manipulation by providing flexible tools to efficiently manage collections of key-value pairs, which is particularly beneficial in applications needing fast lookups, frequent updates, and organization of data .

In a real-time banking application, Python's exception handling can significantly enhance reliability by managing errors related to transactions. For instance, network disconnections during online transactions could be covered under IOError or NetworkError. Database interaction might generate exceptions such as DatabaseError or IntegrityError when data constraints fail. Handling custom exceptions like InsufficientFundsError ensures that withdrawal attempts with insufficient balance are managed gracefully, providing clear feedback to the user without crashing the entire application. Proper exception handling ensures continuity of service and maintains user trust by providing structured problem-solving paths .

Tkinter is a standard Python library for constructing graphical user interfaces (GUIs). It provides a range of widgets which are essential for building the interface of an application including labels, buttons, checkboxes, text boxes, and frames. These widgets are used to take input from the user and display output, hence enhancing user interaction. For example, buttons can trigger actions within a program, entry widgets can receive user input, and canvas widgets can be used to draw graphics. The comprehensive widget set available in Tkinter allows developers to design complex and responsive user interfaces efficiently .

Python handles exceptions through the use of try, except, finally, and else blocks which capture and deal with errors during runtime to prevent code from crashing. These blocks allow for executing alternate code if an error occurs or for cleaning up resources with finally. Defining user-defined exceptions is important in robust software development as it offers the ability to create specific error handling logic that is more aligned with the application's domain knowledge. For example, defining a custom InsufficientFundsError in a banking application ensures precise control over error conditions unique to the application’s logic, thus making the software more reliable and easier to debug and maintain .

Interactive mode in Python allows for the execution of Python commands one at a time, providing immediate feedback, which is useful for testing small code snippets and debugging. It is commonly used in the command line or shells like IDLE. Script mode, on the other hand, involves writing Python code in a file and executing the entire file as a script. This is more suitable for larger programs and has the benefit of saving your code for future use. Debugging in script mode requires running the program to where an error may be, whereas interactive mode allows for immediate correction. Script mode is more advantageous for developing complex applications due to its ability to save and organize code in files .

Nested data structures in Python require iterative or recursive approaches to access deep levels of data. To efficiently access this data, using loops or comprehensions can help navigate through layers, while indexing is used to access specific elements. For instance, a list within a dictionary can be accessed by invoking the dictionary key followed by the list index. Libraries like Pandas can provide higher-level functions for data manipulation in nested structures, allowing complex operations like data selection or filtering in a concise way. Key considerations include ensuring error handling for cases where keys or indices may not exist, avoiding runtime errors .

You might also like