AKTU PYTHON PYQ
AKTU PYTHON PYQ
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
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
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
5. Return a list that reverses all the elements starting from element at index
-2
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-
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
2
3. Attempt any one part of the following:
13
_2
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
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
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
|1
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
3|Page
QP24DP2_290 | 12-03-2024 13:20:30 | 117.55.242.132
Printed Page: 1 of 2
Subject Code: BCC402
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM IV) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3 HRS M.MARKS: 70
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
SECTION A
4
19
SECTION B
92
5.
2. Attempt any three of the following: 7 x 3 = 21
_2
.6
a. Explain the concept of dynamic typing in Python with an example.
P2
40
b. Explain how to define a list in Python. Write a Python program to remove
4E
.2
duplicates from a list and print the resulting list.
15
P2
c. Explain the concept of functions in Python. Write a function that takes a list of
|1
Q
numbers and returns the sum of all the numbers in the list.
d. Write a Python program to read a file named “ABC.txt” and count the number
PM
program to plot a simple line graph showing the relationship between x = [1, 2,
:0
SECTION C
24
(a) Explain for and while loops used in Python with appropriate example.
g-
(a) Write a program takes two strings and checks common letters in both the
|0
strings.
Enter first string: Hari
Enter second string: Hale
The common letters are:
H
a
(b) Write a Python Program to find the sum all the items in a dictionary.
For example if d={'A':100,'B':540,'C':239}then output should be 879.
1|Page
QP24EP2_292 | 07-Aug-2024 1:40:02 PM | 115.240.65.194
Printed Page: 2 of 2
Subject Code: BCC402
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM IV) THEORY EXAMINATION 2023-24
PYTHON PROGRAMMING
TIME: 3 HRS M.MARKS: 70
4
a DataFrame from a dictionary and print it.
19
92
5.
_2
.6
P2
40
4E
.2
15
P2
|1
Q
PM
2
:0
40
1:
24
20
g-
Au
7-
|0
2|Page
QP24EP2_292 | 07-Aug-2024 1:40:02 PM | 115.240.65.194
Printed Page: 1 of 4
Subject Code: KNC302
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
B.TECH
(SEM III) THEORY EXAMINATION 2020-21
PYTHON PROGRAMMING
Time: 3 Hours Total Marks: 100
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 CO
a. What is the use of “raise” statement? Describe with an example. 2 5
P
program.
0Q
1
13
e. Which of the following statements produce an error in Python? 2 1
29
x, y, z = 1,2,3 # s1
2.
0E
a, b = 4,5,6 # s2
24
P2
u = 7,8,9 # s3
5.
(List all the statements that have error.)
_Q
.5
f. Explain the role of precedence with an example. 17 2 1
TU
56
x[ 0] *= 3
x [ 1] [ 1] = ' by e'
1
02
( l ambda x , y : y - 2* x ) ( 1, 11)
2-
|1
SECTION B
2. Attempt any three of the following:
Q no. Question Marks CO
a. Write a Python function removekth(s, k) that takes as input a 10 5
string s and an integer k>=0 and removes the character at index k. If k
is beyond the length of s, the whole of s is returned. For example,
P
d. Write a function lessthan(lst, k) to return list of numbers less 10
0Q 4
than k from a list lst. The function must use list comprehension.
1
Example:
13
29
2.
0E
24
e. Write a program factors(N) that returns a list of all positive divisors 10 2
P2
5.
of N (N>=1). For example:
_Q
.5
factors(6) returns [1,2,3,6] 17
factors(1) returns [1]
TU
56
SECTION C
7:
a. How can you create Python file that can be imported as a library as well 10 5
1
import library
and
M
library.
makePairs([1,3,5,7],[2,4,6,8])
returns [(1,2),(3,4),(5,6),(7,8)]
makePairs([],[])
returns []
P
0Q
a. Explain why Python is considered an interpreted language. 10 1
1
13
29
2.
0E
Python program?
24
a = 0
P2
5.
b = 2
_Q
.5
c = 3 17
x = c or a
TU
print(x)
|1
AK
56
7:
:0
14
1
02
-2
ar
M
2-
|1
triangle(3) prints:
*
**
***
triangle(5) prints:
*
**
***
****
*****
P
countSquares(1) returns 1
0Q
1
# Only 1 is a perfect square <= 1
13
29
countSquares(5) returns 2
2.
# 1, 4 are perfect squares <= 5
0E
24
countSquares(55) returns 7
P2
5.
_Q
.5
17
7. Attempt any one part of the following:
TU
|1
in lst are alternately odd and even, starting with an even number.
: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
2.
2_
24
(e) How do you perform a search in Python? 5
2P
5.
SECTION B
.5
P2
|1
(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
Qno Questions CO
(a) Write a Python program to construct the following pattern, using a 2
nested for loop.
*
**
***
****
*****
BTECH
(SEM III) THEORY EXAMINATION 2021-22
PYTHON PROGRAMMING
****
***
**
*
(b) Write a program to produce Fibonacci series in Python. 4
1
13
0
29
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
|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
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
2
90
13
(h) What is object-oriented programming (OOP) in Python? Give an example.
_2
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("@".join(list1))
3
02
SECTION B
-2
(a) Demonstrate five different built in functions used in the string. Write a
1-
(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.
(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
2.
P2
24
6. Attempt any one part of the following: 5x1 = 5
5.
3D
.5
P2
|1
(b) Explain Binary search with its python code and complexity.
9
:1
suitable example.
02
(b) Summarize the ‘Tower of Hanoi’ puzzle and write its recursive function to
-2
implement it.
03
1-
|2
B.Tech.
(SEM IV) THEORY EXAMINATION 2022-23
PYTHON PROGRAMMING
Note: Attempt all Sections. If require any missing data; then choose suitably.
SECTION A
2
defprintalpha (abc_list, num_list):
13
for char in abc_list:
_2
2.
for num in num_list:
P2
24
print(char, num)
return
3E
5.
printalpha (['a', 'b', 'c'], [1, 2, 3])
.5
P2
|1
i. Compare assert, try-except and raise statements.
j. Write python function to perform linear search.
0
:3
: 24
13
SECTION B
3
02
a. Write Python code snippet to display n terms of Fibonacci series using recursion.
1-
b. Write and explain an algorithm through python code to generate prime numbers.
|0
c. Compare list and tuple data structure with suitable examples. Explain the concept
of list comprehension.
d. Explain the python implementation of stack ADT.
e. Describe python program to implement selection sort. Simulate your code on the
following data
2,52,1,5,2,54,62,64.
i) a &b<<2//5**2+c^b
ii) b>>a**2<<2 >> b**2^c**3
2
HELLO WORLD
13
_2
PRACTICE MAKES PERFECT
2.
P2
24
5. Attempt any one part of the following: 10x1=10
3E
5.
.5
P2
a. Discuss list data structure of python. Explain various inbuilt methods of list with
suitable example of each.
17
Q
b. Compare list and dictionary data structure. Explain various dictionary methods
|1
with suitable examples of each.
0
:3
a. Discuss the concept of Iterators in python. Explain, how we can create text file
13
in python? Describe python program to write the number of letters and digits in
given input string into a File object.
3
02
suitable example.
08
1-
a. Explain the Tower of Hanoi problem and its recursive solution in Python.
b. Write python program to implement merge sort algorithm. Discuss, how we can
compare the time complexity of two algorithms?
BTECH
(SEM IV) 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*4 = 10
Qno Questions CO
(a) Discuss why Python is called as dynamic and strongly typed language? 1
(b) How pass statement is different from a comment? 2
(c) Write a for loop that prints numbers from 0 to 57, using range function. 2
(d) What is the difference between Python Arrays and Lists? 3
SECTION B
2. Attempt any two of the following: 4*2 = 8
Qno Questions CO
(a) Write a python function named ComputeAverage to find average of a list of 3
numbers. It should handle the exception if the list is empty and return 0 in
that case.
(b) Implement the binary search technique. 5
(c) Explain the use of break and continue with a suitable example. 2
90
2
13
SECTION C
_2
2.
Qno Questions CO
P2
24
(a) What do you mean by operator precedence and associativity. Explain. 1
2E
5.
(b) Write short notes on 1
.5
P2
Qno Questions CO
2
2:
(b) Write a program that accepts a sentence and calculate the number of digits, 2
13
Qno Questions CO
-2
(a) There is a file named Input.Txt. Enter some positive numbers into the file 4
08
named Input.Txt. Read the contents of the file and if it is an odd number
write it to ODD.TXT and if the number is even, write it to EVEN.TXT
2-