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


相关推荐

  • ps去色的用法_索尼已经断气了.jpg

    ps去色的用法_索尼已经断气了.jpg原图1、ctrl+shift+u即去色2、ctrl+u降饱和度到最低3、图像——调整——渐变映射(前景色为黑色,背景色为白色或设置渐变为从黑到白)4、图像——调整——通道混合器勾选单色框5、图像——模式——灰度;再图像——模式——RGB6、图像——计算(调整好)——进入通道面板——复制Alpha1通道入图层7、进入通道面板——复制R、G、B任一效果最好的单色通道入图层8

    2022年10月5日
    0
  • 软件测试工程师自我介绍_软件测试工程师简历自我评价

    软件测试工程师自我介绍_软件测试工程师简历自我评价目录:导读一、前言:浅谈面试二、软件测试工程师:简历模板三、软件测试工程师:简历包装1.基本信息:2.教育背景:3.专业技能4.工作经历5.项目经验6.自我评价四、软件测试工程师:简历总结一、前言:浅谈面试面试是我们进入一个公司的门槛,通过了面试才能进入公司,你的面试结果和你的薪资是息息相关的。那如何才能顺利的通过面试,得到公司的认可呢?面试软件…

    2022年10月21日
    0
  • nomasp 博客导读:Android、UWP、Algorithm、Lisp(找工作中……[通俗易懂]

    nomasp 博客导读:Android、UWP、Algorithm、Lisp(找工作中……

    2022年1月29日
    44
  • 排列组合公式的原理_有序排列组合公式

    排列组合公式的原理_有序排列组合公式绪论:加法原理、乘法原理#分类计数原理:做一件事,有n类办法,在第1类办法中有m1种不同的方法,在第2类办法中有m2种不同的方法,…,在第n类办法中有mn种不同的方法,那么完成这件事共有N=m1+m2+…+mn种不同的方法。分步计数原理:完成一件事,需要分成n个步骤,做第1步有m1种不同的方法,做第2步有m2种不同的方法,…,做第n步有mn种不同的方法,那么完成这件事共有N=m1×m2×⋯×mn种不同的方法。区别:分类计数原理是加法原理,不同的类加起来就是我要得到的总数;分步计数原理是乘法原理,是同一

    2022年10月21日
    0
  • pycharm激活码2021年2月【2021免费激活】[通俗易懂]

    (pycharm激活码2021年2月)最近有小伙伴私信我,问我这边有没有免费的intellijIdea的激活码,然后我将全栈君台教程分享给他了。激活成功之后他一直表示感谢,哈哈~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html83…

    2022年3月27日
    46
  • springboot javamail_spring boot入门

    springboot javamail_spring boot入门一、导入相关依赖在springboot中配置MultipartResolver注:使用了Spring的MultipartFile来接受文件上传才要配置的二、controller(service)

    2022年8月16日
    5

发表回复

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

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