Answers for "How to find the highest, lowest and average from a set of values using a function in python"

0

How to find the highest, lowest and average from a set of values using a function in python

#define the function
def Performance(marks):
  max = -1
  min = 101
  sum = 0

  for i in range(0, len(marks)):
    if marks[i] > max:
      max = marks[i]
    if marks[i] < min:
      min = marks[i]
    sum = sum + marks[i]

  return max, min, sum/len(marks)

#input marks
marks = [42, 98, 67, 87, 91, 68, 78, 81, 54, 32]

highest, lowest, average= Performance(marks)

print(highest," ",lowest," ",average)
Posted by: Guest on October-30-2021

Code answers related to "How to find the highest, lowest and average from a set of values using a function in python"

Python Answers by Framework

Browse Popular Code Answers by Language