Computer Science, asked by designerjahanvyas, 4 months ago

Which of the following functions will return the always a Tuple of 3 elements?

(a) Find ( ) (b) Index ( )

(c) Partition ( ) (d) Split ( )

Answers

Answered by singhvaishnavi7002
2
B)Index

Hope it will help you
Answered by dreamrob
3

Option c : partition() function always return a tuple of 3 elements.

More about functions :

a) find() : The find() function returns the index of the first occurrence of the substring is found. If not found,  then it returns -1.

Example :

str = "I love car."

index = str.find('love')

print("Substring 'love' : ", index)

b) index() : The index() function returns the index of the given element in the list.

Example :

L = [10 , 12 , 23 , 34 , 45]

index = L.index(12)

print("Index of 12 is ",index)

c) partition() : The partition() function splits the string at the first occurrence of the given string and always return a tuple containing three parts :

  1. String before separator
  2. Given string
  3. String after separator.

str = "I live in Lucknow."

print(str.partition('in')

d) split() : The split() function returns a list of the words in the string/line, separated by a delimiter string.

Example :

str = "I love to play football."

print(str.split(" ",3))

Similar questions