python基础2---选择结构,循环
作者:互联网
1.结构
# 1
s = 6
if s>60:
print('及格')
else:
print('不及格')
print('退出')# 注意缩进
# 2
s = 6
if s>60:
print('及格')
else:
print('不及格')
print('退出')# 注意缩进
#==============================================================
# if else
s = 86
a = 68
if s > 80 and a > 80:
print('优秀')
else:
print('不优秀')
s = 86
a = 68
if (80 <= a < 90) or (80 <= s < 90):
print('良好')
#===========================================================
# while
count = 100
while count > 0:
print('好好学习')
count -= 1
#=====================================================
# break
count = 100
while count > 0:
print('好好学习')
if count == 99:
break
count -= 1
# continue
count = 100
while count > 0:
print('好好学习')
if count % 2 == 0:
continue
count -= 1
#========================================================
# while else
count = 100
while count > 0:
print('好好学习')
count -= 1
else:
print('程序结束')
#===========================================================
# for
name = 'zhangsan'
for i in name:
print(i)
for i in range(1,20,2):
print(i,end=' ')
print()
# for(int i=10;i<20;i++)
# for i in range(10,20):
#========================================================
# 随机数
import random
num = random.randint(5,10)
print(num)
标签:count,python,好好学习,else,---,while,循环,print,80 来源: https://blog.csdn.net/qq_52384627/article/details/120255355