洛谷题单2-P5712 【深基3.例4】Apples-python-流程图重构
题目描述
小 B 喜欢吃苹果。她今天吃掉了
x
x
x 个苹果。英语课上学到了 apple 这个词语,想用它来造句。如果她吃了 1 个苹果,就输出 Today, I ate 1 apple.
;如果她没有吃,那么就把 1 换成 0;如果她吃了不止一个苹果,别忘了 apple
这个单词后面要加上代表复数的 s
。你能帮她完成这个句子吗?
输入格式
输入一行一个自然数 x x x,表示吃掉的苹果数。
输出格式
根据题目要求输出。
输入输出样例
输入
1
输出
Today, I ate 1 apple.
方式
代码
class Solution:
@staticmethod
def oi_input():
"""从标准输入读取数据"""
x = int(input())
return x
@staticmethod
def oi_test():
"""提供测试数据"""
return 1
@staticmethod
def solution(x):
if x == 1 or x == 0:
print(f"Today, I ate {x} apple.")
else:
print(f"Today, I ate {x} apples.")
oi_input = Solution.oi_input
oi_test = Solution.oi_test
solution = Solution.solution
if __name__ == '__main__':
'''用oi_test()接受数据,然后传入solution'''
x = oi_test()
# x = oi_input()
solution(x)