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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • eureka集群快速搭建

    eureka集群快速搭建提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档eureka集群一、配置三个eureka-server二、启动三个eureka-server,并访问三、启动一个消费者四、访问三个eureka-server,都有消费者服务一、配置三个eureka-server三个eureka-server的application.yml文件如下eureka-serverserver:port:8761eureka:instance:hostname:eureka-s

    2022年5月4日
    35
  • 解决Please make sure you have the correct access rights and the repository exists 问题.

    解决Please make sure you have the correct access rights and the repository exists 问题.问题:Pleasemakesureyouhavethecorrectaccessrightsandtherepositoryexists请确保您具有正确的访问权限并且存储库存在原因:公钥出问题了,需要删除.ssh下文件,然后重设置用户名和邮箱再重新生成ssh公钥即可解决解决:步骤一:删除.ssh下所有所有文件步骤二:1.设置用户名gitconfig–globaluser.name‘zhandehu…

    2022年7月27日
    9
  • Linux中安装tree命令

    Linux中安装tree命令在CentOS系统的普通用户下,使用sudoyum-yinstalltree下载tree命令,在ubuntu系统的普通用户下,使用sudoapt-getinstalltree下载tree命令

    2022年7月24日
    11
  • Python保留小数位数_python怎么保留三位小数

    Python保留小数位数_python怎么保留三位小数python处理保留小数位数,包括四舍五入和不四舍五入。

    2022年8月11日
    105
  • 0603贴片电阻阻值对照表_贴片电阻快速识别表与识别方法[通俗易懂]

    0603贴片电阻阻值对照表_贴片电阻快速识别表与识别方法[通俗易懂]贴片电阻快速识别表与识别方法,要想快速识别贴片电阻,那就必须知道什么是贴片电阻?贴片电阻就是金属粉和玻璃釉粉混合,采用丝网印刷法印在基板上制成的电阻器。与贴片电容不一样的是,贴片电容一般比电容厚,且电阻两边为银白色镀锡,中间黑色。下面我们来看看具体的两个识别方法。快速识别贴片电阻,方法一:如上图所示,正面主要是中间黑色带电阻代码,方便识别贴片电阻大小,两头是锡面,银白色,方便焊接。背面中间是高纯度…

    2022年4月19日
    473
  • 罗马字符及数字_9罗马数字

    罗马字符及数字_9罗马数字罗马字符及数字小写 大写   中文      英文 α  Α    阿尔法  aerfar β   Β     卑塔     beita γ  Γ     嘎吗   gama δ  Δ    德儿塔    derlta ε   Ε   依普西龙   ipuseilong ζ   Ζ    zei塔  zei

    2022年9月30日
    3

发表回复

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

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