0% found this document useful (0 votes)
22 views7 pages

Python 2022-2024 Previous Paper

The document outlines the structure of a Python Programming examination for BTECH students, detailing various sections and questions that cover topics such as list comprehension, operators, functions, and data manipulation. It includes multiple-choice questions, programming tasks, and theoretical explanations, requiring students to demonstrate their understanding of Python concepts. The exam is designed to assess knowledge and practical skills in Python programming over a duration of three hours.

Uploaded by

amitkumar23june
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)
22 views7 pages

Python 2022-2024 Previous Paper

The document outlines the structure of a Python Programming examination for BTECH students, detailing various sections and questions that cover topics such as list comprehension, operators, functions, and data manipulation. It includes multiple-choice questions, programming tasks, and theoretical explanations, requiring students to demonstrate their understanding of Python concepts. The exam is designed to assess knowledge and practical skills in Python programming over a duration of three hours.

Uploaded by

amitkumar23june
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
You are on page 1/ 7

Printed Page: 1 of 3

Subject Code: BCC302


0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0

BTECH
(SEM III) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3HRS M.MARKS: 70

Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
SECTION A

1. Attempt all questions in brief.


Q no. Question Marks
a. Describe the concept of list comprehension with a suitable example 2
b. Differentiate between / and // operator with an example 2
c. Compute the output of the following python code: 2
def count(s):
for str in string.split():
s = “&”.join(str)
return s
print(count(“Python is fun to learn.”))
d. How to use the functions defined in library.py in main.py 2
e. Describe the difference between linspace and argspace. 2
f. Explain why the program generates an error. 2
90

2
x = [‘12’, ’hello’, 456]

13
_2

x[0] *= 3

2.
x[1][1]=’bye’
P2

24
g. Describe about different functions of matplotlib and pandas. 2
4D

5.
SECTION B

.5
P2

2. Attempt any three of the following:


17
Q

a. Illustrate Unpacking tuples, mutable sequences, and string concatenation with 7


|1

examples
b. Illustrate different list slicing constructs for the following operations on the 7
3 0

following list:
0:

L = [1, 2, 3, 4, 5, 6, 7, 8, 9]
:2

1. Return a list of numbers starting from the last to second item of the list
13

2. Return a list that start from 3rd item to second last item.
3. Return a list that has only even position elements of list L to list M.
4

4. Return a list that starts from the middle of the list L.


02

5. Return a list that reverses all the elements starting from element at index
-2

0 to middle index only and return the entire list.


03

Divide each element of the list by 2 and replace it with the remainder.
c. Construct a function perfect_square(number) that returns a number if it is a perfect 7
2-

square otherwise it returns -1.


|1

For example:
perfect_square(1) returns 1
perfect_square (2) returns -1
d. Construct a program to change the contents of the file by reversing each character 7
separated by comma:
Hello!!
Output
H,e,l,l,o,!,!
e. Construct a plot for following dataset using matplotlib : 7
1|Page
QP24DP2_290 | 12-03-2024 13:20:30 | 117.55.242.132
Printed Page: 2 of 3
Subject Code: BCC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0

BTECH
(SEM III) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3HRS M.MARKS: 70

Food Calories Potassium fat


Meat 250 40 8
Banana 130 55 5
Avocados 140 20 3
Sweet
Potatoes 120 30 6
Spinach 20 40 1
Watermelon 20 32 1.5
Coconut
water 10 10 0
Beans 50 26 2
Legumes 40 25 1.5
Tomato 19 20 2.5
SECTION C
90

2
3. Attempt any one part of the following:

13
_2

a. Determine a python function removenth(s,n) that takes an input a string and an 7

2.
integer n>=0 and removes a character at index n. If n is beyond the length of s,
P2

24
then whole s is returned. For example:
4D

5.
removenth(“MANGO”,1) returns MNGO
removenth(“MANGO”,3) returns MANO
.5
P2

17
Q

b. Construct a program that accepts a comma separated sequence of words as input 7


|1

and prints the words in a comma-separated sequence after sorting them


alphabetically.
3 0

Suppose the following input is supplied to the program:


0:

without, hello, bag, world


:2

Then, the output should be:


13

bag, hello, without, world


4. Attempt any one part of the following:
4
02

a. A website requires the users to input username and password to register. Construct 7
a program to check the validity of password input by users.
-2

Following are the criteria for checking the password:


03

1. At least 1 letter between [a-z]


2-

2. At least 1 number between [0-9]


|1

