Which of these lines of code will print “BBBBB” assuming the program begins with this line of code:

letter = "B"

(1 point)
Responses

print(letter)
print(letter)

print5("letter")
print5("letter")

print(letter * 5)
print(letter * 5)

print("letter" * 5

1 answer

To print "BBBBB" given that the variable letter is assigned the value "B", the correct line of code would be:

print(letter * 5)

This line of code takes the value of letter, which is "B", and repeats it 5 times, resulting in "BBBBB".

The other options do not correctly print "BBBBB":

  • print(letter) will print "B".
  • print5("letter") is not valid syntax because there is no function print5.
  • print("letter" * 5) will print "letterletterletterletterletter", as it repeats the string "letter" instead of the value of the variable letter.

So, the correct answer is:

print(letter * 5)