Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called find_second_largest() that takes as input a list of numbers called myList . The function should find the second largest number in

Write a function called find_second_largest() that takes as input a list of numbers called myList. The function should find the second largest number in the list and return it. If the list is empty or only have a single number in it the function should return 0.

Do not call the function, it will be called by the test program.

Test

Result

thelist = [3,1,5,7,9,4]
print(find_second_largest(thelist))
print(*thelist, sep = ' ')
7
3 1 5 7 9 4
thelist = []
print(find_second_largest(thelist))
print(*thelist, sep = ' ')
0
thelist = [3]
print(find_second_largest(thelist))
print(*thelist, sep = ' ')
0
3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

9. Articulate the manager's role in the group process.

Answered: 1 week ago