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):

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 使用SchedulerFactoryBean集成Quarz Job与Spring

    使用SchedulerFactoryBean集成Quarz Job与Spring本文介绍QuartzJob与Spring的集成。[list][*]QuartzJob官网:[url]http://quartz-scheduler.org[/url][*]Spring官网:[url]https://spring.io[/url][*][b]SchedulerFactoryBeanJavaDoc:[/b][url]http://docs.spring.i…

  • getopt在Python中的使用

    getopt在Python中的使用在运行程序时,可能需要根据不同的条件,输入不同的命令行选项来实现不同的功能。目前有短选项和长选项两种格式。短选项格式为”-“加上单个字母选项;长选项为”–“加上一个单词。长格式是在Linux下引入的。许多Linux程序都支持这两种格式。在Python中提供了getopt模块很好的实现了对这两种用法的支持,而且使用简单。取得命令行参数  在使用之前,首先要取得命令行参数。使用sys模块

  • 修改pycharm镜像源「建议收藏」

    修改pycharm镜像源「建议收藏」国内的镜像源地址:阿里云:http://mirrors.aliyun.com/pypi/simple/中国科技大学:https://mirrors.bfsu.edu.cn/pypi/web/simple/豆瓣:http://pypi.doubanio.com/simple/清华:https://pypi.tuna.tsinghua.edu.cn/simple/网易:https://mirrors.163.com/pypi/simple/在pycharm中配置镜像源地址:…

  • CFileDialog的使用方法简单介绍

    CFileDialog的使用方法简单介绍

    2021年11月30日
  • 摄像头-MIPI接口、DVP接口和CSI接口[通俗易懂]

    摄像头-MIPI接口、DVP接口和CSI接口[通俗易懂]本文转自摄像头的MIPI接口、DVP接口和CSI接口-百度经验(baidu.com),感谢作者分享一般来讲,摄像头的接口主要有MIPI接口、DVP接口、CSI接口三大类;我们常用的电脑摄像头接口是USB接口,而常见的智能手机上的摄像头是MIPI接口,还有一部分的摄像头(比如说某些支持DVP接口的硬件)是DVP接口;通俗的讲,USB是串行通用串行总线(UniversalSerialBus)的简称,而MIPI是移动行业处理器接口(MobileIndustryProcessorInterf

发表回复

您的电子邮箱地址不会被公开。

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