if tests and syntax rules this presents the python if statementwhich is the main statement used for selecting from alternative actions based on test results because this is our first in-depth look at compound statements--statements that embed other statements--we will also explore the general concepts behind the python statement syntax model here in more detail than we did in the introduction in because the if statement introduces the notion of teststhis will also deal with boolean expressionscover the "ternaryif expressionand fill in some details on truth tests in general if statements in simple termsthe python if statement selects actions to perform along with its expression counterpartit' the primary selection tool in python and represents much of the logic python program possesses it' also our first compound statement like all compound python statementsthe if statement may contain other statementsincluding other ifs in factpython lets you combine statements in program sequentially (so that they execute one after another)and in an arbitrarily nested fashion (so that they execute only under certain conditions such as selections and loopsgeneral format the python if statement is typical of if statements in most procedural languages it takes the form of an if testfollowed by one or more optional elif ("else if"tests and final optional else block the tests and the else part each have an associated block of nested statementsindented under header line when the if statement runspython executes the block of code associated with the first test that evaluates to trueor the else block if all tests prove false the general form of an if statement looks like thisif test statements elif test statements if test associated block optional elifs