Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

\ BP I,,.

C KB JO" Bf 'I ' C ~ ll6 H


' •. !
I
• . - •
_ ..¥
"} . .~...
l "SN . ----
_ __! - Degree Ex.amimifion:- Ju ne/Ju ly .:!02J
~' ~~ \~ ,- -,---.. - ffer
·:_: , ::" N rs ~S em es· B. E/ B. Te ch
Pr og ra m m in g
1 .....·,1 In tro du ct io n to Py th on

h mr,._il,!e.
AIISK~.r ;my FIJ 'E fal l qaestio ns., ehoosing ·ON E/u ll tpusrion from euc
N01~: I.
l.. M: ,ll• rts . L· Blbom ':s lnw
, C: Colll'l'~ mucome:s.

'.\I L l
-· - - - - Mo du le- I - - ~• ! Ll l ()(
d m Python \ViU1 exa mp le.
Q. l &.. Lt.St and e..""l)la.in math ope rat o~ llSC
-..-r ,s~ ev-e_n_o_r o-d d___ 6 LJ (_ 01
- -ck-"-,1-1e_l_h-er
- il- -t~- che
__nn _ e_n_u_n-tbe
~_th
j@
·- -;-. ""' -\ V_r_lie_ a_P_}_l'l-_ho_ n_-_p_ro_gr
'b~
-~
defrned fun'-l1ons .
- - - - --r--,· L2 CO i
i c. \\-1th 2n e'.:-ample exp lain use r
g, ~
,::; -
~ -:: OR 6 LI C Oi
~~
foll ow mg puilt-in functrons :
~ ::=:
~ --v-. Q-2 a. \"/it h an e:x:ampk exp l:nn the
~ .I 1l pnn r()
=
= """f
=: ,..,, ii) inpmO
~ ~
~ ~
m l !en( ). _ _ ___ ...,.

8 LI C Oi
hon exp lam \Vtth an e,,-a.mple..
' b. Ho w to rumdle exc eption s in P)1
6 LJ C Oi
bers usi ng ste p siz e in range{ ),
'© , Wr ite a pro gra m to print eve n num

l\fo du lc- 2 - -- - - - ----


10 Ll CO'.?.
thods wit h exa mples .
Q..3 a. E..x p~ m the fulto\v·ing IISt me
I •m ~{ )_
•apperod( ).
•m~-en f ) a
-~ rtt l
•re'1erse( ) .
_ I
- ~ 1 die:tionary of IO ke y- n1lu~ pa Lrs an<
l I
T LJ co~
create a
\.::,I \.\'r ne a python pro gr-am Lo
.
I
11 pnn~ only key s on,.gte scr een

used in lists w·1th an exa mp le_ s u co~


c. Ex p[.a m m and llOl i'n operators
----------
OR
QA a. - Sho w th~c l~ r..s are mu table.
mo du k - , --
8- - L - -
fn.'"qu euc y of cha ra.c tcn- usm 2~ ··- CO l
\\ nie a pro,g ram Lo cow ,! t.hc
PP nmr.(Pr~lr;- Prrnin rn.,g).

1
6 ll co~
..._.,FlfJll'f!fBylremiJ)c:mou~raiiioin
- os -r·,...,,, i o~xIi"~ ;;: -: -- -- -- -
-- - -- - - n n cJ(B I 05 /ll PLC JUf)SB -
-- -
. - -- - -- - - - -
fi LJ CO J

_/ r, ., LJ ( ·o:rl
8-1 Lt C OJ i
_J

10y 1I - -1

CO J
Icf6-:-·,·rP!~Pln'hil
I . ' ' 'i) .isalph
the ,fol19wliilfff(ing methods
a() ' ii) isa lnu m( ) iii) isd cim al( ) iv) iss pa ce( ) v)
.with examples :
islil le( ).
I
I
I1 JI /
J II
1

ite
I

a
1' Py tho n pro
'
I

grp m tha
I

t:
I
I

rep eat edl y asks users


t:heir age and a
ord in
for 6 /LJ / C
{~ Vfr inp ut. [age is in dig it and Passw
til the y pro vid e val id
p~•skword ,un / I
alp habet an digit only].
lute and rel ative paths in specifying file
pat hs. 4 / L2 IC
bet we en Ab so
C. , Differentiate - --
)

.._ I -4 -
M 0 d UC - ·- - LI - f C04
8
' uti l module.
- -
- - - - - ,!..- ..--. --,
fifes and folders can be copied using Sh
Q. 7 a. Sh
'
ow that
. I 7 LJ C0 4 /
ep tio ns in Python.
b. Write a note on Raising exc co4 - ➔
J
J-
1-, -

-+c.
-
. ~
' in the Debug Co ntrol Wind ow I .
Explain five bur.tonI s available -1... . --- I
- ~

co

:l.
' J OR -
egorize log messages by JO L2
d Python to • cat
Describe logging levels use
111
j Q.8 a. . !.•
, .
importance . - co
..,;:_

. - - -
tly de leted. IO LI
-- s and folders can be permanen
With example show how file
I fj ,
'
I

I1
-Q9/{!!) Wr ite ~ p
,
rc;
1y
,
> g:ra
' a
; s
m
s~o
f.o im
~n
ple
in Fig .9(
M od ulc -S
•- - - - - -
me nl the _ fo_lJ_o_w_i_ng_ o_b_~_ec_t_ d_ia_g_ra_r_n
-

a). Initia lize the anributcs


and its
through a
~
JOTufO
· · furic1ional.i I

constru ql~,r and print' r the same.


I , -f ,: · -----
--_ -_ -~-_-_-_-_-_-~-......_-;;; -
.: I 1- ~-
-- -- '--
~ ~iJ.: ➔ \ QQ,,0
hlu.# 7:>..oo,O )( ~
ii/ I
·O
b111'1-:
'--
_· ;\
C.~ -nO - -r-11 'f ➔ O•O

C M·H IT U BI (-\H Y

b. Dis c~ss ope~ ato r ove1tloading. Me nti on any five operators with res
pective
Fig.Q9(a) 1-,, ·,· ,\ l') l ' t : ,1 ,r u -J

JO / L2 ~
LO 1

/
oaded in Python. I
spccrnf functions lo be overl

,--=-=- - - - I 8 -r' LZ II c',;): :


I

'__/~ _1
Q. 10 "-T ~xpia in ihe ~o ll= ~g
~wi tl: exa~7 :

I y( ). /
cop y.cop y iv ) copy.decpcop
is insta nce( ) ii) hosall r( ) iii)

i:; ,mlM mB h:llflJXr~Bg GRI\Ol'(f.Gf;Xfdsci@_J;WWJ°lt.l~l3~ 01ii\ B½m~ d;i lie r


function . / 12i LJ ; C0 4
414 ,
,,up s //docs godgih.,
\ Ro(ID)B
_'.,;tl~ ~,z~\ 1 1 1 1 1 1
,
1
(" B?CK 205B / BPLCKB205

:· ! ::;~~ d)~~meste r B.E./ B.Tec h. Degr ee Exam 1h_:;ttion, Nov./


Dec. 2023
\ ~ ; ~ .p : - Intro duct ion to Pyth on ,.P fogr amm ing
1
':f)i/s: ' Max . Marks · J00
---
,'•T_!me .
~
--- oje: 1. Answer any FIVE full questions, choosing ONE full question from each module
.
2. M:I
Marks, L: Bloom's level, C: Course• outcomes.
-
,r Modul e 1 .' M L C
5 Ll COI
Q.I a. Gcmon strate with exampl e print() , inp4t( ) and format ( ). •.

·~, L2 COi
b. Explai n conditi onal branching statements with syntax and write a suitable 7
j
program for the same.

L3 CO]
Write a python progra m t6 check whether a given numbe r is Armstr ong or 8 j
C.
not. [Hint - An Armstr ong numbe r is any numbe r of~ digits whicg is equal
to the sum of n poweJ of digits in the number..,For example, 371 JS ~D
th

Armstr ong numb~r sin~e 3**3 + 7**3+1 ** 3 = 371]


, ....
-~ ,.
,. OR
8 L3 COi
Q.2 a. Write ,a p~lion p·rogra m to guess the sec.i:et numbe r between 1 to 25 within
5 guess if the numbe r is same then it.is,rigbt guess else wrong guess.
\ -
b. What are ·user defined function? Mow can we pass the argume nts to the 6 LI COi
functio ns? Expl,ain with suitab]e,examples.

LI COJ
C. What are compa rison and l3_oolean operato rs? List all the comparison and 6
.I
Boolea n opera~ors in pytfton. - -

I
Modu le-2 ·
L

8 LI CO2
Q.3 a. Explai n the metbod s 'of list data types in python for the following operation
with suitabl e code snippets for each. -
,.
i) Adding values to a list ~

ii) R~m<:>ving values from a:li~t._


iii) Findin g a value in a list
iv) Sorti:yg the values Wa_list'
6 L1 CO2
b. Expia in the concep t <ff !isl slicing and list traversing wilh an exampl e.
!
,
Y{rite a python . program to count occurrences of 6 L3 CO2
c. What is a dic1i9n ary?1
.
charact ersI !Ila s tr·mg an~d· pnnt
. t I1e·counl.
l 11

- -
' ,
. , '
,/
" OR
JO L3 / CO2
a. Write a python progra m ~bat ti.rid the missing number from the given a list
Q.4
0 .,J numbe
rs ranging from l) fo n, There are no duplicates (Hint - eg : Input
=I I 2 4 6 3 7 8, output :~5)

nt .from list()? Explain with exampl e the function used 6 LI CO2


b. How is triple differe
I lo 'conver t list into tfiple and triple into list.
,".)
4 LI CO2
ExpJa.i n ins·ert( ) and remov e() methods of List with example.
I c. ,,.,
BPLC l{lOSil/ B'PLCl(B2.05

- Q3 a. I \Vrite a pytho n program t.o count


l\1fodule - 3
Dl!tmber of lines in a file. '
s I LJ ICO i
---- -l
I

I LI I CO i
I

. f
lO
I
I

g funelion s
, wi<h exam ple : ,,;.
· b. I Exp lain the follow·in
vel-path() iv) hstdi(( ) ' y) sub( )
\
I
i) rruikedif$( ) iQ get.c·wd( ) iiQ
5 LI ' co 0
~
\ c. 1 V-l:h:a t ure thr~~ "nwde'\ arguments
Lhat can be p.~ssed 10· open( ) [unction
with example., . ~ I
I I ' I .
OR 1
CO2 I
r I
r Q.6 a. With' co<l.e'. snip p-et., expl ain savi ng varin 9l~s u_sing the shel ve moduJo ~rid . 6
..
L2
I
I
( ~ s,
I I . prinl pfor raat func tiqn
.- L3 CO2 !

I
' b. Wri Ite a pyth
1

on prog ram that acc~ pts '~,,sente:11ce and find .,.._.


Iwords, digits, upper case letters and !.ower case letters.
, ber of
the num 7

' ..
7 LJ CO2 !
nt elim inat ed
mak e a new -string with all the con s~na
c. Wri te n prog ram to - For exam p!e lnP.ut: Hell o, hav e a
from the strin g read from ~e user [Hint
I
I goo d day. Out put: HIT, hv gd dy]
-"-
J
! l
Module - 4 10 LI COI
ng and
t is mea.nt b~- cqm pres sing File s? E,g ,la~ reading, extr acti
Q.7 a . Wha ~·
. creating ZIP fi!es wiih an example. I
-, 5 LI CO2
asse rt st'!Jement in pyth on cons ists of?
b. Define assertions. Wha t does an
·- , 5 LJ C03
Ic. Ho\.V does -OS .walk( ) wor k in python._?.
.
OR
to config_l,lre tlfe lagg ing with an
7 L2 I CO2
) met hod
Q.8 a. Disc uss the oasi cCo nfig (.
eicample.·
I - Lt CO2
. ra1:n to depi9t
b. Write. a prog Raismg Exc epti on.-
.
. .
. .
7

6 L2 CO2
c. Exp lain tbe func.tions_
i
or Shutil mod ule 1W.it~<example.
. .
'
i

Mola.le•- 5 '
c and ~ta ~~e met hod. 6 L2 C04
Q.9 a. Com pare the ~ifference betw een c.lass, stati '

on. Crea te a class ·call ed Emp loye e and 9


L2 C04
b. Def ine 'cla,,sscs an.d obje cts _jn ' p~h
Design-mcithod to :
initialize it with ,einp loye y id and nam e.
e ·
i) Set Age _:, to' assi gn 'ag~ :to the emp loye
-: to clSS~gn sala ry to the emp loye e l MK IT LIB i {A R y
ii)
... Set~Sala ry
! l;'\fil ,,\LD HL : , JJll 7
loye e.
jii) Dis play - t0 disJ2l~y all information pf the emp •
' I -i' , .
' --- method~ .with an exam ple. 5 L2 C04
C 1:xpJain ---~- init•c:.:. aii~
a ,str
f 1
"' ; • ~
,
...._ • .,_ 1
- I - •, ,

-. i ~ OR
phis m in pyth on usin g met hod 7 L3 CO4
Q.10 a. [ iY/rilf!: a p rogr am to iplp_l~°:le~t poly mor
over ridin g. f"

re of a L3 C04
b. Def ine pur e fu.□ction? an example prog ram that retu rns squa 9ive 7
pass ed mte ger. , ,, .
te a pyth on prog ram to 6 L2 C04
I c. !-low class can ' be! inst anti ated in python? Wri
class REC TAN GLE with mem ber
I
to~t;inoe s ?s n; turn valu es to define a t
erY and mem ber function to find ce n er area
wid th . Heig .ht corn erX com
I .
:rnri n c• r·1mP-ter nf;i rect ang le.
\
n-1 13PLCKI05DlOPLCKUl05
\)SN L I - · - I I I - - - _J
FirsfSeme-s tcr B.E./B.Tecb . Degree Examinotion~ Occ.202.3 /Jon.2024
Introduct ion to Python Programm ing
Mux . Murks: IOO
Time: 3 hrs.
NM~~ t. AnSl4•tr •ti' FIVEft,11 qu~ritlllS, f'AoosinR OlVEftlll ll"~fltmfrom (CIC& motlule,
l. M: ,ll•rts, L.• Btot,nt'"s li!r#. C: CtHUSfl ,mtt"tJfflffi,
Module- I M L C
Q.1 a. List and eN:plain the use of ctH11parison \1perntor in python. Write the step by 6 Ll COi
step execution of tl-.e lbllowlng e.-;:pression in p)1hon.
312 • 4 +) + (I0J4).. 3-2
. u cot
b. Explain the eontml stntcments. ii~ els~. elif wilh proper synttL-.: and 6
e..,11mples.

c. Develop a python program to calculate the area and circumference or!\ 8 LJ COi
circle input the vnlu~ of radius and print the results.

OR
Q.2 ll. Explain the string concatenation and string replication operator with an 6 ' L2 COi
e.~mple.
-
b. faplnin local and global scope of variable with suitable e.°'\nmple. 6 u cot
c. ' Develop a program to read the student details Lik~ Name. USN nnd Murks s Ll cot
in three sub_iecls. Display the student details, total marks and percentage
with suitable mc.'!SSa~s.

Modulc-2
Q.3 a. What is list? Explain the concept oflist indexing nnd slicing with examples. 6 u CO2

b. With suilable examples, ex1>lnin the list methods append( ). e.xumd( ). 8 u COl
.
son( ), count( ) and pop{ ).

c. Read N numbers from the console nnd create n list. Develop n program to 6 L3 CO2
' print mean, variance and standard deviation with suitable message.

OR
QA o. Define tuple daia type? List out the difference between tuple and list. 6 L2 COl

b, lden1ify and expJain the dictionary methods like get( ). item( ). ke)'s( ) and 8 L2 CO2
values ( ) in python with examples.

c. Deve lop !l py1hon program lo swnp two numbers without using 6


. L2 COJ
ln1e.nTiedia1e variabk.s. Prompt the user for input.

I of2
BP LC K I 058/BPLCKB I 05
Mo du lc- J 6 L2 COJ
ing :
Q.5 a. Wr,ite the outpul of !he follow ( )
per
i~ 'HeLLo' •upper( ) · isup .
) er(
ii) ' 1-leLLo' •upper( ) • low
J 'There can be only one ' · split( ) )
' iii) •_' . Join( L2 COJ
6

ng methods.
b. With examples, explain any five siri Ll COJ
sonants 8
elop a python progra m lo count the total number of vowels, con
c. Dev
in a siring.
OR 7 L2 COJ
explain Reading and writing
Ma ke use of the concept of tile handling and
Q.6 a. ams.
process with suitable python prog!_ L2 CO3
7
and relative pat-hs.
Exp lain the con cept of file palh, also discuss absolute
b.
6 L2 CO J
c. Briefly, explain sav
ing variables with shelve module.
Module -4 6 L2 CO3
able examples.
Exp lain the follow ing ,li!e operations in python with suit
Q.7 a.
i) Copying files and folders
I
-
ii) Moving files and folders
iii) Permanent ly deleting file
s and folders ~

lain 8 L2 CO3
th~ ben efits of com pressin g tile with zip file module, also exp
b. List out
ry tree.
the concepts of walking a directo
l.copytree( ) 6 LJ CO3
the diff eren ce betw een shutil.copy( ) and shuti
c. List OUI
methods.
QR
.. -
6 LZ C0 3
ing a exception .
Q.8 a. Briefly explain Assertion and rais
takes two 8 L3 CO3
a function named DivExP which
b. Develop a python program with ertion for
am eter s a, ban d returns a valu e-C. (.C = alb). Wr,ite suitable ass
par gram
i.n fun ction 0iv ExP and rais e
. on exception for when b = 0. Pro
a> 0
has 10 read two values from the. coh
,,
sofe and call a func1ion DivExP.
6 L2 CO J
efly exp lain the difference log ging levels.
c. Bri
Module -5
rectangle 8 i2 CO 4
hon. Construct the class called
Q.9 a. Define c-lasses and objects in Pyt as (x = 0,
I00, wid.th= 200 , starting point
and initialize ii wj th height = ates o-f a
display t'f1e center point coordin
y = 0) and write the method lo
rectangle.
totyping and planning. 6 L2 CO 4
b. Briefly explain rhe concept of pro
__ str( )_ _ method with examp
les. 6 L2 C0 4
c. E>iplain Clearly _ _ init( )_ _ and
OR
le with an example. 6 L2 CO 4
Q. JO ll. Explain the term objects are mutab
8 L2 CO 4
hism with examples.
b. Exp lain the concepr of po'lymorp
modifiers with examples . 6 L2 CO4
C'. Ex plai n brieny pure functions and

2 of2

You might also like