第七课:数组以及可变性,字典,伪码,对于代码运行效率的简介
关于求解三角形斜边长的python代码:
import math
inputok=False
while not inputok:
base=input("enter base:")
if type(base)==type(1.0):inputok=True
else:print("error.base must be a floating point number")
inputok=False
while not inputok:
height=input("enter height:")
if type(height)==type(1.0):inputok=True
else:print("error.height must be a floating point number")
hyp=math.sqrt(base*base+height*height)
print("base: "+str(base)+",height: "+str(height)+",hyp: "+str(hyp))