1.if StatementsIf statement (that is, immediately following the if statement block), the condition of the statement is true false If The statement might read ": If the condition is true, execute the code in the clause. "In python if statement contains the following sections: (1)if keyword; (2) condition (i.e. an expression that evaluates to True or False ); (3) colon; (4) The code block (called an if clause) that is indented at the beginning of the next line . 2.else statement
only if false else clause will not be executed.
In the code, theelse statement contains the following part: (1)else keyword;
(2) Colon;
(3) at the beginning of the next line, the indented code block (called the else clause).
2.elif statements
elif The statement is "otherwise if", always followed by if or another elif after the statement. It provides another condition only in the preceding conditions for false elif statement always contains the following sections:
(1) elif keywords; (2) condition (That is, the evaluation is true or false expression);
< Span style= "FONT-SIZE:11.000000PT; font-family: "times New roman" "> (3) colon; (4) at the beginning of the next line, indent the code block (called the elif clause). instance script:
#!/usr/bin/env python
#_ *_ coding:utf-8 _*_
print (' Inpuyt Your Name: ')
my_name = input ()
if my_name = = ' Dingkai ':
& nbsp; print (' hello ' + my_name)
elif my_name = = ' Lianghui ':
print (' Hello ' + M Y_name)
else:
print (' Your name is wrong! ')
Python Process Control statement-if