Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6696381

Browse files
committed
added find max value algorithm
1 parent334a054 commit6696381

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_numbersimportfind_max
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+
deffind_max (L):
12+
max=0
13+
forxinL:
14+
ifx>max:
15+
max=x
16+
returnmax

‎tests/test_numeric.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
importunittest
2+
3+
fromallalgorithms.numericimportfind_max
4+
5+
6+
classTestMax(unittest.TestCase):
7+
8+
deftest_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)

[8]ページ先頭

©2009-2025 Movatter.jp