निम्नलिखित प्रोग्राम का आउटपुट क्या है?
What is the output of the following program ?
print "Hello World"[::-1]
A
dlroWolleH
B
Hello Worl
C
d
D
Error
Explanation
The given Python code is:
print "Hello World"[::-1]
Explanation:
"Hello World"is a string.[::-1]is a slicing operation that reverses the string.- The slice notation
[::-1]means "take the string and step backwards by 1, effectively reversing it."
- The slice notation
So, reversing "Hello World" gives: "dlroW olleH"
Output:
(A) dlroWolleH
Note: In Python 3, print requires parentheses, so the correct code would be print("Hello World"[::-1]). However, based on the given code, it seems to be Python 2, where print doesn't need parentheses.
[::-1] स्लाइसिंग ऑपरेटर है जो स्ट्रिंग को पूरी तरह से उलट (Reverse) देता है
Correct Answer: A) dlroWolleH