🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

इस Python कोड का आउटपुट क्या होगा?

What will be the output of this Python code?


str="Hello python"
print(str[-7:-4:1])

A
py
B
o p
C
tho
D
Hel
Explanation
  • The string is: "Hello python"

  • Negative index -7 refers to character 'o'
    (full string index: H(0) e(1) l(2) l(3) o(4) (5) p(6) y(7) t(8) h(9) o(10) n(11))

  • str[-7:-4:1] means: start from index -7 to index -4 (excluding -4), step 1

  • So it picks: 'o' (index -7), ' ' (index -6), 'p' (index -5)

  • Output: 'o p'


2. हिंदी में:

  • स्ट्रिंग है: "Hello python"

  • -7 index है 'o' (जो "Hello " के बाद आता है)

  • -4 index है 'y', लेकिन slicing में आखिरी index शामिल नहीं होता

  • तो characters मिलेंगे: 'o', ' ', 'p'

  • Output होगा: 'o p'


Final Output: o p

Correct Answer: B) o p

Latest Updates