37.5k views
5 votes
Look at the following Python code: word1 = ball word2 = park .Which of the following shows the concatenation of the two strings?

a) word3 (ballpark)
b) word3 (ball + park)
c) word3 (word1 + word2)
d) word3 (word1 + word2)

User Tarlog
by
9.1k points

1 Answer

4 votes

Final answer:

The correct answer to the question on how to concatenate two strings in Python when word1 is 'ball' and word2 is 'park' is c) word3 = word1 + word2, resulting in 'ballpark'.

Step-by-step explanation:

The question is about concatenating two strings in Python. When you have variables word1 equal to 'ball' and word2 equal to 'park', you can concatenate these strings by using the plus (+) operator. Therefore, the correct answer is c) word3 = word1 + word2. This expression combines the two strings word1 and word2 into word3 without any space between them, resulting in word3 being 'ballpark'.

User Thomas Kirchhoff
by
7.2k points