Page 37 - 2501_KVS_C-8
P. 37

Let us understand it with an example.
                 Program to check whether inputted number is smaller than 100 or not. You will write the
                 following code in python:

                                  NUM=int(input("Enter a Number :"))


                                  print("You have entered the Number : ",NUM)


                                  if NUM>100:
                                        print(NUM," is > than 100")
                                  else:
                                        print(NUM," is <= than 100")
                 You can observe, we have applied a condition  NUM>100. If the entered number is greater

                 than 100 then we will get a message “NUM is > than 100” otherwise we will get a message
                 positive “NUM is <= than 100”.
                 Now, let us observe the output of the above code for one number which is > 100 and one
                 which is not > 100.


                                         Enter a Number :101
                                         You have entered the Number :  101
                                         101  is > than 100

                                                   Enter a Number :99
                                                   You have entered the Number :  99
                                                   99  is <= than 100

                 We can also write a single statement or multiple statements in any part of the decision
                 statement.


                 Let us revise what we have learnt:

                 Ø  Python is a simple, high-level language used for various applications.
                 Ø  Variables store data, with types like integers, floats, and strings.

                 Ø   Python uses arithmetic (+, -, *, /) and relational (==, >, <) operators for calculations and
                     comparisons.
                 Ø   Commands are executed in a specific order, and the sequence affects the program’s

                     output.
                 Ø   If-Else  Statement  used  for  decision-making,  executing  code  based  on  whether  a
                     condition is true or false.














                                                                    Recap of Python of Class VII                    35
   32   33   34   35   36   37   38   39   40   41   42