当前位置:首页 >> 编程语言 >> 【Python CheckiO 题解】Say Hi,酷锋i5

【Python CheckiO 题解】Say Hi,酷锋i5

0evadmin 编程语言 1
文件名:【Python CheckiO 题解】Say Hi,酷锋i5 【Python CheckiO 题解】Say Hi

CheckiO 是面向初学者和高级程序员的编码游戏,使用 Python 和 JavaScript 解决棘手的挑战和有趣的任务,从而提高你的编码技能,本博客主要记录自己用 Python 在闯关时的做题思路和实现代码,同时也学习学习其他大神写的代码。

CheckiO 官网:https://checkio.org/

我的 CheckiO 主页:https://py.checkio.org/user/TRHX/

CheckiO 题解系列专栏:https://itrhx.blog.csdn.net/category_9536424.html

CheckiO 所有题解源代码:https://github.com/TRHX/Python-CheckiO-Exercise


题目描述

【Say Hi】:你的任务是编写一个根据给出的属性参数来介绍一个人的函数

【链接】:https://py.checkio.org/mission/say-history/

【输入】:两个参数,一个字符串(str)和一个正整数(int)

【输出】:字符串(str)

【范例】:

say_hi("Alex", 32) == "Hi. My name is Alex and I'm 32 years old"say_hi("Frank", 68) == "Hi. My name is Frank and I'm 68 years old" 代码实现 # 1. on CheckiO your solution should be a function# 2. the function should return the right answer, not print it.def say_hi(name: str, age: int) -> str:return "Hi. My name is " + name + " and I'm " + str(age) + " years old"if __name__ == '__main__':#These "asserts" using only for self-checking and not necessary for auto-testingassert say_hi("Alex", 32) == "Hi. My name is Alex and I'm 32 years old", "First"assert say_hi("Frank", 68) == "Hi. My name is Frank and I'm 68 years old", "Second"print('Done. Time to Check.') 大神解答 大神解答 NO.1 def say_hi(name: str, age: int) -> str:return f"Hi. My name is {name} and I'm {age} years old" 大神解答 NO.2 def say_hi(name: str, age: int) -> str:return "Hi. My name is {0} and I'm {1} years old".format(name, age)
协助本站SEO优化一下,谢谢!
关键词不能为空
同类推荐
«    2025年12月    »
1234567
891011121314
15161718192021
22232425262728
293031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接