141k views
1 vote
Which of the following code snippets will output the following:

Hello
Hello
Hello



A:
print("Hello")
print("Hello")
print("Hello")

B:
for i in range(3):
print("Hello")

C:
print("Hello"*3)

D:
print("Hello\\"*3)

2 Answers

5 votes

Answer:

option A B D

Step-by-step explanation:

hope helps you

have a nice day

User Jeff Fischer
by
5.9k points
4 votes

Answer:

A, B and D

Step-by-step explanation:

Given

Options (a) to (d)

Required

Which outputs

Hello

Hello

Hello

(a) Each print statement prints "Hello" on separate lines.

Since there are three print statements, then (a) is true

(b) The loop iterates 3 times; and each iteration prints "Hello" on separate line,

Hence, (b) is also true

(c) The statement prints "Hello" 3 times, but all are on the same line

Hence, (c) is false

(d) The statement prints "Hello" 3 times; The '\\' ensures that each "Hello" string is printed on separate line.

Hence, (d) is true

User S Singh
by
5.8k points