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

Python Sem 3 Paper

Uploaded by

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

Python Sem 3 Paper

Uploaded by

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

Printed

Code: BCC302
PAPER ID-311224
Subject
Roll No:

BTEC!1
22oosoolo8
(SEM II) THEORY EXA
PYTHON MINATION 2023-24
TIME: 3HRS PROGRAMMING
M.MARKS: 70
Note: 1. Attempt all Sections. It require any missing
data: then choose
suitably
STCTION A
1. Attempt all questions in brief.

|Qno
Qustio
Marks
Deseribe the concept of.list comprehenion with suitable exannpie

ia
Differeniate between and // operator NIth an cxample

/
C
Compute the output of the following p thon code:
2
def count(s):

for str in string.split):

S
"&"join(str)
returns

print(count("Pythonis fun to learn.")


How to use the functions defined in library.py in main.py 2
e Describe the difference between linspace and argspace.
f Explain why the program generates an error. 2
X -[12, hello', 456]
x[0] *= 3
x[1I[1]-°bye'
Describe about different functions of matplotlib and pandas.
SICTION B
2. Attempt any iree o1 the tolloWIng:
a.
Illustrate Unpacking tuples, mutable sequences, and sring concatenation with7
examples
Illustrate different list slicing constructs for the following operations on the
following list:

L-[1,2, 3.4, 5, 7, 8,9]


6.,
1. Return a list of numbers starting from the last to second item of the list
2. Return a list that start from 3rd item to second last item.
3. Return alist that has only even position elements of list L to list M.
4. Return a list that starts from the middle of the list L.
5. Return a list that reverses all the
clements starting from element at index
0 to middle index only and return the entire list.

Divide cach clement of the list by 2


and replace it with theremainder
C.
Construct a function perfevt square{nunnber) that
returnsa number ifit is a perfect 7
square otherwise ii returns -1.
For exanmple:
perfcct square(I) returns
I
perfect square (2) reiurns -1
Construct a program to change the contents of the file by reversin: cach character7
separated by comma:
Hello!!

Output

H.e,l.l.o,!,!

VC. Construct a plot for following dataset


using matplotlib 7
1|2e

Galaxy A23
Printed Page: 2 of 3
PAPERID-311224 Subject Code: BCC302
Roll No:

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

Food Calories Potassiun ial

Meat 250 40 8
Banana 130 55
Avocados 140 20
Sweet
Potatoes 120 30 6
Spinach 20 40

1
Watermelon 20 32 1.5

Coconut
water 10 10
Beans 50 26 2
Legumes 40 25 1.5

Tomato 20 2.5
SECTION C
3.
Attempt any one part of the following:
a.
Determine a pvthon function remove1i(s,n) that takes an input a string and an
integer n>=0and removes a character at index n. Ifn is beyond the length of s.
then whole s is returned. For example:

removenth("MANGO", 1)returns MNGO


removenth("MANGO",3) returns MANO

Construct a program that accepts a conima separated sequence of words as input


and prints the words in a comma-separated sequence after sorting them
alphabetically.
Suppose the following input is supplied to the program:
without. hello, bag. world
Then, the output should bc:

bag, hello, without, world


4
Attempt any one part of the following:

A website requires the users to input usename and passwordto registcr. Construct 7
a program to check the validity of passvord input by users.

Following are the criteria sorcheckingne password:


1. At least 1 letter between [a-z]
2, At least 1 number between [0-91
3. At least 1 letterbetween [A-Z]
4. At least I character from [S#@]
5. Minimum length of transaction password: 6
6. Maximum length of transaction password: 12

Your program should accept a sequenceof comma separated passwords and will
check them according to the above criteria. Passwords that match the criteria
are
to be printed, cach separatcd by a
comrma
b. Explorethe working of while, and for loop with examples.
5. Attempt any one part of the following:

Galaxy A23 2|e


PrinteTage
Code:
BCC302
PAPER ID-311224 Subject
Roll No:
BTECH
(SEM II) THEORY EXAMINATION
2023-24
TIME: 3HRS PYTHON PROGRAMMING
M.MARKS: 70
a Construct a function ret smaller(l) that returns smallest
two lists have same length then
list from a nested list. If7
return the first list that is encountered. For
example:

ret smaller(| [-2, -1, 0, 0.12, 1, 21. (3.1, 51. [6.7,8,9. 101,(11,12, 13, 14, 1511)

returas [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, 1O
7
b Construct following filters:

1. Filter all the numbers


all the strings starting with a vowel
2. Filter
contains any of the following noun: Agra,
3. Filter all the strings that

Ramesh, Tomato,Patna.
to clean the text.
Create program that inmplements these
a
tilters

6. Attempt any one part of the following:


to text. Construct a program for the same.
the numbers in the file
Change all

Example:
the product is equal to or lower
product only if
Given 2 integer numbers, return their
than 10.
And the result should be:
the product is equal to or
return their product only if

Given two integer numbers,


lower than one zero
separated by whitespace7
Construct program which accepts a sequence of words
a

input. Print the words


composed of digits only.
as file

of the following:
7. Attempt any one part
remove last column and save
it in

Construct aprogram to read cities.csv datasct,


array. Plot the first two columns.
a.

an array. Save the last column to another


with the following buttons
and functionalities like addition.
b. Design a calculator
division and clcar.
subtraction, multiplication,
Calculator

Galaxy A23 31a

You might also like