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

22CS104 3

The document outlines the examination paper for Python Programming for I B. Tech. II Semester, detailing the structure and content of the exam. It includes two sections: Section A with four questions focusing on various programming tasks and Section B with two questions on exception handling and a restaurant simulation. Each section specifies the types of functions and operations students are required to implement, along with the marks allocated.

Uploaded by

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

22CS104 3

The document outlines the examination paper for Python Programming for I B. Tech. II Semester, detailing the structure and content of the exam. It includes two sections: Section A with four questions focusing on various programming tasks and Section B with two questions on exception handling and a restaurant simulation. Each section specifies the types of functions and operations students are required to implement, along with the marks allocated.

Uploaded by

devaraj48212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Regulation: R22 Code No: 22CS104/3

I B. Tech. II Semester Regular Examinations – July, 2023


PYTHON PROGRAMMING
Time: 150 Min (CSE) Max. Marks:80M

SECTION – A
Answer all Four questions 4×10M=40M

1. Design a menu driven application to perform the following for a given number and measure
the execution time taken for each bit.
a. Develop a function to find Fibonacci Series up to n
b. Develop a function to find the given number is Strong or not
c. Create function to get the Prime factors of a number
d. Create function to find Nth Armstrong number

2. Create a text file file1.py and perform the following operations

a. What are different file opening modes?


b. Develop a function to find frequency of the search key such as “was” (in small case
only) words in the text file
c. Develop a function to find frequency of a character i.e. number of ‘s’ (in small case
only) character repeated in the text file
d. Create a function to count number of lines and words in the text file
e. Create a function to count number of lowercase alphabets and uppercase alphabets in
the text file

3. Create a table that stores the details of student name, marks obtained in various courses (DS,
PS, PP, DBMS). Design and implement the following
a. Develop a function to find the details of students who secured the first rank.
b. Create a function to get the details of students who failed in all the subjects.
c. Develop separate functions to find the details of students who got highest score in a
given course.
d. Develop separate functions to find the details of students who got lowest score in a
given course.
e. Develop a function to find the average score and standard deviation in a given course.

4. a) A tuple of numbers is given. This tuple contains duplicates. Create a new tuple from the
original that contains no duplicates. Print both the tuples.
b) A sentence called line has the value “the quick brown fox jumps over the lazy dog”.
Develop a program to create a new sentence that transposes all its letters by 1, but take only
letters from ‘a’ to ‘x’. Perform this operation using list comprehension. (Note: The transpose
of letter ‘a’ is ‘b’ and ‘g’ is ‘h’)
c) Given a string “s” consisting of words and spaces, develop a function that returns the
length of the last word in the string. A word is a maximal substring consisting of non-space
characters only. For example, int the string s = "fly me to the moon “, the length of the last
substring is .

1 of 2
Regulation: R22 Code No: 22CS104/3
d) Develop a program for the given an integer number, repeatedly add all its digits until the
result has only one digit, and return it.
For example, if the Input: num = 38 then the Output: 2
Explanation: The process is
38 --> 3 + 8 --> 11
11 --> 1 + 1 --> 2
Since 2 has only one digit, return it.

e) Given an integer array ‘nums’ and an integer ‘k’, develop a function that returns the k
most frequent elements. You may return the answer in any order. For example, if nums =
[1,1,1,2,2,3], k = 2, then the output is [1,2]

SECTION - B
Answer all Two questions 2×20M=40M

5. Create a module called “Exception_Handling” to perform the following operations


a) What is Exception? Why we need an exception?
b) Throw the error which raises zero division error and address how to handle it
c) Throw the error which raises file not found error and address how to handle it.
d) Type_Error(): throw the error which raises type and address how to handle it
e) Name_Error(): throw the error which raises Name error and address how to handle it
f) Index_Error(): throw the error which raises index error and address how to handle it
g) Value_error: (): throw the error which raises value error and address how to handle it
h) Module_Not_found_Error: (): throw the error which raises module not found error and
address how to handle it
6. Simulate the following using python: Think of a restaurant with four tables, each having four
chairs. There are two waiters assigned each with two tables. The tip-sharing arrangement is that
all tips will be halved and shared. Each table can serve three batches of customers in one
evening in a FIFO manner. The average tipping per customer per batch is 100 rupees. In the
case of absence or leave of one waiter, all tables have to be served by the lone waiter and tips
will not be shared. Now consider that in off-season there is a 50-75% chance of occupancy.
Use random numbers to generate table occupancy within 75% in a 5-day off-season period.
Ordering time is one minute scaled down to 0.1 second, the serving time is 10 minutes, which
must be scaled down to 1 second and dinner time of 40 minutes must be scaled down to 4
seconds for simulation. Each table must be served simultaneously, or on FIFO basis by
designated waiter thread for full occupancy of both tables. Each customer batch can contain
between 2-4 members only.
a) Develop a function to compute the average tipping received by each waiter in the five-
day period.
b) Create a function to find if the case is that one waiter abstains for a day, what would be
difference in the amount received by both waiters
a) Design the code segment to simulate and find out average waiting time in case of absence of
one waiter.
b) Develop a function to compute the maximum possible amount of tip calculated.

2 of 2

You might also like