hamburger menu
All Coursesall course arrow
adda247
reward-icon
adda247
    arrow
    arrow
    arrow
    Identify the output of the following Python program segment: S = 'Python Programming' L = S.split() S = ':'.join(L) print(S)
    Question

    Identify the output of the following Python program segment:
    S = 'Python Programming'
    L = S.split()
    S = ':'.join(L)
    print(S)

    A.

    Python Programming

    B.

    Python: Programming

    C.

    :Python Programming

    D.

    :Python, Programming

    Correct option is B

    The split() method divides the string S into a list of words, using the default whitespace delimiter. After splitting, the list L contains ['Python', 'Programming']. The join() method is then used with ':' as the separator, combining the list elements with a colon. Therefore, the result is the string 'Python:Programming'.
    Important Key Points:
    1. split(): The split() method splits the string into a list of words using spaces as the default delimiter.
    2. join(): The join() method takes all items in an iterable (like the list L) and joins them into a single string, with the specified separator (in this case, ':').
    3. Final Output: The elements 'Python' and 'Programming' are joined with a colon, resulting in 'Python:Programming'.

    test-prime-package

    Access ‘KVS PGT’ Mock Tests with

    • 60000+ Mocks and Previous Year Papers
    • Unlimited Re-Attempts
    • Personalised Report Card
    • 500% Refund on Final Selection
    • Largest Community
    students-icon
    194k+ students have already unlocked exclusive benefits with Test Prime!

    Free Tests

    Free
    Must Attempt

    DSSSB TGT COMPUTER SCIENCE PYP (01 August 2021 Shift-2)

    languageIcon English
    • pdpQsnIcon200 Questions
    • pdpsheetsIcon200 Marks
    • timerIcon120 Mins
    languageIcon English
    Free
    Must Attempt

    English Subject Test 1

    languageIcon English
    • pdpQsnIcon20 Questions
    • pdpsheetsIcon20 Marks
    • timerIcon20 Mins
    languageIcon English
    Free
    Must Attempt

    Indian Geography Chapter Test

    languageIcon English
    • pdpQsnIcon10 Questions
    • pdpsheetsIcon10 Marks
    • timerIcon10 Mins
    languageIcon English