美文网首页
Python循环语句

Python循环语句

作者: 魔曦帝天 | 来源:发表于2019-08-26 00:00 被阅读0次

if语句

if 条件语句: # 注意这里必须以英文的冒号结束
条件语句为真时,执行的语句
elseif 条件语句:
条件语句为真时,执行的语句
else:
执行语句

while 循环

while True:
执行代码

for循环

for i in 'hello world':
    print(i)


for i in range(5):
    print(i)

>1为true,0为fales 双重否定为肯定,

数值判断

range(n)

产生一个可被循环的整数序列,默认序列的元素从 零 开始

range(1,6)  含有1到5的值,
#####range
python3存储的是算法代码,调用执行
含有不包括下边值之间的数  
输出1到4
for i in range(5):   
    print(i)

相关文章

  • 012.Python循环语句

    Python 循环语句 1. 概述 Python中的循环语句有 for 和 while。 Python循环语句的控...

  • python 基础 - 循环语句

    python 循环语句 Python中的循环语句有 for 和 while。Python循环语句的控制结构图如下所...

  • 我的python学习笔记-第十天

    循环语句 Python中的循环语句有 for 和 while。 while 循环 Python中while语句的一...

  • Lesson 021 —— python 循环语句

    Lesson 021 —— python 循环语句 Python中的循环语句有 for 和 while。 循环可以...

  • python 循环语句

    本次将为大家介绍Python循环语句的使用。Python中的循环语句有 for 和 while。Python循环语...

  • continue

    Python continue 语句Python continue 语句跳出本次循环,而break跳出整个循环。 ...

  • python循环语句详细讲解

    想必大家都知道python循环语句吧,可以python循环语句有多种,比如for循环、while循环、if、els...

  • python循环语句详细讲解

    想必大家都知道python循环语句吧,可以python循环语句有多种,比如for循环、while循环、if、els...

  • 14、python循环语句

    本章节将为大家介绍Python循环语句的使用。Python中的循环语句有 for 和 while。 while循环...

  • Python3入门(五)循环语句

    Python中的循环语句有 for 和 while。Python循环语句的控制结构图如下所示 一、while循环 ...

网友评论

      本文标题:Python循环语句

      本文链接:https://www.haomeiwen.com/subject/siwmsctx.html