30天程序语言研究

今天是30天程序语言研究的第十一天,研究的语言一样是python,今天主要学习的是问答程序

网址:https://www.youtube.com/watch?v=zdMUJJKFdsU&ab_channel=GrandmaCan-%E6%88%91%E9%98%BF%E5%AC%A4%E9%83%BD%E6%9C%83

笔记:

问答程序

#question.py
class Question:
def init(self, description, answer):
self.description = description
self.answer = answer

from question import Question #从档案question指引入Question
test = [
"1+3=?\n(a) 2\n(b) 3\n(c) 4\n\n",
"1公尺等於几公分?\n(a) 10\n(b) 100\n(c) 1000\n\n",
"香蕉是什麽颜色?\n(a) 黑色\n(b) 黄色\n(c) 白色\n\n"
]
questions = [
Question(test[0],"c"), #问题表达
Question(test[1],"b"),
Question(test[2],"b")
]
def run_test(questions):
score = 0
for question in questions:
answer = input(question.description)
if answer == question.answer:
score += 1
print("你得到" + str(score) + "分,共" + str(len(questions)) + "题")

run_test(questions)


<<:  30天程序语言研究

>>:  30天程序语言研究

MS Azure ML01

Microsoft Azure Machine Learning 终於开始罗。 <<前提...

Python 演算法 Day 9 - Exploratory Data Analysis

Chap.II Machine Learning 机器学习 https://yourfreetemp...

【Day8】[资料结构]-伫列Queue-实作

伫列(Queue)建立的方法 enqueue: 尾端新增元素 dequeue: 从前端移除元素 pe...

Day23 [实作] 一对一视讯通话(3): Client

昨天我们把 Signaling server 完成了,今天我们要继续完成 Client 端: 细部分...

[Day12] THM Cyborg

网址:https://tryhackme.com/room/cyborgt8 IP : 10.10...