Example #1
0
    'choices': {
        "[1, 3]": True,
        "[1, 1, 3, 9]": False,
        "[1, 1, 1, 1, 1, 1, 3, 9, 27, 81]": False,
        "(1, 3)": False,
        "None of the above": False
    }
})
#Question 8
q_lines = [
    "What is the ouptput of the following?",
    ">>> print [[i,j] for i in range(3) for j in range(i)]", "\n"
]
quiz_list.append({
    'question': '\n'.join(q_lines),
    'choices': {
        "This produces an error":
        False,
        "[[1, 0], [2, 0], [2, 1]]":
        True,
        "[[0, 0], [1, 0], [2, 0]]":
        False,
        "[[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1]]":
        False,
        "[[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]":
        False
    }
})

test = Quizzer.selfTest(quiz_list=quiz_list)
Example #2
0
                {
                'question':'\n'.join(q_lines),
                'choices' : { "lst(1)(2)(1)(1)" :False,
                              "lst[1][2][1][1]" :False,
                              "lst[2][0][0][1]" :False,
                              "lst(1)(1)(1)(0)":False,
                              "lst[1][1][1][0]":True,
                              }
                }
                )

#Question 6
q_lines = ["let lst = ['a', 'b', 'c', 'd']",
    "Which of the following commands would print the list backwards?",
        "\n"]
quiz_list.append(
                {
                'question': '\n'.join(q_lines),
                'choices': {"lst[-1:0:-1]":False,
                            "lst[1:0:1]":False,
                            "lst[-1::-1]":True,
                            "lst[3::1]":False,
                            "lst[3::-1]":False,
                            }
                }
                )



test = Quizzer.selfTest(quiz_list=quiz_list)