Travis CI: Add pytest --doctest-modules maths (#1020) · SandersLin/Python@93fdc9f · GitHub
Skip to content

Commit 93fdc9f

Browse files
cclaussAnupKumarPanwar
authored andcommitted
Travis CI: Add pytest --doctest-modules maths (TheAlgorithms#1020)
* Travis CI: Add pytest --doctest-modules maths * Update lucas_series.py * Update lucas_series.py
1 parent b35f5d9 commit 93fdc9f

5 files changed

Lines changed: 35 additions & 29 deletions

File tree

.travis.yml

Lines changed: 0 additions & 4 deletions

maths/abs_min.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
from abs import abs_val
1+
from .abs import abs_val
2+
23

34
def absMin(x):
45
"""
5-
# >>>absMin([0,5,1,11])
6+
>>> absMin([0,5,1,11])
67
0
7-
# >>absMin([3,-10,-2])
8+
>>> absMin([3,-10,-2])
89
-2
910
"""
1011
j = x[0]
@@ -13,9 +14,11 @@ def absMin(x):
1314
j = i
1415
return j
1516

17+
1618
def main():
1719
a = [-3,-1,2,-11]
1820
print(absMin(a)) # = -1
1921

22+
2023
if __name__ == '__main__':
2124
main()

maths/binary_exponentiation.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ def binary_exponentiation(a, n):
1717
return b * b
1818

1919

20-
try:
21-
BASE = int(input('Enter Base : '))
22-
POWER = int(input("Enter Power : "))
23-
except ValueError:
24-
print("Invalid literal for integer")
25-
26-
RESULT = binary_exponentiation(BASE, POWER)
27-
print("{}^({}) : {}".format(BASE, POWER, RESULT))
20+
if __name__ == "__main__":
21+
try:
22+
BASE = int(input("Enter Base : ").strip())
23+
POWER = int(input("Enter Power : ").strip())
24+
except ValueError:
25+
print("Invalid literal for integer")
26+
27+
RESULT = binary_exponentiation(BASE, POWER)
28+
print("{}^({}) : {}".format(BASE, POWER, RESULT))

maths/lucas_series.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# Lucas Sequence Using Recursion
22

33
def recur_luc(n):
4-
if n == 1:
5-
return n
6-
if n == 0:
7-
return 2
8-
return (recur_luc(n-1) + recur_luc(n-2))
9-
10-
limit = int(input("How many terms to include in Lucas series:"))
11-
print("Lucas series:")
12-
for i in range(limit):
13-
print(recur_luc(i))
4+
"""
5+
>>> recur_luc(1)
6+
1
7+
>>> recur_luc(0)
8+
2
9+
"""
10+
if n == 1:
11+
return n
12+
if n == 0:
13+
return 2
14+
return recur_luc(n - 1) + recur_luc(n - 2)
15+
16+
17+
if __name__ == "__main__":
18+
limit = int(input("How many terms to include in Lucas series:"))
19+
print("Lucas series:")
20+
for i in range(limit):
21+
print(recur_luc(i))

maths/sieve_of_eratosthenes.py

Lines changed: 2 additions & 4 deletions

0 commit comments

Comments
 (0)