dsp QB
dsp QB
2.4]-YI
S2>printit)
4. Deseritbe any three methods of lists in python
S. Write a program to create dictionary in python
6 Describe tuple in python and write syntas to create tuple.
7. Write a python program to create list for 5 items in python.
$ Write the output for tolowingif the variabie fruitemango using list
>fruit-21
>>>ruit(11
3frult[13)
sfruit:l
9. ist ary two features of python
10, Define set in python with exampie
11. Explain merge of two dictionaries
12. Describe membership operators in python.(in, not in)
13 Describe any two data conversion function.
14. Describe keyword continue with example
15. Describe creating dictionary and accessing dictionary element wth esample
16. Explain any four python builtn function with example.
17. Explain bitwise operator in python with example
18. Write a python program to calculate sum of digit of gven number using function.
19. Writea python program to find the largest number and smallest number in a list
20. Explain ay three set function with eample.
ALFAH Page No.
DSP QB Date:
an) andset
ist beteen
DA
Dichonag
Dict iongxy censistA sed is
Set
a cellection et
of a coll etion of unorlere tems means
Lobiects as Bey not in any particulay
yalepairs. Lordex:
2A The elementsinThe elemente n Set are
im muta ble meanS cannat
mutable means chang eab be changec
|le
aMDescibeat
>]apptndnsatfl
mase
three methods af lieh 'n athon
removeC
Vxevase
as)lte a pragam 4o create distionay jn athar
Imy d=t|lo 2:2o314, s,l 4ibye hyef
prink C" accesstem" my dLs)
Shot on OnePlus
Powered by Triple Camera 2023.09.01 12:18
Date:
Cox
python and
andl wnte
wnte syndaxta
Q6Desciibe. tuple in
Ceate Luple
kre
usel to
’)aples is the dat a type in RtAon
storemdiple data i t s na sinqle Variable
alos
ahich is ordexe cl Un- change able and
plicate values
benmbers 0Y
iJlData itens n tuplesmay be nu
sting qnd must b
be enclosccl within g0n d
brackets C) separate by Comqc
’ Paxin xange(s)i
Lem input CE"entey item Ci+1)
jtem Aseppenc Citem)
Loont C The lst ef Temstemi)
be'm
print( i )
for x in li
print (x)
Shot on OnePluS
Powered by Triple Camera 2023.09.01 12:19 b
ALFAH| Page No.
Date:
)ist ang
any to feattr of python
icasy to Cocle
Fee anc apeo So
nCasy to Reacl
Qlo Define set a pqthon with example 24
’ i h mathematicsacet is a callectin ot
anorereitems means no t ' n any paxdicula
oT@ey.
simlar to this
pathen Set S heqy about
mathe matical denition
Shot on OnePlus.
Powered by Triple Camera 2023.09.01 12:19
YDesaibe mem besship opesctos in python nDst
yThe membexsbipopeiatos in pthon ased to
test whethey aVelueox Variable fhunc in a
stingeist, tuplesed and dicthinnay
YouCan
notthe
Qnly test foy pfesence ot
Valee in a dctiona
3 ) f the vale is pncseot ia the ata atrctse
sych qs
shiaqRist tple, set ancd dicionsry
thenyetns tue othe
tiueothey sexetrns false
4 -The hembeiship
nembeiship opesatoxS are gien belo
boi- xetyrhtaet a se quence th specha
Val ue s p i esent inthe object
l'not in ; - geturn txuef aSequence with.
he specified velye snot pre sent
)nthe obect
Shot on OnePlus
era 2023.09.01 12:19
ALFAH Page No.
Date:
S>>nt Ct)
Shot on OnePluS
OnePlus on
Shot
Liae) (seserse print
place istin the
idemof lQeta element
']
e', m lasti pop
= lp
i) Aist:" ("pap print
Date:
Date:
ange
mango'
Me
Shot on OnePluS
Powered by Triple Camera 2023.09.01 12:19
dictien9asy ancl gcesSinq
sDesciba creating
elemeot with xqnple
'evel
>lCinting
values They ax
eys and theiy conponing
ntten with curly bracetso
lanclcolen: to Qelne Lhe ey Values.
pais withun the lictionon
elemeats i- Access)ng
Accessing dhctionag
in pthon in voles hchopant ebmeals
inq thekeds of the
cioaaxy to vetieve theiy asssociateal values
You ca 25e sauare brgcke bs anc pzoxiclin
4he elesireel key
key within them
exi- my
pint
pi nt acess 3iemi?m y d o
olp =dicl :fi:lo 2:20, 3: 5.s,61
bycbye
qccesS 3te m:
bye bye
Shot on OnePlus
Powered by Triple Camera 2023.09.01 12:19
ALFAH Page No.
Date:
DML
abs () : ;e fc
angument value ej
C-s)
Retns he ot
leagth a
shing
Ex;len CHella'
Shot on OnePlus
Powered byTriple Camera 2023.09.01 12:20
(ALFAHP
Date:
Dperatoy:
-Thisportn bit 1L exists in ithe
Lopaenc
Shot on OnePlus
Powered by Triple Camera 2023.09.01 12:20
ALFAH Page No.
Date:
D<<(bitLise
Tie
lft sbi£tapera toz)
let op ¬xand s moveellef4
by he nmbex bits oW
specitiol by the
iaht operano n
CBitse
>>(Bitise ahtShlft
shit operator) The Se
Qperancl
Lhumbty ot bits pecied by the ~ight
perand
pzint ( ae b
print afb alb)
pint a b
printa << 2
PriotCas2
2
3
a7b
Shot on OnePlus
Powered by Triple Camera 2023.09.01 12:20
2023.09.0112-20 Camera Triple Powered
by
OnePlus on
Shot
Smallest laznest, rttunm
num Smallest
s
Smallest: <nurn it
Aangest
numhes in num for
Numhes
[o Smallest= 1orgest
None None, rturn
numbersi not if
(numhecs): Smallest largest
- find- def
List
in
hymber est Small and bey nect tt larq
toind
the pzogram python a te Q14
xesut) digits: otsm intC
")) n4mber ("Entr intCinpt num
S4m toal Yetuy
humba=la
numberlo
lo cligit
=
achile
totalS.
ber)i Gn4m digits cletsm
sing d'git
VsL numb
pythospongra lilea
sum calcalat do
Date:
Q2aFxplain
Explain Ons thxee Sek functian with example.
all)
Retunm Tnue f all elements of the
Fne tme (Or if the set is empty)
Ex
Shot on OnePlus
Powered by Triple Camera 2023.09.0112:20
others.
Built-in functions likeall). any),
used with set to perform different enumerate(), len), max), min (0, sorted), sum) etc. are commonly
tasks. Consider set A= (3, 1, 6, 7}.
" Following table lists built-in functions for set:
ST.
Punction Description
NO.
1
Example
all() Return True if all elements of the set are true (or if the set>>> al11 (A) True
is empty).
2. any() Return True if any element of the set is true. If the set is>>> any (A) True
empty, return False.
3. len() Return the length (the number of items) in the set. >>> len (A)
4
4. max() Return the largest item in the set. >>> max(A)
7
5. min() Return the smallest item in the set.
>>> min (A)
6. 1
sorted() Return a new sorted list from elements in the
sort the set itself). set(does not >>> sorted (A)
7. sum() Retrun the sum of all elements in the set. [1, 3, 6, 7]
>>> sum(A)
17