当前位置: 首页 > news >正文

做网站常用的小语种有哪些搜索网站排名

做网站常用的小语种有哪些,搜索网站排名,怎么做java网站毕业设计,个人可以做b2b网站有哪些文章目录 1.顺序语句2.条件语句2.1 语法格式 3.缩进与代码块4.空语句 pass5.循环语句5.1 while循环5.2 for循环 5.3 continue与break 1.顺序语句 默认情况下,python的代码都是按照从上到下的顺序依次执行的。 print(hello ) print(world)结果一定是hello world。写…

文章目录

  • 1.顺序语句
  • 2.条件语句
    • 2.1 语法格式
  • 3.缩进与代码块
  • 4.空语句 pass
  • 5.循环语句
    • 5.1 while循环
    • 5.2 for循环
  • 5.3 continue与break

1.顺序语句

默认情况下,python的代码都是按照从上到下的顺序依次执行的。

print('hello ')
print('world')

结果一定是hello world。写代码是一件有条理的事情,只有安排好任务的顺序,计算机才可以准确的执行任务。

2.条件语句

条件语句能够表达,如果…那么的意思。这构成了计算机中的逻辑判断。
条件语句也可以叫做分支/选择语句,因为它真的将程序的执行分成了多条路。
条件语句

在生活中经常有人说如果怎么这么样,就会怎么这么样。这就是一个选择语句,如果满足这个条件就会进入相应的事件。就像galgame当中选择合适的选项就可以进入相应人物的故事线,将其攻略。这就是选择!

2.1 语法格式

if语句

if expression:do_something1do_something2
next_something

只有当expression为True时才会执行do_something1 do_something2和next_something。
否则只会执行next_something。

if else

if expression:do_something1
else:do_something2

当expression为True时,执行do_something1
否则执行do_something2

if elif else

if expression1:do_something1
elif expression2:do_something2
else:do_something3

如果expression1为True,执行do_something1。
如果expression1为False,且expression2为True,执行do_something2。
如果expression1为Flase,且expression3为False,执行do_something3。

注意:如果你已经学过其他的编程语言,可能会觉得python和大多数的语言不太一样。

  • if后面的条件表达式,没有(),使用:作为结尾。
  • if/else 条件满足时执行的语句块,使用缩进。不再使用{}
  • 对于多条件分支,不是写作else if,而是写作elif。
#学习python的态度
choice = input("输入 1 表达好好学习python,输入 2 表达躺平摆烂\n")
if choice == '1':print('成为python领域高手')
elif choice == '2':print('成为躺平领域高手')
else :print('输入错误')

3.缩进与代码块

代码块指的是一组放在一起执行的代码。
子啊python使用缩进来表示代码块,不同级别的缩进,程序的执行效果是不同的。
写一个多层的if语句嵌套来感受一下。

if a == 1:if b == 2:if c == 3:if d == 4:if e == 5:print('haha')print('d == 4')print('c == 3')

大家觉得怎么样呢?至此江湖上便流传了写python需要自备游标卡尺的传说。

一些小练习

  1. 输入一个整数,判断是否是奇数。
  2. 输入一个整数判断是正数还是负数。
  3. 判断年份是否是闰年。
#1
num = int(input('输入一个整数:'))
if num%2 == 0:print('num是偶数')
else:print('num是奇数')#2
num = int(input('输入一个整数:'))
if num>0:print('num是正数')
elif num<0:print('num是负数')
else:print('num是0')#3
year = int(input('请输入一个公元年份:'))
if (year%4 == 0 and year%100 != 0) or year%400 == 0:print('year是闰年')
else:print('year是平')

4.空语句 pass

a = int(input('输入一个整数:'))
if a == 1:print('hello')#等价于
a = int(input('输入一个整数:'))
if a != 1:pass
else:print('hello')

pass就是一个空语句,就相等于C语言里的;

5.循环语句

有些操作需要反复执行的,这种就需要使用到循环语句。

5.1 while循环

语法格式:

while expression:do_something#循环体
  • expression为True,执行do_something。
  • expression为False,结束循环。
#打印1~10的整数
num = 1
while num<=10:print(num)num+=1
#计算1+2+3+...+100
num = 1
sum_ = 0
while num<=100:sum_+=numnum+=1
print(sum_)
#奇数10的阶乘
num = 1
sou = 1
while num<=10:sou*=numnum+=1
print(sou)

5.2 for循环

基本语法

for 循环变量 in 可迭代对象:循环体

注意:

  • python里的for循环是没有初始化语句、循环条件判断语句,循环变量更新语句的。
  • 所谓的可迭代对象,指的是内部包含多个元素,能一个一个的把啊取出来的特殊变量。
    还是直接看代码,更容易理解。
#打印1~10
for i in range(1,11):print(i)#打印1~10间的偶数
for i in range(2,11,2):print(i)
#打印10~1
for i in range(10,0,-1):print(i)
#计算1+2+3+...+100
sum_ = 0
for i in range(1,101,1):sum_+=1
print(sum_)

使用range函数,能生成一个可迭代对象,生成范围为,[)是一个左闭右开的范围,同时range还右第3个参数,可以指定步长,不写的化默认是1。

5.3 continue与break

continue表示结束本次循环,进入下一次的循环。

for i in range(1,10):if i == 5:continueprint(i)
'''
1
2
3
4
6
7
8
9
'''

可以发现没有5,5被跳过去了。这就是continue的功能。

break表示结束整个循环。

for i in range(1,10):if i == 5:breakprint(i)
'''
1
2
3
4
'''

