第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python中的測驗游戲循環(huán)

Python中的測驗游戲循環(huán)

翻翻過去那場雪 2021-11-02 15:27:26
class Question:    def __init__(self, prompt, answer):        self.prompt = prompt        self.answer = answer我創(chuàng)建了上面的question_class.py文件并將其導(dǎo)入下面的quiz.py文件。我正在嘗試運行一個 while 循環(huán)來詢問用戶是否有興趣再次播放測驗。但是,代碼不會運行。如何在循環(huán)中再次正確插入播放?另外,我如何詢問用戶是否準(zhǔn)備好玩游戲并正確檢查輸入錯誤?這是我的第一個個人項目,并在完成初學(xué)者教程后嘗試學(xué)習(xí)如何編寫自己的項目。我感謝所有反饋。    from question_class import Question    username = input("What is your name? ")    print(f"Welcome, {username}!")    play_again = 'y'    while play_again == 'y':    question_prompts = [    ]    questions = [        Question(question_prompts[0], "b"),        Question(question_prompts[1], "a"),    ]    def run_test(questions):    score = 0    for question in questions:        answer = input(question.prompt)        if answer == question.answer:            score += 1        print("You answered " + str(score) + "/" + str(len(questions)) + " correct.")    play_again = input("Want to play again(y/n): ")    run_test(questions)
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 155 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號