Question Papers
Question Papers
BPL.CKZ05B/BPLCKW05
Seeond Semester B.E/B,T'ech, Deuree Exmination. Nov/Dec. 2023
Tiae. 3 hs Introductlon to Python Programming
Max Marks 0
Vote: l. Iaswer any FIVE full questions, chuusing ONE Jul qustinn eaeh
2. M: arks, L: Bloom's level, C: Curse l:
vuteDmes.
.1al. Demonstrate with example print(Module-1
M 4
). input{ )anxl fonit ( .
. Expiann conditona branching statenents with syatax and wpe a sjtable 7 20i
program lor the sae.
C.Write a pvthon program lo clheck whether a given number is Armstrng o 8 1.3 C01
|ot. (HnI - An Armstrong number is eny number ofa dits wliicl: is equut
to the sum of n power of digits in lhe nunber For
esumple. 71 tl
Armstrong nunber since 3**3 + 7**34|**3 371|
OR
(.2 Write a pvthon program o guess the secret runber hetwecn 1 ie 2i wtata 8 3
|5 guess ifthe aumber is sme then it is right gucss else wrong gCs.
), What are user defired iunction? How can we pass ine aeui
functons? Explain with suitable exnplkes.
Wbit are copar:son ad Boolea: operatars in he oa17 d 6
Boelean operators n python.
Module -2
Q.3 a. Fsnlan tie inethods o! Iist data types in pvtlon lor the f 1kowee
operalio 1
with suitabie code snippets for each.
) Adding values toa list
) Remnoving vaities troma list
u) Finding a value in a ist
) Sortng the values in a list
b. Explain the concept of list slicing ana list traversrg wil: n eNp!.
b.Write a python progran that accepisasentence and ind the nunber of 7 LsC02
WOr ds, digts, upper cise etters and lower case letters.
c.Write a program to mike a new string with all the consonant elimnated 7'13 cO2
Iroa tle siring read liom the user {Hint - For exampleInput: Hello, have a
SUnt day. Output. Hli iv gd dy)
Module -4
).7
. * t ts eat by conmpressing Files? Explain reading, extracting and 10 1.1 CO1
P tiles with an exatnpie.
h. Detits tts Wha docs n aert statement in pvthonconsists of? 5 1.1 C02
tiow docs OS.vailkt )work n pvthon?
OR
a.cu- ti basiconlig ) mcthod to configure the lagging with an 7 L2 CO2
, Deihe pulte utcto? oiNe an csample program that relurns square ofa7L3 CO4
Dsscd 1tegen
2 of2
GBGS SGHEME BPLCK105B/BPLCKB105
OR
Q2 What are functious? Explain Python function with parameters and return 7 L2 CO1
statements.
are handled in python? Write a7 L2 C01
b. Detine exccption handling. How exceptions
program to solve divide by zerO exception.
rectangle and triangle6 L3COI
C.Develop a python program to calculate the area of
print the result.
Module -2
slicing. index( ), append( ), remove ), popl ).8 L2 CO2
Q3 a. Explain negative indexing
suitable example.
insert( ) and sort( ) with
suitable examples 6 L2 CO2
b. Explain the use of in and not in operators in list with
standard deviation, 6 L3 CO2
C. Develop a program to find mean, variance and
OR 8 L2CO2
Q.4 a. Explain the following methods in lists with an examples:
i) len() ii) sum() ii) max( ) iV) min(0.
6 L2 | C02
b. Explain set( ) and setdefault( )method in a dictionary.
string 6L3CO2
c. Develop a Python program lo swap cases of a given
input: Java
output: jAVA
Module -3
examples. 8 L2 | CO3
0.5 a. Explain join( ) and splits) method with
) 1) isalnum( ii) isspace( ). 6L2 CO3
b. Explain with examples: i) isalpha(
whether the given string is a 6 L3 CO3
c.Develop a pytbon code lo determine
palindrome or not apalindrome.
Iof 2
GBGS SGHEME
BPLCKI05B/BPLCKBI05
Q.1 Module-1 ML C
List and explain the use of comparison gperutor in python. Writc the stepby 6
step execution of the folkowing expression in pulin.
CO1
324+3+ (104)"3
b. Explain the control statements. if. else, elit with proper syntaX a 6 Co1
Cxamples.
Q2 Explain the string concaenation and string ruplicat'on operator with an6 1.2 CO1
exampe
b. Explain local and global scope of variable with suitable example 6 CO1
cDevelop a program to read the student details L.ike Nane, SN und Marks 8 L3 CO1
in three subjects. Display the student details, total marks and percentage
wih suitable messages
a.
Module-2
What is list? Explain the concept of list indexing ard sicing with exanples
0.3 6 L2 CO2
b. With suitable examples, explain the list methods append( ). extendi ). 8 L2 CO2
sort( ). count( )and pop( ).
e. Read N numbers from the conyle and ereste a list. Develop a program to
L3 CO2
print mean. variance and standard deviation with suitable nessuge
Q.4 a. Define tuple data type? List out the dillerence between tuple and list.
6 L2 CO2
b. ldentify and explain the dictionary methods like getl . item( ). keys ) and 8 L2 C0
values ()in python with examples.
c. Develop a python progrum to swap two numbers without using 6 L2 CO3
Intermediute variables. Prompt the user lor inpu.
Iof?
BPL.CK105B/BPIÇKBI05
OR
Q.6 Explain the concept of file handling Also expluin reading and writing L2 c03
pnocess with suitable example.
b. Explain tlhe concept of file path. Also discuss nbsolute tnd relative fle patlh.6 L2 CO3
c. Betly explain saving variables with slaelve module. 613 CO3)
Module-4
0. Explain the following file operations in Python with suitable example: 6 L2CO3
i) Copying tiles and folders
i) Moving files and folders
iii) Pernanently deleting files and folders.
List out the benefits of compressing fie? Aliso explain reading of azip file8 L2 co3
with an example,
List out he d1fferences between shutil.copy ) and shutil.copytrec( ) |L3 C03
method.
OR
Q.8 a. Brietly explain assertions and raising u exception. 6 L2 CO3
b. List out the benefits of using logging module with an example. |6 L2 co3
c. Develkop a program with a function named DivExp which takes two8 L3CO3
parameters a, b and returns a value C(C= ab). Write suitable assertion for
a >0 in function DËvExp and raise an enception fos wien h0 Developa
suitable program which reads two values from the console and cals a
funetion DivExp.
Module-S
0.9 a. Detine
a class and object, construct the class called rectangle and0),initialize8
with
L2 Co4
bepht 100, wIdth 200, starting pout as ( Write a
program 1o displav the center point co-ord1nates ofa
b. Explain the concept of copying using copy module with an example. 6L2 COM
2 of2
Wrile the output of the
Module -J BPLCKI05B/BPLLCKB105
I) following: 612 CO
it) 1lel.Louppert
HelLo'uppert
) isupper) ()
) kwert
iii)-Jain There can be only one'-split( ) )
b.Wih examples, explain any five string methods. 6 L2 C03
Develop a python prugram to count the total
in a siring number of vowels, consonants CO3
O.6 OR
Make use of the concept of file handling
process with suitable python programs. and explain Reading and writing 7L2 CO3
b Explain the concept of file path, also discuss
absolute nnd relative puths. 7|L2 CO3
C. Brielly. explain saving variables with shelve
module. 6 L2 CO3
Q.7 a. Explain the following file
Module - 4
i) Co
opyng liles and folders
operations in python with suitable examples. 6 L2 CO3
i) Moy files and fokders
iii) Permanently deleting liles and folders
b. List out the benefits of
concepts ofwalking acompressing
the file with zip file module, also explain8 L2 CO3
director tree.
c. Lis out the difference between shutil.cops ) and
methods shutil.coptreet )6 13 CO3
OR
0.8 a. Brietly explain Asscrtion and raising a
exception.
b. Develop a
L2CO3
python program with
function a
pararneters a, h and returns a value C. (C named DivExP s hich takes two
ab), Write suitable assertion for
8 L3 CO3
a 0 in tunction
DivENP and
has to read two values from the raisc
on eNCeption for when b
0.
console and cail a function DivExP. Program
c. Brietly explain the ditference logging levcs
6 L2 CO3
Q.9 Module
Define classes and objects in Pthon.
and initialize it with height Construct the class called rectangle8 12 CO4
100, witth 200. starting point as ( 0,
0) and wrie the method to
display the center pont coordinates of a
rectangle.
b. Briefly explain the concept of prototyping and planning.
L2 C04
c.Explain Clearly init( and str( ) method with examples
6 L2 CO4
OR
0.J0 a. Explain the term objects are nmutable with an exampie.
6 L2 |C04
b. Explain the concept ofpolymorphistn with examples.
8 L2 CO4
c. Esplain brietly pure functions and moditiers with examples.
612 CO4
2 of2
GBGS SGHEME
USN BPLCK205B/ BPLCKB205
0.2a. List and explain with smtax ad example the flow control statement in 10 LICO1
python.
b. Demonstrate with example printt ) ipu ) and string replication
function6 L2 COI
in python.
c. Devekop a program to read the name and year of birth of aperson. Display
4 L3CO1
weather person is senior citizen or not?
Module -2
0.3 What is a list? Explain append( ), insert( ), and remove mcthods wth 10
cxample.
LI CO2
OR
Q4 a Explain get( ). item keys( )and values ) methods of dictionary in 8 L2C02
python.
bHow is tuple different from list? Which function is used to convert list to9
tuple? LICO2
I of?
USN
GBGS SCHEME
BPLCK105B/BPLCKD105
Pirst Semester B.E/B.Tech. Degree Examination,
Dec.2023/Jan.2024
Introduction to Python Programmning
Time: 3hrs.
Note: 1.
Answer any FIVE full questions, Max. Marks: 100
2. choosing
M:Merks, L: Blaom's level. C: Couse ONE full question fromn each module.
outcomes.
Q.1 a. List and explain the use of
step cxccution of the
Module-1
compurison onerutor in python. Write the step by MLLC
32.4+3+(10D/4 03-2
following expression in python. CO1
|0.2 OR
Explain the string
example concatenation and string renlicat ion
operator with an 6 L2 COI
b.
Explain local and global seope of
variable with suitable
e. De
evelop a example L2 CO1
three prugran read the student details
n to
subjects,
with suitable Displas
messages the student Like Name,
details, total marks USN an
Marks8 L3 CO1
and
percentage
A. What is list? Eplain the Module
concept of list -2
b. With suitahle indexing and slicing with exainples
Sort( ). count )exanples explain the list
C.
and popi .
Read N numbers from the
metlaods append, extendi ).
612CO2
12 C02
print niean, consle and
variance and standard ereate a list.
devjation Develon aprogram
with suitable a
to6 13
messag (00
0.4
Defing tuple data type? Liss OR
out ihe
Identity Oand dillerence between tuple and lit.
in explain
the
values dictionary tmethods like get(). ,
pvthan with examples |6 L2CO2
item kevs() and
Develop a python 8 L2 C02
Intermediate variables,program to
Prompt the uscrswaplor input.
two
numbers without usi1y 6 12 CO3
Iof2
eRead multidigit number from cunsole. Develop a progran lo print LSCO3
frequencyof occurrence ofcach digit with suitable messsge,
OR
0.6. Explain File reading and writing process with suitable python program. 7|L3CO3
b. Wah code snipippet, explain saving variables using shelve module and 6 |12 CO3
print() ad print format( ) functions.
eWrite a python code to implement multiclip board project in python. L3CO3
Module-4
0.7 Explain the functions of shutil module with example. 10 LICO3
What is meant by compressing files? Explain reading extracting and 10 LI CO3
crating zip files with code snippet.
OR
Q.8 1.Explain the following file operation in python with example. 6 LI CO3
i) Copying files and folders
ii) Moving files and folders
ii) Permanently deleting files and folders
b. Detine assertions. What does an assert statement in python consists of? |LIC03
Give an cxample.
cDevclop a progran to sort contents of a text file and write the foned |L3 CO3
content into a separate file.
Module -
0.9 Explain operator overloading and polymorphism with example. 7LIC04
b. Explain the cocept of pure functions and modifiers with python code. LICO4
Write a function called print time that takes a time object and print it in the6 L3 C04
form of hour: minutet second?
OR
O.10a.What is class? How do we define class? How class members are sccessed, 6 L1 CO4
explain with examples.
b. Expain init( ) and-str ) method with an example. |LIC04
.Discuss type bascd dispatch in python. 6 LI Co4
2 or2
BPLCKI0SB/BPLCKB105
Module - L2cOJ1
Wrile th output of the follkwing
i) lel io unpert ) Isuper ()
Hello uppert ) lowert
) Joinc There can be only one splitO)
612COs
b. With esamples. explain any live string melhods.
vowcls, cotisonants 813CO3
Develop a pythn program to count the total numher of
in a string
OR
esplain Reading and writing 7 2C03
0.62 Make use of the concept of file handling ard
process With suitahle python prograns
b. Explain the concept of ile nath also discuss absolute
and relative paths. 7L2 CO3
6 L2 Co3
Briclly. explain sving variahles with shelve nodule.
Module-4
sutable examples 6 L2 | CO3
Q.7 a. Explain the following file operations in python with
) Copving iles and folders
ii) Mev ing files and folders
iii) Pentanently deleting iles and folders
zip ile module, also explain 8
b. List out the benefits of compressing file with
the concepts of walking a directory tree.
and shutil.copstreet )
c. List out the difference between shutil.cops
methods
OR 12 C03
a. Briellv esplain Assertien and raising a cNception
Q.8
which takes two L3 CO3
b. Devckop a psthon program with a funtion named DivEXP suitable assertion for
parameters a, b and returns a value C.(C- ab) Write
a0 in function DivExP and raise on exception function for when b=D. Program
fron the console and call a Dis
has to read two vaiues
12 CO3
C. #rielly esplain the difference lkogging levels
Module -5
the class called rcctangle 8 L2 C04
Detine classes and obiets in Pthon. CoHIstruct
100, width 200, starting point as (N= 0,
0.9
itialize it with height
point coordinates of a
0) and write the method to display the center
rectangle
6 L2 C04
b. Brietly esplain the concept of prototyping and planning
Explain Ckarly initt str) method with examples. 6 L2 cO4
OR
cxape. 6 L2 co4
0.10 a Explain the term objects are utable withh an
8 L2| CO4
Explain the concept of polymorphism with examples.
Eplain hrietly pure functiens and moditiers with
examples. L2 C04
c.
2ef2
GBGS SCHEME
L'SN BPLCKIOSB/BPLCKB105
|O.2 . OR
Explain the string concatenation and string replication
exaimple. operator with an L2 CO1
b. Explain local and gkobal scope of variable with suitable example.
L2 COI
Devekop proram to read the student
a
in three subjects. Display the student details
Like Name. USN and NMarks 8
details, total marks and percentage L3 CO1
with suitable messages
03 What is list?
Module -3
.
Lxplain the concept of list indexing and slicing
withexamples,6 L2 |CO2
With suitable examples. explain the list methods
sort( ). count )and pop() append), extendi ). 8 L2 CO2
OR
Q.4 Define tuple data type? List out the dillerence between tuple and list.
L2 CO2
hldeutily and explain the dietionary imethods like ge( ). item(). keys( ) and
8 L2C02
valtues () in python with examples.
eDevelop a pytton program t0 s ap t0 numbers without usine6
Intermediate variahles, Prompt the user or input. L3C0M
BPLCKI05B/BPLCKBI0S
Module
05a, Write the outyut of the kollowing |6 L2CO3
Tlelle pper sipper )
) HelLo uppert kowcrt
inJoint"T here can be only onespli( )
b. Withexamples, explain any five string methods. 6L2 CO3
C. Develop a pyhun progran to count the total numbet of sowels, consonants 8L3 O3
in a string
Q.6 a, Make use of the concept of le handling end esplain Reading and writing 112 CO3
pcess with suitable python programs.
b. Explain the concept of file path, also discu5s absolute and relative paths. 1 2 CO3
c. Brielly, evplin saving variables with shelve module. 6 L2CO3
Module-4
a. Explain the following file operations in python with suitable eamples. 6 12 CO3
) Copying files and folders
ng iles and folders
i1) Permanently deleting fies and folders
b. Lit out the benefits of compressing file with zip
Iile module. also explain8 L2 CO3
the concepts of walking a directory tree
OR
0.4 a. Explain the following methods in lists with an examples: L2 CO2
i) len() i) sum() ii) mas( ) iv) min ),
b. Lplain sett ) ald etuefaul( ) ciho na ctionary, CO2
Explain the concepl of file path. Also discuss absoluie and relative file path.62COJ
Brictly explain saving variables with shelve moduie. 6 L3COJ
Module-4
0.7 a.Explain the lollowing file operations in Python with suitable example: 6L2 CO3
Copying files and folders
i) Moving files and folders
li) Permanently deleting files and folders.
b. List out the benefits of compressing file? Also explain reading of a zip file 8L2 co3
with an cxample.
c List out the differences between shutil.copy ) and shutil.copytrect )6 L3 CO3
method.
List out the bene fits of using logging module with an cxample. 6 L2 CO3
c Devclop a prograi with function iamed DivEap which takes two8L3 CO3
parameters a, b and returns a value C (C ab). Write suitable assertion for
a>0 in function DivEvp and raise an exception for when b =0. Devclop a
suitable progran which reads two values from the console and calls a
function DivExp.
Module - 5
0.S A. Define aclass and object, construct the class calied rectangleand initialize 8 L2 CO4
it with height 100, width 200, starting 3pont
p as (x=0, y= 0). Write
progrum to display the center point co-ordinates ofa rectangle.
b. Explain the concept of copying using copy module with an example. 6L2 CO4
Explain the concept of inheritance with an cxample. 6 L2 CO4
OR
Q.J0a. Define a function which takes two objects representing complex numbers|8 L2 CO4
and returns new complex number with aaddition of two complex Numbers.
Define a suitable class Complex' to represent the complex numbet.
Develop aprogram to read N(N>=2) complex numbers and to compute
the addition of Ncomplex numbers.
b. Explain_init )and__str_() method with exnamples. 6 12 CO4
2of?