Travis CI: Add pytest --doctest-modules maths (#1020)

* Travis CI: Add pytest --doctest-modules maths

* Update lucas_series.py

* Update lucas_series.py
This commit is contained in:
Christian Clauss 2019-07-21 08:16:28 +02:00 committed by Anup Kumar Panwar
parent b35f5d971b
commit 93fdc9f2a1
5 changed files with 34 additions and 28 deletions

View File

@ -18,10 +18,6 @@ script:
--ignore=machine_learning/perceptron.py --ignore=machine_learning/perceptron.py
--ignore=machine_learning/random_forest_classification/random_forest_classification.py --ignore=machine_learning/random_forest_classification/random_forest_classification.py
--ignore=machine_learning/random_forest_regression/random_forest_regression.py --ignore=machine_learning/random_forest_regression/random_forest_regression.py
--ignore=maths/abs_min.py
--ignore=maths/binary_exponentiation.py
--ignore=maths/lucas_series.py
--ignore=maths/sieve_of_eratosthenes.py
after_success: after_success:
- python scripts/build_directory_md.py - python scripts/build_directory_md.py
- cat DIRECTORY.md - cat DIRECTORY.md

View File

@ -1,10 +1,11 @@
from abs import abs_val from .abs import abs_val
def absMin(x): def absMin(x):
""" """
# >>>absMin([0,5,1,11]) >>> absMin([0,5,1,11])
0 0
# >>absMin([3,-10,-2]) >>> absMin([3,-10,-2])
-2 -2
""" """
j = x[0] j = x[0]
@ -13,9 +14,11 @@ def absMin(x):
j = i j = i
return j return j
def main(): def main():
a = [-3,-1,2,-11] a = [-3,-1,2,-11]
print(absMin(a)) # = -1 print(absMin(a)) # = -1
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -17,11 +17,12 @@ def binary_exponentiation(a, n):
return b * b return b * b
try: if __name__ == "__main__":
BASE = int(input('Enter Base : ')) try:
POWER = int(input("Enter Power : ")) BASE = int(input("Enter Base : ").strip())
except ValueError: POWER = int(input("Enter Power : ").strip())
print("Invalid literal for integer") except ValueError:
print("Invalid literal for integer")
RESULT = binary_exponentiation(BASE, POWER) RESULT = binary_exponentiation(BASE, POWER)
print("{}^({}) : {}".format(BASE, POWER, RESULT)) print("{}^({}) : {}".format(BASE, POWER, RESULT))

View File

@ -1,13 +1,21 @@
# Lucas Sequence Using Recursion # Lucas Sequence Using Recursion
def recur_luc(n): def recur_luc(n):
if n == 1: """
return n >>> recur_luc(1)
if n == 0: 1
return 2 >>> recur_luc(0)
return (recur_luc(n-1) + recur_luc(n-2)) 2
"""
if n == 1:
return n
if n == 0:
return 2
return recur_luc(n - 1) + recur_luc(n - 2)
limit = int(input("How many terms to include in Lucas series:"))
print("Lucas series:") if __name__ == "__main__":
for i in range(limit): limit = int(input("How many terms to include in Lucas series:"))
print(recur_luc(i)) print("Lucas series:")
for i in range(limit):
print(recur_luc(i))

View File

@ -2,9 +2,6 @@
import math import math
N = int(input("Enter n: "))
def sieve(n): def sieve(n):
"""Sieve of Eratosthones.""" """Sieve of Eratosthones."""
l = [True] * (n + 1) l = [True] * (n + 1)
@ -26,4 +23,5 @@ def sieve(n):
return prime return prime
print(sieve(N)) if __name__ == "__main__":
print(sieve(int(input("Enter n: ").strip())))