Python Development-Process Control

Source: Internet
Author: User

The Python process controls the IF branch statement for Loop statement while the Loop statement break and the Continue loop control the 1.if branch statement if single branch statement:

Format:

if conditional Expressions: Directives Else : Instruction

For example:

A = 1if a = = 1    :print("Yes")else  :     Print ("No")
------------The result of the output-----------
Yes
If multi-branch statement:

Format:

if conditional expression:    directive elif  conditional expression:     directive elif  conditional expression:    directive  else  :    directives

For example:

A = 1= 2if a! = 1    :print("A! = 1")elif b = = 2    :print("b = = 2")Else  :     Print ("No")
-----------The result of the output---------
b = = 2
If nested formula sentence:

Format:

if conditional expression:    directive if  condition expression:     directive else  :        directive Else  :    instruction

For example:

A = 1b= 2ifA = = 1 :    Print("a=1")    ifb! = 2 :        Print("b! = 2")    Else :        Print("b=2")Else :    Print("a!=1")
------------The result of the output-----------
A=1
b=2

Python Development-Process Control

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.