Page 200 - Ai Book - 10
P. 200

always a string value. If the data type of the defined variable is an integer, in such a case, input() function is used
            to input integer values and if float, then input() is used to input float values.
            Example:













            Conditional Statements

            Conditional statements are structures within the code that can execute different lines of code on the basis of
            specified condition.
            If Statement                                                                                        False
                                                                                                  IF <condition>
            If statement tests a particular or specific condition. If the condition evaluates to
            true, it carries out the execution of a set of instructions inside the body of ‘if’ and
            if the condition evaluates to false, it does nothing.
            The basic syntax of if statement is as follows:                                               True
                                                                                                   Statements
                 if<conditional expression>:
                      Body of if(a set of statements)
            Example:












              Always remember that If statement will do nothing if the test expression evaluates to false.

            If Else Statement

            The if else control structure also tests a conditional expression .If the condition evaluates to true , the statements
            inside the if part will be executed and if the condition evaluates to false, then statements inside the else part will
            be executed.
            The basic syntax of if else statement is as follows:
                                                                                True                       False
                                                                                          <IF Condition>
                 if<conditional expression>:
                      body of if(Set of Statements)
                                                                           Body of IF                        Body of ELSE
                 else:
                      body of else( Set of Statements)






                74
                74
   195   196   197   198   199   200   201   202   203   204   205