Computer Science, asked by animesharma2405, 6 months ago

Here is a function to compute the third smallest value in a list of distinct integers. All the integers are guaranteed to be below 1000000. You have to fill in the missing lines. You can assume that there are at least three numbers in the list.

def thirdmin(l):
(mymin,mysecondmin,mythirdmin) = (1000000,1000000,1000000)
for i in range(len(l)):
# Your code below this line


# Your code above this line
return(mythirdmin)

Answers

Answered by mahajan789
0

def thirdmin(l):

(mymin,mysecondmin,mythirdmin) = (1000000,1000000,1000000)

for i in range(len(l)):

# Your code below this line

l.sort()

   mythirdmin=l[2]

   break

# Your code above this line

return(mythirdmin)

#SP3

Answered by brainlysme13
0

The missing code is:

def thirdmin(l):

(mymin,mysecondmin,mythirdmin) = (1000000,1000000,1000000)

for i in range(len(l)):

# Your code below this line

{

   sort()

   mythirdmin = l[2]

   break

}

# Your code above this line

return(mythirdmin)

This code will return the third smallest number.

We have sorted the list in ascending order, and since the index of elements starts from 0, the element at index 2 will be the third smallest element in the list.

#SPJ3

Similar questions