Sei sulla pagina 1di 2

ES

102:
PYTHON
PROGRAMMING

ASSIGNMENT4

THEORYQUESTIONS:
1. Statethedifferencebetween:
a. a.pop()anda[:1]
b. a.reverse()anda[::1]
Whereaisalist.
2. Givedifferentwaysofinitialisingadictionary
3. Explaintheutilityands yntaxoflistc omprehension
4. Whatdoyouunderstandbyimperativeprogramming?
5. Whatisrecursionlimitandexplainwithreferencetos tackdepth?
6. Whatistheutilityofs trip()whileacceptinginput?
7. Representthefollowinggraphsasedgelist,adjacencylistandadjacencym atrix
representationsinPython
a.

b.


c.

PROGRAMMINGQUESTIONS:
1. Writeaprogramtoacceptalistofintegersasinputfromtheuserandprintanewlist
thathasonlyevenintegersfromthelist.Uselistc omprehension.
2. Writeaprogramtoaccepttwolistsandc reateanewlistwhichc ontainsthe
elementsc ommontoboththelists.Uselistc omprehensionstoachievethes ame.
3. Uselistc omprehensiontoc reateam atrixass hownbelow:
1####
#1###
##1##
###1#
####1
4. Implementhisaabtoworkwithadjacencym atriximplementationofgraph.
5. ImplementtheAPIforadjacencym atriximplementations othatthehisaabalgorithm
ofhisaab3.pyprovidedinthenotesworkswithitwithoutneedtoc hangeanythinginit.
6. Writeaprogramdefiningafunctions um_digits()whichreturnsthes umofdigitsina
giveninputnumber.Defines um_digits()asarecursivefunction.

OPTIONALQUESTIONF ORPRACTISE:
APangramChecker:
Apangramisas entencethatusesallalphabetsofEnglishlanguageatleastonce.W ritea
programtoc heckifthegiveninputs entenceisapangram.
Hint:Youc anuseadictionarytoc ountoccurrenceofthec haracters.

Potrebbero piacerti anche