Skip to content

Commit 6696381

Browse files
committed
added find max value algorithm
1 parent 334a054 commit 6696381

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

allalgorithms/numeric/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .max_numbers import find_max

allalgorithms/numeric/max_numbers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: UTF-8 -*-
2+
#
3+
# Numeric Algorithms
4+
# The All ▲lgorithms library for python
5+
#
6+
# Contributed by: Becky
7+
# Github: @beckyw5
8+
#
9+
10+
11+
def find_max (L):
12+
max = 0
13+
for x in L:
14+
if x > max:
15+
max = x
16+
return max

tests/test_numeric.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import unittest
2+
3+
from allalgorithms.numeric import find_max
4+
5+
6+
class TestMax(unittest.TestCase):
7+
8+
def test_find_max_value(self):
9+
test_list = [3, 1, 8, 7, 4]
10+
self.assertEqual(8, find_max(test_list))
11+
12+
if __name__ == "__main__":
13+
unittest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy