Posts

Showing posts with the label Python - Conditional if

Python Programming Language - Conditional if

Image
Conditional constructs direct program execution along one of the paths based on the value of conditional expressions. The if construction is one example of such a construction. It has the following formal definition: if boolean_expression:     instructions [ elif boolean expression:     instructions] [ else :     instructions] In its most basic form,  there is a logical expression, it comes after the if keyword. Furthermore, each of the following instructions must start on a new line and be indented from the beginning of the expression if (it is recommended to indent with 4 spaces or the number of spaces that is a multiple of 4) if this boolean expression returns True: name = "Rick" if name == "Rick" :     print( "Hello Rick" ) print( "End" ) Since in this case the value of the name variable is "Rick", the if block will be executed, which contains only one instruction - print("Hello Rick"). As a result, the console will dis