嗨,我只是在这里测试这个示例项目,并得到这个奇怪的错误,可以搞清楚吗? // [英] Hi im just testing this sample project here and getting this strange error and can figure it out ? //

查看:64
本文介绍了嗨,我只是在这里测试这个示例项目,并得到这个奇怪的错误,可以搞清楚吗? //的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

animals_questions = 'Animals Questions'
capitals_questions = 'Capitals Questions'
math_questions = 'Math Questions'

questions = [animals_questions, capitals_questions, math_questions]

quiz = {animals_questions: [("All lionesses in a pride", True),
                        ("Another animals question", False),
                        ("Last animals question", False)],

        capitals_questions: [("Cairo is the capital city of Egypt", True),
                         ("Another capitals question", True),
                         ("Last capitals question", False)],

        math_questions: [("20 is log 100 for base 1o", False),
                     ("Another math question", True),
                     ("Last math question", False)]
}

result = {"Correct": 0, "Incorrect": 0}

def get_quiz_choice():
    while True:
        try:
            quiz_number = int(input(
                'Choose the quiz you like\n1 for {}\n2 for {}\n3 for {}\nYour choice:'.format(animals_questions,
                                                                                          capitals_questions,
                                                                                          math_questions)))
        except ValueError:
            print ("Not a number, please try again\n")
        else:
            if 0 >= quiz_number or quiz_number > len(quiz):
                print ("Invalid value, please try again\n")
            else:
                return quiz_number


def get_answer(question, correct_answer):
    while True:
        try:
            print ("Q: {}").format(question)
            answer = int(raw_input("1 for True\n0 for False\nYour answer: "))
        except ValueError:
            print ("Not a number, please try again\n")
        else:
            if answer is not 0 and answer is not 1:
                print ("Invalid value, please try again\n")
            elif bool(answer) is correct_answer:
                result["Correct"] += 1
                return True
            else:
                result["Incorrect"] += 1
                return False


choice = get_quiz_choice()
quiz_name = questions[choice - 1]
print ("\nYou chose the ()\n").format(quiz_name)
quiz_questions = quiz[quiz_name]
for q in (quiz_questions):
    print ("Your answer is: {}\n").format(str(get_answer(q[0], q[1])))





我尝试了什么:



i固定的错误总和让我在打印时遇到错误( Q:{})。格式(问题)



What I have tried:

i fixed sum of the errors put im getting error at print ("Q: {}").format(question)

推荐答案

与编写它的人交谈,而不是我们。

这是一个示例项目,我们不知道什么是奇怪的错误,甚至是示例代码应该做的事情,你有问题。



所以去回到你得到它的地方,并寻找联系作者的方法。例如,这里的每篇文章都在底部有一个论坛,您可以直接与作者联系。所以如果你在这里找到它,那就是开始的地方。
Talk to the people who wrote it, not us.
It's a sample project and we have no idea what a "strange error" is, or even what the sample code is supposed to do that you are having problems with.

So go back to where you got it, and look for a way to contact the author. For example, every article here has a forum at the bottom where you can contact the author directly. So if you found it here, that's the place to start.


这篇关于嗨,我只是在这里测试这个示例项目,并得到这个奇怪的错误,可以搞清楚吗? //的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