以下是代码运行效果:
你最喜欢的美食是什么?
请回答问卷问题,按 q 键退出:(用户输入三汁焖锅)
请回答问卷问题,按 q 键退出:(用户输入海鲜大咖)
请回答问卷问题,按 q 键退出:(用户输入牛排)
请回答问卷问题,按 q 键退出:(用户输入q)
美食:三汁焖锅
美食:海鲜大咖
美食:牛排
以下是待完善的代码:
class Survey():
def __init__(self, question): # 收集调查问卷的答案
self.question = question
self.response = []
def show_question(self): # 显示调查问卷的题目
print(self.question) # 存储问卷搜集的答案
def store_response(self, new_response):
self.response.append(new_response)
你最喜欢的美食是什么?
请回答问卷问题,按 q 键退出:(用户输入三汁焖锅)
请回答问卷问题,按 q 键退出:(用户输入海鲜大咖)
请回答问卷问题,按 q 键退出:(用户输入牛排)
请回答问卷问题,按 q 键退出:(用户输入q)
美食:三汁焖锅
美食:海鲜大咖
美食:牛排
以下是待完善的代码:
class Survey():
def __init__(self, question): # 收集调查问卷的答案
self.question = question
self.response = []
def show_question(self): # 显示调查问卷的题目
print(self.question) # 存储问卷搜集的答案
def store_response(self, new_response):
self.response.append(new_response)
