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

Assignment For Essential of Python

Uploaded by

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

Assignment For Essential of Python

Uploaded by

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

Assignment

Paper code & Name: 2346000007- Essential of Python


Course Name: SEC, Sem: III
Deadline: November 15, 2024 Maximum Marks: 15

➢ Attempt all questions.


Question 1: Explain the concept of errors and exceptions in programming. How do they
differ, and why is it crucial to handle exceptions in code?

Question 2: Given a code snippet using a try-except block, identify the purpose of this block
and explain how it handles potential errors.

Question 3: Enumerate and describe at least five common types of exceptions in Python.
Provide examples of scenarios where each type might occur.

Question 4: Explain the difference between ‘r’, ‘w’, and ‘a’ file modes in Python. Provide
examples for each mode and describe how you would handle a ‘FileNotFoundError’
exception while working with files in ‘r’ mode.

Question 5: Demonstrate the usage of the ‘with’ statement in file handling. Explain how it
ensures proper file closure and exception handling, comparing it to the traditional way of
opening and closing files manually.

Question 6: Define polymorphism in the context of object-oriented programming. Create a


Python class with multiple subclass that override a method from their parent class. Explain
how this demonstrates polymorphic behavior.

Question 7: Explain the concept of generators and how they differ from regular functions in
Python. Provide an example of a generator functions with lists or iterables, and explain their
return values and usage in logical operations.

Question 8: Write a Python function that takes a list of integers as input and returns a new list
containing only the even numbers from the original list using list comprehension. Ensure the
function has a default parameter to handle empty input lists. Demonstrate the function by
providing an example.

P.T.O
Question 9: Create a Python program that simulates a simplified version of a Google Form
using Tkinter. Include components such as labels, entry widgets for user input, check buttons
for multiple-choice options, and a submit button. Upon clicking the submit button, display the
collected information in the console.

Question 10: Create a Python program that interacts with an SQLite database. Define a table
named 'Employees' with columns for 'id' (integer), 'name' (text), 'age' (integer), and 'salary'
(real). Perform the following operations:

➢ Insert two new employees into the table.


➢ Display all records from the 'Employees' table.
➢ Update the salary of one employee.
➢ Delete one employee record.
➢ Implement commit and rollback operations to ensure the changes are appropriately
managed.

Question 11: Create a Python-based chat application where multiple clients can connect to a
central server to exchange messages.

➢ Design a server program that listens on a specific port for incoming connections from
clients and manages the chat functionality.
➢ Develop a client program that can connect to the chat server, send messages, and
receive messages from other connected clients.
➢ Ensure that messages from each client are broadcasted to all other connected clients.

Question 12: How do Python's 'filter', 'map', and 'reduce' functions work with examples, and
what role do decorators play in modifying their behavior? Additionally, explain the concept
and usage of frozen sets in Python.

Question 13: Could you explain how regular expressions in Python can be used to split
strings, handle special characters, validate dates and emails, utilize quantifiers, and
differentiate between 'match' and 'findall methods in regex with suitable examples?

Question 14: Write a Python code snippet that defines three tasks as separate functions and
assigns each task to a thread using the 'threading module. Additionally, demonstrate how you
would handle multi-threading and synchronization issues within these tasks.

Question 15: Describe how you would access the Facebook Messenger API using Python,
outlining the essential steps to authenticate and send messages through the API. Provide a
code snippet demonstrating the process.

All the Best

P.T.O

You might also like