Exam PCAP All QuestionsBrowse all questions from this exam
Question 118

What is the expected behavior of the following code?

    Correct Answer: D

    D

Discussion
kontraOption: A

Exam has no typo errors. Output is [4,2] Answer is: A

gekkehenkOption: D

Answer is indeed D, due to the ] before the if statement. If this bracket wouldnt be there, the result would be [4, 2]. my_list = [i for i in range(5,0,-1)] m = [my_list[i] for i in range(5) if my_list[i] % 2 == 0] print(m) [4, 2]

beshaOption: A

if ] in the correct place, then the correct answer would be A

seaverickOption: D

my_list = [i for i in range(5,0,-1)] m=[my_list[i] for i in range(5)] if my_list[i]%2==0 print(m) #output SyntaxError: expected 'else' after 'if' expression Ans is D

andr3

can somebody who took exam already confirm if in real exam code is erroneous ?

Rizos

There are no typos or indentation issues in the real exam.

angelika_azOption: D

SyntaxError, - there is no else statement

macxszOption: D

D. the code is erroneous and it will not execute