Question

Problem 5 Given a list a, the max function in Pythons standard library computes the largest element in a: max(a) . Similarly

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE IN PYTHON:

def my_max(a):
    if a:
        max = a[0]
        for val in a:
            if val > max :
                max = val
        return max
    print("List is empty")


def my_min(a):
    if a:
        min = a[0]
        for val in a:
            if val < min :
                min = val
        return min
    print("List is empty")

a = [0.28197719, 0.59580708, 0.54095388, 0.44264927, 0.12360858, 0.3067179, 0.33002426, 0.43553806, 0.14259775, 0.01909447]
print(my_max(a))
print(my_min(a))

INDENTATION:

def my_max(a): if a: max = a[@] for val in a: if val > max : max = val return max print(List is empty) def my_min(a): if a:

OUTPUT:

maxMin C:\Users\madhuvenv\Python3.8\Scripts\python.exe D: /PythonWorld/HelloWorld/maxMin.py 0.59580708 0.01909447 Process fin

Add a comment
Know the answer?
Add Answer to:
Problem 5 Given a list a, the max function in Python's standard library computes the largest...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT