Open In App

Python-Quizzes | Python String Quiz | Question 11

Like Article
Like
Save
Share
Report

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


Last Updated : 18 Sep, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads