个人作品集网站模板,室内装修设计软件有哪些,合肥能做网站的公司,专门做餐饮装修的公司CheckiO 是面向初学者和高级程序员的编码游戏#xff0c;使用 Python 和 JavaScript 解决棘手的挑战和有趣的任务#xff0c;从而提高你的编码技能#xff0c;本博客主要记录自己用 Python 在闯关时的做题思路和实现代码#xff0c;同时也学习学习其他大神写的代码。
Chec…
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 题目描述
【Fizz Buzz】“Fizz buzz” 是一个单词游戏我们将教会机器人学会关于除法的一些知识。你将要使用 python 写一个方法方法接收一个整数如果这个整数既可以整除 3 也可以整除 5则返回Fizz Buzz如果这个整数只能整除 3则返回Fizz如果这个整数只能整除 5则返回Buzz其他情况则返回传入的这个整数。
【链接】https://py.checkio.org/mission/fizz-buzz/
【输入】一个整数值
【输出】返回的结果字符串
【前提】0 number ≤ 1000
【范例】
checkio(15) Fizz Buzz
checkio(6) Fizz
checkio(5) Buzz
checkio(7) 7代码实现
# Your optional code here
# You can import some modules or create additional functionsdef checkio(number: int) - str:# Your code here# Its main function. Dont remove this function# Its using for auto-testing and must return a result for check.if number % 3 0 and number % 5 0:return Fizz Buzzelif number % 3 0:return Fizzelif number % 5 0:return Buzzelse:return str(number)# Some hints:
# Convert a number in the string with str(n)# These asserts using only for self-checking and not necessary for auto-testing
if __name__ __main__:print(Example:)print(checkio(15))assert checkio(15) Fizz Buzz, 15 is divisible by 3 and 5assert checkio(6) Fizz, 6 is divisible by 3assert checkio(5) Buzz, 5 is divisible by 5assert checkio(7) 7, 7 is not divisible by 3 or 5print(Coding complete? Click Check to review your tests and earn cool rewards!)大神解答 大神解答 NO.1 def checkio(number):#Your code here#Its main function. Dont remove this function#Its using for auto-testing and must return a result for check.if number%3!0 and number%5!0:return f{number}return f{(number%30)*Fizz}{(number%30 and number%50)* }{(number%50)*Buzz}大神解答 NO.2 def checkio(number: int) - str:if not number % 3 and not number % 5:return Fizz Buzzelif not number % 3 or not number % 5:return Fizz if not number % 3 else Buzzelse:return str(number)