|
肖尧11.14号星际跳高笔记
1.当没有return时,代码会返回None
2.月球跳跃高度
def jump(height):
result = height*6
print(result)
jump(1)
3.半成品代码
def jump(height, planet):
if planet == '月球':
result = height*6
if planet == '火星':
result = height*2.5
if planet == '木星':
result = height*0.4
print(result)
jump(1,'火星')
4.完整代码
def jump(height, planet):
if planet == '月球':
result = height*6
if planet == '火星':
result = height*2.5
if planet == '木星':
result = height*0.4
sentence = '你可以在' + planet + '跳' + str(result) + '米'
print(sentence)
print(f'你可以在{planet}跳{result}米')
|
|