python小程序,python如何問問題_Python簡單問答程序如何解決問題循環

 2023-12-01 阅读 31 评论 0

摘要:Python學習者(2.7.5版)。在python小程序、目前我正在開發一個簡單的測試腳本,允許用戶重新回答問題,并限制用戶錯誤回答問題的機會。在因此設置了5個總限制,并顯示一條消息(例如“END!”)當達到限制時將顯示給用戶。所有問題都有這個限制。在pyth

Python學習者(2.7.5版)。在

python小程序、目前我正在開發一個簡單的測試腳本,允許用戶重新回答問題,并限制用戶錯誤回答問題的機會。在

因此設置了5個總限制,并顯示一條消息(例如“END!”)當達到限制時將顯示給用戶。所有問題都有這個限制。在

python用什么編譯器。當我測試下面提到的腳本時,我發現了幾個問題。在

1)即使問題1被錯誤回答了5次,問題2仍然會顯示,如果已經達到限制,我如何防止下一個問題出現?在

python基礎教程,2)我想問我應該在哪里插入結束消息的代碼(“end!”)如果達到了極限?在

非常感謝!在def quiz():

score = 0

counter = 0

print "Please answer the following questions:"

print "Question 1 - ?"

print "a."

print "b."

print "c."

while counter <5:

answer = raw_input("Make your choice:")

if answer == "c":

print("Correct!")

score = score +1

else:

print("Incorrect!")

counter = counter +1

print "Question 2 - ?"

print "a."

print "b."

print "c."

while counter <5:

answer2 = raw_input("Make your choice:")

if answer2 == "a":

print("Correct!")

score = score +1

else:

print("Incorrect!")

counter = counter +1

print

print ("Your score is ") + str(score)

另外,代碼似乎有點偏離了復制粘貼功能。很抱歉給您帶來不便

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/1/187056.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息