Page 306 - AI Ver 1.0 Class 9
P. 306

if Amount>10000:
            if gender=="F":
                print("Amount after 15% Discount is: ",Amount-(0.15*Amount))
            else:
                print("Amount after 10% Discount is ",Amount-(0.10*Amount))
          else:
                    print("Sorry! no discount")
        Output:
        Enter billing Amount : 12000

        Gender :M
        Amount after 10% Discount is 10800.0


          Program 8:  To input a number and check whether it is multiple of 5 or not. This check is valid only for
          positive numbers.

        Algorithm                                                Flowchart
        Start
                                                                              START
        Input Num
        if Num is greater than zero then                                    Input Num
            if Num is divisible by 5 then

                Display "It is multiple of 5"
                                                                                Is      No       Display
            Otherwise                                                        Num > 0?          "Invalid No"

                Display "Not divisible by 5"
                                                                                 No
        Otherwise
            Display "Sorry! Invalid Number"                                     Is      Yes      Display
        Stop                                                               Num %5=0?          "Not Multiple"

        Source Code:
                                                                                 No
        Num=int(input("Enter a number :"))
                                                                             Display
        if Num>0:                                                         "Multiple of 5"

          if Num%5==0:
              print (Num," is multiple of 5%)                                  STOP
          else:

              print(Num," is not multiple of 5%)
        else:

              print("Sorry! Invalid Number")
        Output:
        Enter a number : 34

        34 is not multiple of 5




                  304   Touchpad Artificial Intelligence-IX
   301   302   303   304   305   306   307   308   309   310   311