3. At least 1 letter between [A-Z]


4. At least 1 character from [$#@]
5. Minimum length of transaction password: 6
6. Maximum length of transaction password: 12
Your program should accept a sequence of comma separated passwords and will
check them according to the above criteria. Passwords that match the criteria are
to be printed, each separated by a comma
b. Explore the working of while, and for loop with examples. 7
5. Attempt any one part of the following:

2|Page
QP24DP2_290 | 12-03-2024 13:20:30 | 117.55.242.132
Printed Page: 3 of 3
Subject Code: BCC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0

BTECH
(SEM III) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3HRS M.MARKS: 70

a. Construct a function ret smaller(l) that returns smallest list from a nested list. If 7
two lists have same length then return the first list that is encountered. For
example:

ret smaller([ [ -2, -1, 0, 0.12, 1, 2], [3, 4, 5], [6 , 7, 8, 9, 10], [11, 12, 13, 14, 15]])
returns [3,4,5]
ret smaller([ [ -2, -1, 0, 0.12, 1, 2], [‘a’, ’b’, ’c’, ’d’, 3, 4, 5], [6 , 7, 8, 9, 10], [11,
12, 13, 14, 15]]) returns [6 , 7, 8, 9, 10]
b. Construct following filters: 7
1. Filter all the numbers
2. Filter all the strings starting with a vowel
3. Filter all the strings that contains any of the following noun: Agra,
Ramesh, Tomato, Patna.
Create a program that implements these filters to clean the text.
6. Attempt any one part of the following:
a. Change all the numbers in the file to text. Construct a program for the same. 7
90

2
Example:

13
_2

Given 2 integer numbers, return their product only if the product is equal to or lower

2.
than 10.
P2

24
And the result should be:
4D

Given two integer numbers, return their product only if the product is equal to or

5.
lower than one zero
.5
P2

b. Construct a program which accepts a sequence of words separated by whitespace 7


17
as file input. Print the words composed of digits only.
Q

|1

7. Attempt any one part of the following:


a. Construct a program to read cities.csv dataset, remove last column and save it in 7
3 0

an array. Save the last column to another array. Plot the first two columns.
0:

b. Design a calculator with the following buttons and functionalities like addition, 7
:2

subtraction, multiplication, division and clear.


13
4
02
-2
03
2-
|1

3|Page
QP24DP2_290 | 12-03-2024 13:20:30 | 117.55.242.132
Printed Pages: 02 Sub Code:KNC-302

Paper Id: 233077 Roll No.

B.TECH.
(SEM III) THEORY EXAMINATION 2022-23
PYTHON PROGRAMMING
Time: 3 Hours Total Marks: 50
Note: Attempt all Sections. If you require any missing data, then choose suitably.

SECTION A

1. Attempt all questions in brief. 1x10 = 10

(a) Explain the Programming Cycle for Python in detail.


(b) Describe the concept of List Slicing with a suitable example.
(c) Show the way to import the module in python.
(d) Differentiate between Python Arrays and lists?
(e) Define floor division with an example.
(f) Explain the difference between 'append' and 'extend' in Python?
(g) What is a dictionary in Python?

2
90

13
(h) What is object-oriented programming (OOP) in Python? Give an example.
_2

(i) What will be the output of the following python code

2.
P2

24
def count1(s):

5.
3D

vowels = "AEIOUaeiou"
count = 0

.5
P2

for c in s:
if c in vowels: 17
Q

|1
count += 1
return count
9

print(count1(‘I love India’))


:1
31

(j) What will be the output of the following code?


list1 = ['M', 'o', 'n', 'k', 'y']
:
13

print("@".join(list1))
3
02

SECTION B
-2

2. Attempt any three of the following: 5x3 = 15


03

(a) Demonstrate five different built in functions used in the string. Write a
1-

program to check whether a string is a palindrome or not.


|2

(b) Explain the following loops with a flow diagram, syntax, and suitable
examples.
I) For II) while
(c) Explain the continue, break, and pass statements with a suitable example.
(d) Develop a program to calculate the reverse of any entered number.
(e) Explain the list Comprehension with any suitable example.

QP23DP2_290 | 21-03-2023 13:31:19 | 117.55.242.132


SECTION C
3. Attempt any one part of the following: 5x1 = 5

(a) Illustrate Unpacking Sequences, Mutable Sequences, and List


comprehension with examples.
(b) Explain the lambda function. How it is helpful in the higher order function.
Explain map() function with a suitable example.

