Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Python-Quizzes | Python String Quiz | Question 11

  • Last Updated : 18 Sep, 2020

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

var1 = 'Hello Geeks!'    
var2 = "GeeksforGeeks"
print ( var1[0], var2[1:5])

(A) H eeks
(B) H eek
(C) H eeksf
(D) H Geeks

Answer: (A)

Explanation: Strings are among the most popular types in Python. We can create a string by enclosing characters within quotes. Python treats single quotes the same as double-quotes. It is notable that unlike C or C++ python does not support a character type; in fact, single characters are treated as strings of length one, thus also considered a substring. To access substrings, use the square brackets for slicing along with the index or indices to obtain your substring.

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 :