Which of the following is a valid string in Python?
a) “Hello, World!”
b) 12345
c) True
d) [1, 2, 3]
Answer:
a) “Hello, World!”
Explanation:
The string "Hello, World!"
is a valid string in Python because it is a sequence of characters enclosed in double quotes. Strings in Python can be enclosed in either single or double quotes.
greeting = "Hello, World!"
print(greeting) # Prints "Hello, World!"
Strings are used to store and manipulate text data. They are immutable, meaning once a string is created, it cannot be changed, but you can create new strings from existing ones using various string methods.