Python Flow control[通俗易懂]

Python Flow control[通俗易懂]HowtotellPythontomakeintelligentdecisionsaboutwhatcodetorun,whatcodetoskip,andwhatcodetorepeatbasedonthevaluesithas.WithFlowcharts!Flowcontrolwillneedyesornooptionstomakedecisions.InPythoncode,yesandnoisshownas

大家好,又见面了,我是你们的朋友全栈君。

How to tell Python to make intelligent decisions about what code to run, what code to skip, and what code to repeat based on the values it has.With Flowcharts!

more sources:[Python Control Flow Statements and Loops]/
More Control Flow Tools

Flow control will need yes or no options to make decisions.In Python code,yes and no is shown as Boolean Values True and False.1.Boolean Values can be stored in variables and use as expressions.

Comparison Operators also called relational operators as below:

Equal to ==

Not equal to !=

Less than <

Greater than >

Less than or equal to <=

Greater than or equal to >=

When use comparison operators,an integer or floating-point value will always be unequal to a string value.That means 31!= ‘31’.Also The <, >, <=, and >=operators, on the other hand, work only with integer and floating-point values.Numbers! Never with string value.Computer will confuse if you did.
Don’t confuse with one equal side or two equal sides.
Two equal sides (equal to) asks whether 2 valus are the same with each other.(eg. True == True)

While one equal side is about puts value to the left side as variable. (Box in eg. Age = 7 )

The three Boolean operators are and, or, and not.

and,or always with 2 boolean values(experssions),considered as binary operators.
not only with one boolean value(experssion),considered as unary operator.
Python evaluates the not operators first, then the and operators, and then the or operators.

Flow control elements like conditions (like boolean values or expressions),blocks of code,program execution,flow control statements.(eg.if …: end with colon.or else:elif: while and for loops statement,continue and break statement.)

There are 3 rules of blocks of code:

Blocks begin when the indentation increases.

Blocks can contain other blocks.

Blocks end when the indentation decreases to zero or to a containing
block’s indentation.

Only use continue and break statements inside while and for loops.

For loops example as for i in range(3):

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/139580.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • UML图之例图

    用例图主要说明的是谁要使用系统,以及他们使用该系统可以做些什么,帮助开发团队以一种可视化的方式理解系统的功能需求。一个用例图包含了多个模型元素,如系统、参与者和用例,并且显示这些元素之间的各种关系,

    2021年12月29日
    40
  • chmod命令用法举例「建议收藏」

    chmod命令用法举例「建议收藏」chmod命令用于改变linux系统文件或目录的访问权限。该命令有两种用法。一种是包含字母和操作符表达式的文字设定法;另一种是包含数字的数字设定法。利用chown命令来更改某个文件或目录的所有者。利用chgrp命令来更改某个文件或目录的用户组。 chmod命令详细情况如下:1.命令格式:chmod[-cfvR][–help][–version]modefile  …

    2022年6月28日
    40
  • 计算机ata考试题库答案,ATA考试系统题库【机房系统】[通俗易懂]

    计算机ata考试题库答案,ATA考试系统题库【机房系统】[通俗易懂]职业道德1.下列不属于职业道德修养的内容的是(A)。A、强化职业技能教育B、端正职业态度C、强化职业情感D、历练职业意志2.职业道德作为(D),有着与其它的职业行为准则不具备的特征。A、社会行为准则B、工作行为准则C、社会交往准则D、职业行为准则3.下列不属于职业道德功能的有(D)。A、有利于调整职业利益关系B、有利于提高人民的道德水平C、有利于完善人格D、有利于人的职业生涯规划4..以下不属…

    2022年7月13日
    17
  • rsyslog配置日志服务器_linux开启rsyslog

    rsyslog配置日志服务器_linux开启rsyslogRsyslog是一个开源软件实用程序,用于UNIX和类Unix计算机系统,用于在IP网络中转发日志消息,收集日志。它实现了基本的syslog协议,通过基于内容的过滤,丰富的过滤功能,灵活的配置选项扩展了它,并添加了诸如使用TCP进行传输等功能。一、配置环境系统:Debian二、Rsyslog配置基本上Linux系统都安装Rsyslog服务但没有开启,只需要修改配置文件即可使用。首先,如…

    2022年9月25日
    0
  • windows-install-python-and-sphinx(*.rst file)

    windows-install-python-and-sphinx(*.rst file)

    2022年1月4日
    37
  • C#并行计算 Parallel.ForEach[通俗易懂]

    C#并行计算 Parallel.ForEach[通俗易懂]C#并行计算Parallel.ForEach///<summary>///获取订单链接///</summary>publicvoidGetOrders(){GetToken();HttpHelperhttp=newHttpHelper();HttpItemitem=newHttpIte…

    2022年7月19日
    23

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号