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)
上一篇 2022年5月29日 下午3:36
下一篇 2022年5月29日 下午3:46


相关推荐

  • xshell安装步骤_Xshell6

    xshell安装步骤_Xshell6开发环境部署目的:利用ssh远程登陆服务器(在windows系统下远程连接linux)下载XSHELL7XSHELL7下载网址:https://www.netsarang.com/zh/xshell/点击“下载”点击“免费授权界面”以上是XSHELL7的下载过程然后找到右键“以管理员身份运行”一上来会出现这种错误,先点击“是(Y)”过程中一直点击“下一步”,以及“我同意”类似的,然后选择个安装路径就可以没啥特殊的。到最后一切顺利的话会显示下面这样的界面一般通向成功的道

    2025年10月13日
    5
  • 最大子段和

    最大子段和

    2021年7月8日
    113
  • 记一次性能压测瓶颈排查

    记一次性能压测瓶颈排查

    2022年3月12日
    56
  • Python编程题2–水仙花数

    Python编程题2–水仙花数题目如果一个3位数等于其各位数字的立方和,则称这个数为水仙花数。例如:153=13+53+3^3,因此153就是一个水仙花数请按照从小到大的顺序输出1000以内的水仙花数

    2022年7月5日
    23
  • SpringBoot重点详解–使用JPA操作数据库[通俗易懂]

    SpringBoot重点详解–使用JPA操作数据库[通俗易懂]目录JPA&SpringDataJPA配置Maven依赖配置数据源和JPA创建POJO实体数据持久化使用SpringDataJPA接口(方式一)CrudRepositoryPagingAndSortingRepositoryJpaRepositoryQueryByExampleExecutor自定义查询方法(方式二)JUnit测试…

    2022年6月22日
    31
  • 电容及RC积分电路

    电容及RC积分电路在做项目时当我们需要将 PWM 信号转换为直流信号给单片机采集时 我们可以使用 RC 积分电路 RC 积分电路模型为 Vi 为输入的 PWM 方波 经过 RC 积分后就能够输出完整的直流信号 入下是周期为 5ms 的 pwm 经过 RC 之后的输出波形 积分电路实质上是利用的电容两端的电压不能突变的特性将直流脉冲信号转变为稳定的直流信号 选取合适的 R 和 C 同理我们也可以通过 rc 电路将 pwm 转换成各种波形 三角波 本章我们只讨论选取是当时 R 和 C 将 PWM 转变为直流信号 在此之前我们需要知道几

    2026年3月20日
    2

发表回复

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

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