4. Attempt any one part of the following: 5x1 = 5

(a) Discuss the different types of argument-passing methods in python. Explain


the variable length argument with any suitable example.
(b) Write short notes on the following with a suitable example
I) Encapsulation II) Inheritance

5. Attempt any one part of the following: 5x1 = 5

(a) Demonstrate the file handling procedure in detail. Write a python code to
create a file with ‘P.txt’ name and write your name and father’s name in this

2
file and then read this file to print it.
90

13
(b) Demonstrate the ‘Sieve of Eratosthenes’ theorem and write the python
_2

function to print prime numbers between 1 to 100.

2.
P2

24
6. Attempt any one part of the following: 5x1 = 5

5.
3D

.5
P2

(a) Develop and write the python code of selection sort


17
41,65,43,91,12,14,62 elements. Also, explain its complexity.
to sort
Q

|1
(b) Explain Binary search with its python code and complexity.
9
:1

7. Attempt any one part of the following: 5x1 = 5


: 31
13

(a) Explain the importance of Exception handling in any object-oriented


programming language. Explain try exceptions and finally block with any
3

suitable example.
02

(b) Summarize the ‘Tower of Hanoi’ puzzle and write its recursive function to
-2

implement it.
03
1-
|2

QP23DP2_290 | 21-03-2023 13:31:19 | 117.55.242.132


Printed Page: 1 of 2
Subject Code: KNC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0

BTECH
(SEM III) THEORY EXAMINATION 2021-22
PYTHON PROGRAMMING
Time: 3 Hours Total Marks: 50
Note: Attempt all Sections. If you require any missing data, then choose suitably.

SECTION A
1. Attempt all questions in brief. 2*5 = 10
Qno Questions CO
(a) Explain the Programming Cycle for Python in detail. 1
(b) What will be the output of the following Python code? 2
i=0
while i< 3:
print(i)
i += 1
else:
print(0)
(c) What will be the output of the following Python code? 3
def cube(x):
return x * x * x

1
x = cube(3)

13
0
print x
29

(d) How do we define an Interface for an ADT? 4

2.
2_

24
(e) How do you perform a search in Python? 5
2P

5.
SECTION B

.5
P2

2. Attempt any three of the following: 5*3 = 15


17
Qno Questions CO
Q

|1

(a) What do you mean by Python IDE? Explain in detail. 1


(b) How can you randomize the items of a list in place in Python? 2
6
:3

(c) Explain Tuples and Unpacking Sequences in Python Data Structure. 3


25

(d) What are File input and output operations in Python Programming? 4
(e) Solve the Tower of Hanoi problem for n= 3 disk and show all the steps. 5
:
13

SECTION C
2
02

3. Attempt any one part of the following: 5*1 = 5


Qno Questions CO
-2

(a) Write a program in Python to execute the Selection sort algorithm. 5


ar

(b) Explain why python is considered an interpreted language. 1


M
2-

4. Attempt any one part of the following: 5 *1 = 5


|2

Qno Questions CO
(a) Write a Python program to construct the following pattern, using a 2
nested for loop.

*
**
***
****
*****

QP22P2_290 | 22-Mar-2022 13:25:36 | 117.55.242.131


Printed Page: 2 of 2
Subject Code: KNC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0

BTECH
(SEM III) THEORY EXAMINATION 2021-22
PYTHON PROGRAMMING
****
***
**
*
(b) Write a program to produce Fibonacci series in Python. 4

5. Attempt any one part of the following: 5*1 = 5


Qno Questions CO
(a) Write a Python program to change a given string to a new string where 3
the first and last chars have been exchanged.
(b) Write a Python program to add an item in a tuple. 3

6. Attempt any one part of the following: 5*1 = 5


Qno Questions CO
(a) How to create and import a module in Python? 4
(b) Explain the algorithm Sieve of Eratosthene used in Python 4
Programming.

1
13
0
29

7. Attempt any one part of the following: 5*1 = 5

2.
2_

Qno Questions CO

24
(a) Write a Recursive function in python BinarySearch(Arr,l,R,X) to 5
2P

5.
search the given element X to be searched from the List Arr having R

.5
P2

elements, where l represent slower bound and R represents the upper


17
bound.
Q

|1

(b) Explain the terms Merge List and Merge Sort in Python Programming. 5
6
:3
: 25
13
2
02
-2
ar
M
2-
|2

QP22P2_290 | 22-Mar-2022 13:25:36 | 117.55.242.131

You might also like