找回密码
 中文实名注册
查看: 250|回复: 0

肖尧11.14号星际跳高笔记

[复制链接]

23

主题

188

帖子

3539

积分

版主

Rank: 7Rank: 7Rank: 7

积分
3539
发表于 2021-11-14 11:26:18 | 显示全部楼层 |阅读模式
                                                                                                                                   肖尧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}米')
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 中文实名注册

本版积分规则

小黑屋|东台市机器人学会 ( 苏ICP备2021035350号-1;苏ICP备2021035350号-2;苏ICP备2021035350号-3 )

GMT+8, 2024-5-21 08:10 , Processed in 0.040463 second(s), 28 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表