2018-01-07 Python Branch statement

Source: Internet
Author: User

Mind Map of this article:

Program
    • Order
      Follow the order
      For example: Wash your hands first, eat again, and then wash the dishes.
    • Branch
      According to different circumstances, the condition satisfies the execution of the statement under certain conditions.
      For example: Wash hands first, if the rice did not do well, play games, if the meal is done, eat, if the rice has not done, called takeout.
    • Cycle
      The condition is fulfilled on a recurring, non-satisfied execution or no longer performed.
      For example: Wash hands first, look at the meal is not good, no good, one will look at once, until the meal is ready, only to start eating. The cycle condition here is that the meal is not done well, the cycle to see the rice is good. Single BRANCH statement
    • If statement
      If condition:
      code block
      Condition must be a bool type, this place has an implicit conversion bool (condition)
      If 1<2:
      Print (' 1 less than 2 ')
    • code block
      Similar to the IF statement is followed by a statement block
      In If,for,def,class etc.

      Truth table

Object/Constant value
“ ” False
"String" Really
0 False
>=1 Really
<=-1 Really
() Empty tuple False
Empty list False
Empty dictionary False
None False
False等价布尔值,相当于bool(value)    空集合        空字符串        空字典        空列表        空元组    None对象    0

Multi-Branch statements
    • If...elif...else statements
    • Examples of branching and nesting exercises

2018-01-07 Python Branch statement

Related Article

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.