MinMaxAvg

The story

Algorithms are one of the most important things for programmers - they are the foundations on which we build our programs. No matter which language you (will) use, the algorithms are always involved.

So, no more talking, let’s practice some of them - calculating minimum, maximum and average from numbers in a list.

PLEASE DO NOT USE BUILT-IN PYTHON FUNCTIONS TO CALCULATE MIN, MAX, AND AVG! Those forbidden functions are: min(), max(), sum(), sort(), sorted() etc.

The exercise

  1. Let’s assume we’ve got a list: numbers = [-5, 23, 0, -9, 12, 99, 105, -43]

  2. Please create three flowcharts for calculating the maximum, minimum and average number for above list (you can use draw.io ).

  3. After this, please create a python script that will implement above flowcharts.

  4. (optional) Now, the list looks a bit different: numbers = [-5, 23, 0, "dupa", -9, 12, 99, [2, 44], None, 105, -43]. Update your python script to maintain it’s previous functionality - ignore non-numbers and search for numbers inside nested list!

Please submit your Python script.