您的位置:首页 > 理论基础

计算机科学与编程导论小习题-MIT

2015-04-12 15:33 253 查看
第七课:数组以及可变性,字典,伪码,对于代码运行效率的简介

关于求解三角形斜边长的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))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: