Question 6 of 141

What is the output of the following piece of code?

    Correct Answer: C

    B

Question 7 of 141

What is the expected output of the following snippet?

    Correct Answer: A

    The code contains a syntax error. Specifically, the comparison within the if statement uses a single equals sign (i % 2 = 0) which is incorrect for equality comparison in Python. It should use a double equals sign (i % 2 == 0). Therefore, the code will not run and will raise a syntax error. Hence, the expected output is that the code is erroneous.

Question 8 of 141

How many lines does the following snippet output?

    Correct Answer: B

    The code snippet has a for loop that iterates over the range (1, 3), which means it will run for i=1 and i=2. In each iteration, print('*', end='') will execute, which prints '*' without moving to a new line. After the loop, the else clause will execute, printing '*' and moving to a new line. Therefore, the entire output will be '***' on a single line.

Question 9 of 141

Which of the following literals reflect the value given as 34.23? (Choose two.)

    Correct Answer: A, B

    AB

Question 10 of 141

What is the expected output of the following snippet?

    Correct Answer: D

    A