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


相关推荐

  • 通讯加密方式?「建议收藏」

    通讯加密方式?「建议收藏」客户端信道处理ProcessMessage1加密通讯 初始唯一标识和加密提供程序 向服务器请求密钥并根据响应的密钥初始化加密提供程序(服务端需验证IP合法性) 根据加密提供程序加密请求消息 向服务器发起请求 根据加密提供程序解密响应流。 返回。2非加密通讯 初始唯一标识和加密提供程序 向服务器请求密钥并根据响应的密钥初始化加密提供程序(服务端需验证IP合法性) 向服务器发起请求 返回…

    2022年5月2日
    62
  • 镁光硬盘测试软件,镁光固态硬盘评测[通俗易懂]

    镁光硬盘测试软件,镁光固态硬盘评测[通俗易懂]镁光M500DC企业级120G固态硬盘前言近期NAND市场为值友所喜闻乐见,3DTLC大幅度跳水,越来越多厂商加入瓜分市场的行列,加之QLC即将大量问世,M.2接口的SSD即将冲破1元1G的大关。在此情景下,SATA口SSD在各类值得买爆款里随便挑一款不失为一个很好的选择,然而对于不少值友,TLC的寿命、写入放大、全盘模拟SLC导致后期掉速、黑白片拆机ufs等诸多问题的存在,终究无法满足其苛刻的…

    2022年6月22日
    46
  • 极影动漫_风车动漫无删减免费下载

    极影动漫_风车动漫无删减免费下载极影动漫链接:http://vod.ktxp.com…

    2022年8月23日
    3
  • 基于Vue的电商后台管理系统(2)

    基于Vue的电商后台管理系统(2)电商后台管理系统2前言上期已经实现该系统的登陆界面、路由、登录、退出及导航守卫功能,本期将继续完善该系统的以下功能:从后端获取后台列表数据并渲染到前端页面、用户列表的展示、修改、删除和添加。后台页面布局本系统后台将采用ElementUI中的Container布局容器。基本结构如下:代码框架:<el-container><el-header>Header</el-header><el-container><el-a

    2022年6月11日
    31
  • ubuntu卸载foxit reader「建议收藏」

    ubuntu卸载foxit reader「建议收藏」翻译自:https://askubuntu.com/questions/816678/how-can-i-uninstall-foxit-reader-from-16-04使用安装目录里面的maintenancetool通常的安装目录为home/(user)/opt/foxitsoftware/foxitreader,也可以通过locatefoxit查找目录可能需要root权限,使用…

    2022年5月30日
    82
  • 操作系统实验一:进程管理(含成功运行C语言源代码)[通俗易懂]

    操作系统实验一:进程管理(含成功运行C语言源代码)[通俗易懂]目录操作系统实验一:进程管理实验目的实验内容操作系统实验一:进程管理1.实验目的1.理解进程的概念,明确进程和程序的区别2.理解并发执行的实质3.掌握进程的创建、睡眠、撤销等进程控制方法2.实验内容用C语言编写程序,模拟实现创建新的进程;查看运行进程;换出某个进程;杀死运行进程等功能。3.实验准备以下将分别介绍①进程的概念,以及进程的各类状态(就绪状态、执行状态、阻塞状态);②进程控制块PCB的作用及内容信息③进程的创建与撤销(????重.

    2022年10月20日
    1

发表回复

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

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