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'.

Free Tests

Free
Must Attempt

DSSSB TGT Social Science 2024 Mock 01

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

Reasoning Ability : Subject Test - 01

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

UP LT Grade - Social Science PYP Held on 24 June 2018

languageIcon English
  • pdpQsnIcon270 Questions
  • pdpsheetsIcon300 Marks
  • timerIcon120 Mins
languageIcon English
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
253k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow