Exam PCAP All QuestionsBrowse all questions from this exam
Question 8

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.

Discussion
Tarun1Option: B

its one line

AvidulamOption: B

It prints only in one line

N9Option: B

3 stars in one line

mplopezOption: A

The correct answer is A. The snippet returns ***.

naveenbv80Option: A

for i in range (1,3): print("*", end="") else: print("*") Answer is ***

peypaOption: C

range Starts at 1 and ends at 2

mplopez

It only works the for loop, the else part is no needed in this case because you didn't have any way to take.

IshanKarpeOption: A

Three lines, elseincluded

IshanKarpeOption: A

Stop Lying. IT DOES NOT PRINT 1, IT PRINTS THREE BC OF ELSE STATEMENT> TRIED AND TESTED

86b907fOption: B

Only one line ...

DempsdawgOption: B

Answer is B

CristianCruzOption: D

answer is D

DinshaOption: B

The * will print in one line

spiderking123Option: B

Answer is one line

beshaOption: B

one line and 3 stars

SuvabrataOption: A

A is correct...It will print ***

666_mOption: A

A is correct