score = 0
#question1
answer1 = input("After the emperor was overthrown, what two political parties emerged in China?\na.Republican & Democrats\nb.Nationalist & Communist\nc.Fascists & Socialsts\nd.The People for Republic of China & The Japanese Communist Party\nAnswer:")
if answer1 == "b" or answer1 == "Nationalist & Communist":
score += 1
print("Correct!")
print("Score:", score)
print("\n")
else:
print("Wrong! The answer is b.Nationalist & Communist.")
print("Score:", score)
print("\n")
#question2
answer2 = input("Who was the leader of the Communist party?\na. Mao Zedong\nb. Deng Xiaoping\nc. George W. Bush\nd. Emperor Hirohito\nAnswer:")
if answer2 == "a" or answer2 == "Mao Zedong":
score += 1
print("Correct!")
print("Score:", score)
print("\n")
else:
print("Wrong! The answer is a. Mao Zedong.")
print("Score:", score)
print("\n")
#question3
answer3 = input("What did the Communist party promise to bring to China?\na.More freedom of speech\nb.Food to the poor and more wealth to all Chinese, and land reforms\nc.Freedom of religion\nd.More personal freedoms\nAnswer:")
if answer3 == "c" or answer3 == "Food to the poor and more wealth to all Chinese, and land reforms":
score += 1
print("Correct!")
print("Score:", score)
print("\n")
else:
print("Wrong! The answer is b.Food to the poor and more wealth to all Chinese, and land reforms.")
print("Score:", score)
print("\n")
#question4
answer4 = input("When was the Communist state of the People’s Republic of China established?\na.1900\nb.2008\nc.1989\nd.1949\nAnswer:")
if answer4 == "d" or answer4 == "1949":
score += 1
print("Correct!")
print("Score:", score)
print("\n")
else:
print("Wrong! The answer is d.1949.")
print("Score:", score)
print("\n")
#question5
answer5 = input("Why did poor peasants support the Chinese Communist Party?\na.They wanted to work in communes\nb.They had no other option\nc.It promised them food and a better quality of life\nd.Mao Zedong said he would give them money\nAnswer:")
if answer5 == "c" or answer5 == "It promised them food and a better quality of life":
score += 1
print("Correct!")
print("Score:", score)
print("\n")
else:
print("Wrong! The answer is c.It promised them food and a better quality of life.")
print("Score:", score)
print("\n")
有人能帮我优化这个代码吗?如果我有更多的问题,比如10或20个,它会把一切都搞砸。也许我需要使用循环,但是怎么做呢?以及如何制作,如果用户连续回答错误3次,那么游戏应该停止并提示“游戏结束!”。
您可以将三元组问题、短答案、长答案
存储在一个列表中,然后将您的逻辑应用于每个问题
QA = [
("After the emperor was overthrown, ... ", "b", "Nationalist & Communist"),
("Who was the leader of the Communist ...", "a", "Mao Zedong"),
("What did the Communist party ...", "c", "Food to the poor and ..."),
("When was the Communist state ...", "d", "1949"),
("Why did poor peasants support ...", "c", "It promised them food and a ...")
]
score = 0
for question, short_ans, long_ans in QA:
answer1 = input(question + "\nAnswer:")
if answer1 in (short_ans, long_ans):
score += 1
print("Correct!\nScore:", score, "\n")
else:
print("Wrong! The answer is ", short_ans, long_ans, "\nScore", score, "\n")
好吧,我已经在这方面工作了两天了--我的代码有点草率和混乱,但我已经翻阅了数百个问题,网站等等,寻找一个答案,或者只是一个我理解的解释;不幸的是,我的尝试仍然没有成功。 我正在PHP/HTML中构建一个“问答”游戏--该网站引用了一个数据库,特别是一个标有“答案”的列表,其中包含以下信息: 现在,对于站点的一点信息--一旦用户登录,他/她就可以“玩”游戏;游戏只是一个HTML表单,上面显示一个随机
删除问题 DELETE /api/v2/qa/questions/{id} 1 仅拥有 [Q&A] Manage Questions 或者是问题发布者本人才有权限删除 响应: Status: 204 No Content 1 删除回答 DELETE /api/v2/qa/answers/{id} 1 仅拥有 [Q&A] Manage Answers 或者是回答发布者本人才有权限删除 响应: Sta
这个产品可以用于生产环境吗?https://zeit.co 都是一直用 Next.js 写的。 它的开发体验和终端用户体验都很好,所以我们决定开源出来给大家共享。体积多大? 客户端大小根据应用需求不一样大小也不一样。 一个最简单 Next 应该用 gzip 压缩后大约65kb这个像 `create-react-app`? 是或不是. 是,因为它让你的 SSR 开发更简单。 不是,因为它规定了一定的
添加 saga 后应用程序被卡住了 确保你在 Generator 函数里 yield 了 effect。 参考下面这个示例: import { take } from 'redux-saga/effects' function* logActions() { while (true) { const action = take() // 错误 console.log(actio
什么是A-Frame? :a:-Frame 是一个用来构建虚拟现实(VR)应用的网页开发框架。由WebVR的发起人Mozilla VR 团队所开发,在three.js和DOM之上实现了声明式的实体-组件-系统模式。 为什么需要A-Frame A-Frame使得WebVR易于学习和快速开发,有益于构建WebVR的内容生态系统。 如何开始A-Frame的开发 阅读入门教程来建立基础概念和开发环境。 阅
本节记录了一些设计选择的理由。 它也作为一些(不是这样)常见问题的解答。 如果你认为某个问题应该添加到这个列表,开一个GitHub issue,我们将考虑改进文档或在这里添加问题。 为什么要限制外部依赖的使用? 这样做有几个原因。首先,Hana是一个非常基础的库;我们基本上重新实现了核心语言和支持异构类型的标准库。当编写代码时,人们会很快意识到,其他库很少需要,几乎一切都必须从头开始实现。此外,由