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)


相关推荐

  • 从网页抓取数据的一般方法

    首先要了解对方网页的运行机制 ,这可以用httpwacth或者httplook来看一下http发送和接收的数据。这两个工具应该说是比较简单易懂的。这里就不再介绍了。主要关注的内容是heade

    2021年12月27日
  • apache 转发 配置_url导入配置

    apache 转发 配置_url导入配置本文主要测试通过配置Apachehttpd实现url转发,以及配置ssl协议实现支持https转发。

    2022年10月18日
  • 8天学通MongoDB——第七天 运维技术

    8天学通MongoDB——第七天 运维技术

  • 字符串匹配算法_字符串模式匹配算法

    字符串匹配算法_字符串模式匹配算法目录Brute-Force算法Knuth-Morris-Pratt算法确定有限状态自动机部分匹配表Boyer-Moore算法Rabin-Karp算法总结网络信息中充满大量的字符串,对信息的搜寻至关重要,因此子字符串查找(即字符串匹配)是使用频率非常高的操作:给定一段长度为N的文本和长度为M的模式字符串(N≥M),在文本中找到一个和模式串相匹配的子串。由这个问题可以延…

  • 凶残的挖矿脚本,奴役我数千机器!

    凶残的挖矿脚本,奴役我数千机器!本文转载自不正经程序员温馨提示:本文中出现的命令和脚本,不要在自家服务器上随便运行,除非你知道自己在做什么。挖矿是把机器当作奴隶,一刻不停歇的去计算、运转,本质上是个无用的工作。但可惜的是,它能赚钱。用别人的机器去赚钱,更是很多人梦寐以求的,所以挖矿脚本屡禁不止。有钱的地方,就有技术。但反过来并不一定成立。牢记这个准则,就能够心平气和的学习新技术,而不是气急败坏的纠结为啥没钱。1.脚本从哪来?下面是一个http的报文。GET/console/images/%2E%2E%2F

发表回复

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

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