Page 316 - Artificial Intellegence_v2.0_Class_9
P. 316

print("The subtraction is", N1–N2)
        elif op=="*":

            print("The multiplication is", N1*N2)
        else:

            print("No Result! Wrong Operator Selected")
        Output:
        Enter first Number :5

        Enter second Number :4
        Enter an operator(+,–,* only) :*

        The multipication is 20
          Program 6:  To input a number and check whether the number is positive of negative.

        Algorithm                                                  Flowchart

        Start                                                                     START
        Input Num

        if Num is same as 0:                                                    Input Num
            Display "You entered zero"
        Otherwise, if Num is greater than 0:
                                                                                    Is      Yes    Display
            Display "You entered +ve Number"                                    Num = 0?            "Zero"
        Otherwise
                                                                                      No
            Display "You entered -ve Number"
        Stop                                                                        Is      Yes    Display
                                                                                Num > 0?          "+ve No"

        Source Code:                                                                  No

        Num=int(input("Enter a Number :"))                                        Display
                                                                                 "–ve No"
        if Num==0 :
            print("You entered zero")
                                                                                   STOP
        elif Num >0 :
            print("You entered a +ve number")
        else:

            print("You entered a –ve number")
        Output:
        Enter first Number :–4

        You entered a –ve number







              314     Touchpad Artificial Intelligence (Ver. 2.0)-IX
   311   312   313   314   315   316   317   318   319   320   321