首页 / PYTHON / Python全栈课程004
Python全栈课程004
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Python全栈课程004,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1918字,纯文字阅读大概需要3分钟。
内容图文
![Python全栈课程004](/upload/InfoBanner/zyjiaocheng/626/e8fc6684ada745bd94de601cd48a3466.jpg)
程序结构
- 顺序
- 选择
- 循环
选择(分支)语句
- if语句
- if 表达式:
语句1
语句2
else:
语句
a = input("请输入数字:") #字符串
a = int(a)
if a < 10:
print("Python全栈课程")
else:
print("Linux从入门到放弃")
请输入数字:100
Linux从入门到放弃
#输入成绩,100-90分为优秀,89-80分为良好,79-60分为及格,60分以下为不及格
score = input("input your score:")
score = int(score)
if score <= 100 and score >= 90:
print("优秀")
else:
if score <= 89 and score >= 80:
print("良好")
else:
if score <= 79 and score >=60:
print("及格")
else:
print("不及格")
input your score:99
优秀
score = input("input your score:")
score = int(score)
if score <= 100 and score >= 90:
print("优秀")
elif score <= 89 and score >= 80:
print("良好")
elif score <= 79 and score >=60:
print("及格")
else:
print("不及格")
input your score:99
优秀
pass关键字
- 占位符
a = 1
if a < 2:
File "<ipython-input-12-504e793a112e>", line 2
if a < 2:
^
SyntaxError: unexpected EOF while parsing
a = 1
if a < 2:
pass
a = 1
if a < 2:
pass #跳过此语句,而不是终止
print("pass")
pass
循环
- for循环
- while循环
list = [1,2,3,4]
for i in list:
print(i)
1
2
3
4
list = [1,2,3,4]
for i in list:
print("**********************")
if i % 2 == 0:
print("Python全栈课程")
else:
print("Linux从入门到放弃")
print("**********************")
**********************
Linux从入门到放弃
**********************
**********************
Python全栈课程
**********************
**********************
Linux从入门到放弃
**********************
**********************
Python全栈课程
**********************
print(1)
print(2)#print()自动换行
1
2
print(1, end = "") #end的默认值为\n(换行)
print(2, end = "")
12
for i in range(1,101,2):#range:从1开始到100结束,步长为2
print(i, end = " ")
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99
list = [1,2,3,4]
for i in list:
print(i)
else:
print("python全栈课程")
print("Linux从入门到放弃")
1
2
3
4
python全栈课程
Linux从入门到放弃
内容总结
以上是互联网集市为您收集整理的Python全栈课程004全部内容,希望文章能够帮你解决Python全栈课程004所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。