Skip to content
Related Articles

Related Articles

Improve Article

Python-Quizzes | Python String Quiz | Question 12

  • Last Updated : 18 Sep, 2020

Question 12: What is the output of the following program?

var1 = 'Geeks'
print(var1[:4] + 'for' + 'Geeks'

(A) GeeksforGeeks
(B) GeekforGeek
(C) GeekforGeeks
(D) GeekForGeeks

Answer: (C)

Explanation: Python provides a flexible way to update string in your code. Use square brackets and specify the index from where string has to be updated and use + operator to append the string. [x:y] operator is called Range Slice and gives the characters from the given range.

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Recommended Articles
Page :