Page 190 - Computer Science Class 11 Without Functions
P. 190

14 cutOffD = 33
          15
          16 if percentage >= cutOffA:
          17     grade = 'A'
          18 elif percentage >= cutOffB:
          19     grade = 'B'
          20 elif percentage >= cutOffC:
          21     grade = 'C'
          22 elif percentage >= cutOffD:
          23     grade = 'D'
          24 else:
          25     grade = 'F'
          26
          27 print('Your grade is', grade)
        InlShtltxnepatlgivtnlnbovtliflShtlpercentage itl54,ltnchloflShtlconditonnaltxprtttiontlpercentage >= cutOffA,
        nnd percentage >= cutOffB yitadtl(onltvnaunton) False,lbuSlShtlconditonnaltxprtttion percentage >=
        cutOffC yitadtl(onltvnaunton) True, to ShtltSnStetnS:

            grade = 'C'
        itltxtcuStd.lFinnaay,lonlShtltxtcutonloflShtltSnStetnS:l
            print('Your grade is', grade)
        PyShonlinStrprtStrlouSpuStlShtletttngt:l
            Your grade is C
         >>> Enter student's percentage:  54
              Your grade is C
         Program 8.7 WriStlnlprogrnelShnSlchtcktlwhtShtrlnlnuebtrlitlpotitvt,lntgntvt,lorlztro,lnndlditpanytlnnlnpproprinStl
         etttngt.

        Solution:
          01 #Objective: To check whether a number is positive, negative or zero
          02 num = int(input("Enter a number :  "))
          03 if num > 0:
          04     print("POSITIVE")
          05 elif num < 0:
          06     print("NEGATIVE")
          07 else:
          08     print("Number is ZERO")
         nepatlOuSpuSl1:
         >>> Enter a number : 4
              POSITIVE
         nepatlOuSpuSl2:

         >>> Enter a number : -2
              NEGATIVE
         nepatlOuSpuSl3:

         >>> Enter a number : 0
              Number is ZERO
         Program 8.8 WriStlnlprogrnelShnSlncctpStlntlinpuSlnlbinnryloptrnSorlnndlSwoloptrnndtlnndlcoepuSttlShtlrttuaSlofl
         nppayinglSht optrnSor.lThtlprogrneletrtaylchtcktlwhtShtrlShtltuppaitdloptrnSorltqunatlnnylontlbylontlinlShtlttSl
         {+, -, *, /, %, //, **},lnndlprinSlShtlrttuaSloflnppayinglShtloptrnSorlSolShtloptrnndt.








         188   Touchpad Computer Science-XI
   185   186   187   188   189   190   191   192   193   194   195