Page 120 - CatalogNEP-LS
P. 120

e.  Find the frequency of a character in a string.
                          f.  Replace a character by another character in a string.
                          g.  Remove the first occurrence of a character from a string.
                          h.  Remove all occurrences of a character from a string.
                   10. WAPtoswapthefirstncharactersoftwostrings.
                   11. Write a function thataccepts two strings and returnsthe indicesof all the occurrencesof the
                      second  string  in  the  first  string  as  a  list.  If  the  second  string  is  not  present  in
                      thefirststringthenitshouldreturn-1.
                   12. WAP  to  create  a  list  of  the  cubes  of  only  the  even  integers  appearing  in  the  input
                      list(mayhaveelementsofothertypesalso)usingthefollowing:
                          a.  'for' loop
                          b.  list comprehension
                   13. WAPtoreadafileand
                          a.  Print the total number of characters, words and lines in the file.
                          b.  b. Calculate the frequency of each character in the file. Use a variable of dictionary
                             type to maintain the count.
                          c.  c. Print the words in reverse order.
                          d.  d. Copy even lines of the file to a file named ‗File1‘ and odd lines to another file
                             named ‗File2‘.
                   14. WAPtodefineaclassPointwithcoordinatesxandyasattributes.Createrelevant  methods  and
                      print    the    objects.   Also     define    a    method     distance    to    calculate
                      thedistancebetweenanytwopointobjects.
                   15. Writeafunctionthatprintsa  dictionary  where  the  keys  are  numbers  between  1  and
                      5andthevaluesarecubes ofthekeys.
                   16. Consideratuplet1=(1,2,5,7,9,2,4,6,8,10).WAPtoperformfollowingoperations:
                          a.  Printhalfthevaluesofthetupleinonelineandtheotherhalfinthenextline.
                          b.  Printanothertuplewhosevaluesareevennumbersinthegiventuple.
                          c.  Concatenateatuplet2=(11,13,15)witht1.
                          d.  Returnmaximumandminimumvaluefromthistuple
                   17. WAPtoacceptanamefromauser.Raiseandhandleappropriateexception(s)
                      ifthetextenteredbytheusercontainsdigitsand/orspecialcharacters.

               SUGGESTED READINGS:

                   1.  Taneja,S.,Kumar,N.PythonProgramming-
                       AmodularApproach,1stedition,PearsonEducationIndia, 2018.
                   2.  Balaguruswamy  E.  Introduction  to  Computing  and  Problem-Solving  using  Python,
                       2ndedition,McGrawHill Education, 2018.
                   3.  Brown,MartinC.Python:TheCompleteReference,2ndedition,McGrawHillEducation, 2018.
                   4.  Guttag,J.V.IntroductiontocomputationandprogrammingusingPython,2ndedition,MITPress,
                       2016.


               Minor III:




               Micro.321                 Microbial Genetics                                              2+1

               LEARNING OBJECTIVES:

               The primary objective of this course is to introduce:


                                                                                                           105
   115   116   117   118   119   120   121   122   123   124   125