#coding=utf-8
‘’’
这件事情 我不知道能不能发生 所以要先判断一下
如果 条件成立 去做什么事情 否则 去做什么事情
‘’’
from builtins import int
##########单分支
if 1==1: # 条件结束 后面要写英文冒号
print(‘ok’) #层级关系 python代码格式要求非常高 必须是4个空格
##########双分支
if 1==2:
print(‘ok’)
else: #冒号结束
print(‘error’)
###########多分支 只要有一个条件满足 后面就不运行了
score=input(‘input score:’)
score=int(score)
if score<60:
print(‘不及格’) #语句块 目前这里只写了一条语句,以后代码可以写很多
elif score==60:
print(‘及格’)
elif 60<score<=80:
print(‘良好’)
else:
print(‘优秀’)
############嵌套if
score=input(‘input score:’)
score=int(score)
if 0<=score<=100:
if score<60:
print(‘不及格’) #语句块 目前这里只写了一条语句,以后代码可以写很多
elif score==60:
print(‘及格’)
elif 60<score<=80:
print(‘良好’)
else:
print(‘优秀’)
else:
print(‘不要瞎输 0-100分’)
########################课堂练习##########################
‘’’
输入三边 告诉我是什么三角形(任意两边之和大于第三边, 不规则 等腰 等边 直角 )
‘’’
while 1: #为了调试方便 补一个死循环
x=float(input(‘input number1:’))
y=float(input(‘input number2:’))
z=float(input(‘input number3:’))
if x>0 and y>0 and z>0 :
if x+y>z and x+z>y and y+z>x:
if xyz:
print(‘等边’)
elif xy or yz or zx:
print(‘等腰’)
elif xx+yyzz or xx+zz==yy or yy+zz==x*x:
print(‘直角’)
else:
print(‘不规则’)
else:
print(‘无法构成三角形’)
else:
print(‘不要乱输’)