【发布时间】:2019-02-01 13:03:05
【问题描述】:
这是我想出的,我不明白为什么会这样,因为我的期望是每个正确答案都会增加分数,任何错误答案都会扣分。
name = str(input("What is your name?: "))
score = 0
answer1 = str(input("(1) What is the name of the first president of Nigeria? \n(a) Amadu Bello \n(b) Shehu Shagari \n(c) Olusegun Obasanjo \n(d) Nnamdi Azikwe\n:Your answer: "))
if answer1 == "d" or "D" or "Nnamdi" or "Nnamdi Azikwe" and "Azikwe":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
answer2 = str(input("(2) What is the name of the capital of Lagos state? \n(a) Ikorodu\n(b) Ikeja\n(c) Surulere\n(d) Victoria Island\nYour answer: "))
if answer2 == "a" or "A" or "Ikeja":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
answer3 = str(input("(3) What is the name of the first capital of Nigeria?\n(a) Kano \n(b) Abuja\n(c) Lagos\n(d) Calabar\nYour Answer: "))
if answer3 == "c" or "C" or "lagos" and "Lagos":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
answer4 = str(input("(4) What is the name of the governor of Lagos when Code-Lagos was first implemented? \n(a)Raji Fashola\n(b)Akinwunmi Ambode\n(c) Ahmed Tinubu\n (d) Lateef Jakande\nYour answer: "))
if answer4 == "b" or "B" or "Ambode" or "Akinwunmi Ambode" or "akinwunmi ambode":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
answer5 = str(input("(5) Which of the following is indigenous Nigerian content? \n(a) Etisalat\n(b) Airtel\n(c) MTN\n(d) Globacoms\n Your Answer: "))
if answer5 == "d" or "D" or "glo" or "Glo" or "GLO":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
输出,只接受任何正确答案并加分。
【问题讨论】:
-
考虑给minimal reproducible example,而不是倾倒你所有的代码...
-
为了详细说明这里出了什么问题(以及 MCVE 如何导致更强有力的问题)——我们的目标是建立对尽可能多的人有帮助的问题和答案的集合尽可能。这意味着每个问题都应该专注于它所包含的问题,而忽略不相关的细节;仅发布产生该问题的最短代码可以更轻松地查看错误,从而更容易理解答案如何修复它,因此犯相同错误的其他人可以更轻松地看到相似性并从您的问题的答案中学习。跨度>
-
...类似地,一个理想的标题关注的是你遇到的问题,而不是你遇到它时想要完成的事情——因为这是对别人有用的问题将寻找;下一个在理解
or的工作原理方面犯同样错误的人可能不会自己也参与测验程序。
标签: python