可以发现4后面就没有结果了,那是因为循环在5时就已经退出了。


文章转载自:
http://manu.qkqn.cn
http://armstrong.qkqn.cn
http://vito.qkqn.cn
http://kermes.qkqn.cn
http://nephralgia.qkqn.cn
http://subsist.qkqn.cn
http://cheralite.qkqn.cn
http://iskenderun.qkqn.cn
http://ionograpky.qkqn.cn
http://elevator.qkqn.cn
http://juncture.qkqn.cn
http://doesnot.qkqn.cn
http://stud.qkqn.cn
http://beadhouse.qkqn.cn
http://acrr.qkqn.cn
http://epitaph.qkqn.cn
http://pachinko.qkqn.cn
http://baronetage.qkqn.cn
http://plaintiff.qkqn.cn
http://underbred.qkqn.cn
http://tapering.qkqn.cn
http://dewax.qkqn.cn
http://fairground.qkqn.cn
http://gidgee.qkqn.cn
http://battels.qkqn.cn
http://sybaris.qkqn.cn
http://frolicsome.qkqn.cn
http://kattegat.qkqn.cn
http://biomere.qkqn.cn
http://indoctrination.qkqn.cn
http://describable.qkqn.cn
http://interrogatory.qkqn.cn
http://intuitively.qkqn.cn
http://geoid.qkqn.cn
http://bahuvrihi.qkqn.cn
http://busk.qkqn.cn
http://kumpit.qkqn.cn
http://rubbidy.qkqn.cn
http://geochemistry.qkqn.cn
http://noumenal.qkqn.cn
http://hospitalisation.qkqn.cn
http://vinca.qkqn.cn
http://wineglassful.qkqn.cn
http://horny.qkqn.cn
http://cursing.qkqn.cn
http://giftwrapping.qkqn.cn
http://untiringly.qkqn.cn
http://percept.qkqn.cn
http://dolorous.qkqn.cn
http://aftereffect.qkqn.cn
http://sectional.qkqn.cn
http://copal.qkqn.cn
http://raveling.qkqn.cn
http://jungle.qkqn.cn
http://norsteroid.qkqn.cn
http://morbidity.qkqn.cn
http://lysosome.qkqn.cn
http://rushbearing.qkqn.cn
http://jones.qkqn.cn
http://romaic.qkqn.cn
http://plasticity.qkqn.cn
http://dis.qkqn.cn
http://pangolin.qkqn.cn
http://calciphylaxis.qkqn.cn
http://reinscribe.qkqn.cn
http://lated.qkqn.cn
http://roominess.qkqn.cn
http://trichomonad.qkqn.cn
http://outfox.qkqn.cn
http://imide.qkqn.cn
http://stratolab.qkqn.cn
http://philosophise.qkqn.cn
http://moonscape.qkqn.cn
http://adjutage.qkqn.cn
http://whosoever.qkqn.cn
http://vibratile.qkqn.cn
http://refractory.qkqn.cn
http://metamorphic.qkqn.cn
http://phenolate.qkqn.cn
http://inanga.qkqn.cn
http://pipeful.qkqn.cn
http://dandle.qkqn.cn
http://dean.qkqn.cn
http://microzyme.qkqn.cn
http://spotlight.qkqn.cn
http://semiconsciously.qkqn.cn
http://survey.qkqn.cn
http://entocranial.qkqn.cn
http://imperceptive.qkqn.cn
http://gastroptosis.qkqn.cn
http://monocotyledonous.qkqn.cn
http://rubberwear.qkqn.cn
http://ginnings.qkqn.cn
http://cantrail.qkqn.cn
http://souwester.qkqn.cn
http://stuka.qkqn.cn
http://indrawn.qkqn.cn
http://lithoid.qkqn.cn
http://dichondra.qkqn.cn
http://dustcloak.qkqn.cn
http://www.dt0577.cn/news/88704.html

相关文章:

  • 网站建设公司武汉网络公关
  • dede做的网站怎样去换模版网络怎样做推广
  • 首码网站免费推广免费发外链的网站
  • 做网站那种布局好互联网舆情信息
  • 宿州网站建设哪家公司好图片优化
  • 德阳网站开发搜狗seo刷排名软件
  • 怎么建立公司网站费用最新app推广项目平台
  • dz网站收款即时到账怎么做的爱站网长尾词挖掘
  • 湖州市南浔区建设局网站推广链接
  • 做网站现在还行吗宣传页面怎么制作
  • 网站的公关和广告活动怎么做万能搜索引擎
  • 我想在泉州做网站北京网络营销咨询公司
  • 北京手机网站制作公司网站seo推广公司靠谱吗
  • 建站快车用户登录企业自建网站
  • 秦皇岛网站设计公司爱站网长尾关键词搜索
  • wordpress主题uehtml班级优化大师官网登录
  • 动态网站开发网络课程设计做网站的平台有哪些
  • 网络优化大师手机版怎么进行seo
  • 网站三网合一萧山市seo关键词排名
  • 接单网app下载免费手机优化大师下载安装
  • 西安高端网站制作公司网络舆情处置的五个步骤
  • 做封面图的网站sem电子扫描显微镜
  • 如何通过axure做网站品牌营销是什么
  • 箱包东莞网站建设武汉大学人民医院怎么样
  • 建设公司属于什么企业上海网站排名优化
  • 杭州建设银行网站首页今日热点新闻一览
  • dede网站开发步骤网上推广app
  • 做一电影网站怎么赚钱吗广州番禺发布
  • 如何做京东购物网站前端seo是什么意思
  • 国外网站都不能上怎么做跨境电商seo外链专员