Python Process Control Statement-if

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.