0% found this document useful (0 votes)
198 views

Attempt Any: Six Question(s) 5 Marks

This document provides instructions for a programming exam in Python. It contains 7 questions asking students to write Python code to: 1) Create a wrapper function for the open() function that returns None instead of raising an error if a file fails to open. 2) Describe the need for try/except statements to catch exceptions. 3) Import functions from 3 different modules into a Python program. 4) Explain the difference between modules and packages, and the purpose of creating multiple packages and modules. 5) Use regular expressions to extract numbers from lines in a text file and compute the average. 6) Create a GUI with buttons that update a label with the text of the button

Uploaded by

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

Attempt Any: Six Question(s) 5 Marks

This document provides instructions for a programming exam in Python. It contains 7 questions asking students to write Python code to: 1) Create a wrapper function for the open() function that returns None instead of raising an error if a file fails to open. 2) Describe the need for try/except statements to catch exceptions. 3) Import functions from 3 different modules into a Python program. 4) Explain the difference between modules and packages, and the purpose of creating multiple packages and modules. 5) Use regular expressions to extract numbers from lines in a text file and compute the average. 6) Create a GUI with buttons that update a label with the text of the button

Uploaded by

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

B.Tech. (Computer Science & Engineering) (Sem.

– 3)
Programming in Python
Subject Code: BTCS 510-18
MST -11

Time: 2 Hrs Max. Marks: 30


INSTRUCTIONS TO CANDIDATES:

 Attempt any Six question(s), each question carries 5 marks.

Que 1. Create a wrapper for the open() function. When a program opens a file successfully, a file handle
will be returned. If the file open fails, rather than generating an error, return None to the callers so
that they can open files without an exception handler.
Que 2. Describe the need for catching exceptions using try and except statements.
Que 3. Suppose there are three modules m1.py, m2.py, m3.py, containing function f1(), f2(), and f3()
respectively. How will you use those function in your program?
Que 4. (a) what is the difference between a module & a package.
(b) what is the purpose behind creating multiple packages and modules?
Que 5. Why do you need regular expressions in Python? Consider a file “ait.txt”. Write a Python program
to read the file and look for lines of the form X-DSPAM-Confidence: 0.8475 X-DSPAM-
Probability: 0.458 Extract the number from each of the lines using a regular expression. Compute
the average of the numbers and print out the average.
Que 6. With the help of Label & Button Widget write a script to create three buttons and perform the
following operation on that Pressing any of the three buttons will result in changing the text label
so that it will then contain the text of the Button (widget) that was pressed.
Que 7. Take any existing database table, and use the knowledge you developed from Database
Programming and output the contents of a database table into an HTML table.

Note:
 Any student found attempting answer sheet from any other person(s), using incriminating material
or involved in any wrong activity reported by evaluator shall be treated under UMC provisions.
 Student found sharing the question paper(s)/answer sheet on digital media or with any other person
or any organization/institution shall also be treated under UMC.
 Any student found making any change/addition/modification in contents of scanned copy of
answer sheet and original answer sheet, shall be covered under UMC provisions.
IN Case of UMC: All MST will be Cancelled and no Internal Mark’s will be Awarded.

You might also like