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

निम्नलिखित कोड का आउटपुट क्या होगा?

What will be the output of the following code?


word = "Snow world"
print(word[4:7])
A
w
B
snow
C
wo
D
worl
Explanation

Python में slicing का syntax होता है:

 
string[start : end]
  • Start index शामिल होता है (inclusive)

  • End index शामिल नहीं होता (exclusive)
    String: "Snow world"
    Indexes:

     

    Index Character
    0 S
    1 n
    2 o
    3 w
    4 ␣ (space)
    5 w
    6 o
    7 r
    8 l
    9 d

    word[4:7] का मतलब है:

    • Index 4 → ' ' (space)

    • Index 5 → 'w'

    • Index 6 → 'o'

    • Index 7 → excluded

    ➡ इसलिए Output: ' wo' (space + 'w' + 'o')

     

Correct Answer: C) wo

Latest Updates