From 130f879d04391d191c12f740aed2f12c5dced215 Mon Sep 17 00:00:00 2001 From: Siddharth Srivastava Date: Thu, 12 Sep 2019 17:15:00 +0530 Subject: [PATCH] Uploading file max_min.py --- max_min.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 max_min.py diff --git a/max_min.py b/max_min.py new file mode 100644 index 0000000..322ff5e --- /dev/null +++ b/max_min.py @@ -0,0 +1,21 @@ +def findmax(db): + """Returns the maximum element from a database (dictionary)""" + db2 = [i for i in db.values() if isinstance(i, int) or isinstance(i, float)] + maximum = max(db2) + return maximum + +def findmin(db): + """Returns the minimum element from a database (dictionary)""" + db2 = [i for i in db.values() if isinstance(i, int) or isinstance(i, float)] + minimum = min(db2) + return minimum + +def main(): + db = {'a': 4, 'b': 6.5, 'c': 'der'} + max_value = findmax(db) + print(max_value) + min_value = findmin(db) + print(min_value) + +if __name__ == '__main__': + main()