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

Commit c7b3804

Browse files
committed
09-Max_integer_from_list
1 parent 5a439a0 commit c7b3804

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
my_list = [43,23,6,87,43,1,4,6,3,67,8,3445,3,7,5435,63,346,3,456,734,6,34]
2+
3+
#Your code go from here:
4+
def maxInteger(arr):
5+
maxInt=0
6+
for i in range(len(arr)):
7+
if arr[i] > maxInt:
8+
maxInt = arr[i]
9+
return maxInt
10+
11+
print(maxInteger(my_list))

‎exercises/09-Max_integer_from_list/test.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import io, sys, os, pytest, re
22
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
33

4+
@pytest.mark.it('The function maxInteger must exist')
5+
def test_function_existence(capsys, app):
6+
assert app.maxInteger
47

5-
@pytest.mark.it("Max integer from the list")
8+
@pytest.mark.it("The function should return the maximun number from a list")
69
def test_output(capsys, app):
7-
app()
8-
captured = capsys.readouterr()
9-
assert "5435\n" in captured.out
10+
result = app.maxInteger([43,23,6,87,43,1,4,6,3,67,8,3445,3,7,5435,63,346,3,456,734,6,34])
11+
assert result == 5435
12+
13+
@pytest.mark.it("The function should work with other lists")
14+
def test_output_2(capsys, app):
15+
result = app.maxInteger([43,23,6,8733,43,1,4,6,3,67,8,99999,3,7,5435,63])
16+
assert result == 99999
1017

1118
@pytest.mark.it("Use the for loop")
1219
def test_for_loop():

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /