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


相关推荐

  • python循环语句for怎么用_python编程

    python循环语句for怎么用_python编程Python的for循环for语句是Python中执行迭代的两个语句之一,另一个语句是while。如果你对Python的迭代并不是很熟悉的话,Python中的迭代:for、while、break、以及continue语句是一个不错的切入点。Python中,for循环用于遍历一个迭代对象的所有元素。循环内的语句段会针对迭代对象的每一个元素项目都执行一次。暂且可以将迭代对象想象成一个对象集合,我们可以一个个遍历里面的元素。用for循环获取列表元素一、在获取值也获取下标方式一:当在py

    2022年8月12日
  • 数据库的查询语句_数据库select from where

    数据库的查询语句_数据库select from where一、温馨提示在dos窗口登录mysql,这里面使用库,给库中表添加一条中文数据—-会出现插入数据有问题,中文错误这是因为:1、在dos窗口中,默认的编码格式gbk,而mysql服务器软件使用的编码utf82、在dos窗口输入一个指令,模糊查询当前mysql数据库中所有带有”character”字符集的变量全部出来SHOWVARIABLESLIKE’%character%’;3、在dos窗口中需要修改setchar…

    2022年9月7日
  • CSS Opacity属性对层叠上下文的影响

    CSS Opacity属性对层叠上下文的影响今天在遇到一个opacity过渡的时候,遇到了一个奇怪的问题:父元素设置了opacity。子元素设置了z-index:-1

    2022年5月25日
  • Intro to Filtering with Network Monitor 3.0

    Intro to Filtering with Network Monitor 3.0

    2022年2月21日
  • 【JavaScript】——入门

    【JavaScript】——入门

    2021年9月7日
  • Windows 定时执行脚本[通俗易懂]

    Windows 定时执行脚本[通俗易懂]Windows定时执行脚本1、参考资料windows设置定时执行脚本2、解决办法由于Windows系统,无法使用Linux下强大的crontab命令,所以该定时任务也是针对Windo系统的具体操作步骤右击【我的电脑】,选择【管理】在【任务计划程序】面板中点击【创建基本任务】输入任务的【名称】和【描述】当然是希望每天自动执行防疫打卡啦~设置每天执行任务的时间,以及每隔几天执行一次该任务选择【启动程序】选择启动程序的startup.bat

    2022年7月17日

发表回复

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

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