Coverage for src/calc.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.2.1, created at 2024-07-26 12:59 +0300

1""" 

2 

3calculation module 

4 

5""" 

6 

7 

8def add(number_one: (str, int, float), number_two: (str, int, float)) -> (int, float): 

9 """ 

10 Add two numbers 

11 :param number_one: number one 

12 :type number_one: int or float 

13 :param number_two: number two 

14 :type number_two: int or float 

15 :return: sum of two numbers 

16 :rtype: int or float 

17 """ 

18 try: 

19 return number_one + number_two 

20 except TypeError: 

21 return float(number_one) + float(number_two) 

22 

23 

24def sub(number_one: (str, int, float), number_two: (str, int, float)) -> (int, float): 

25 """ 

26 Subtract two numbers 

27 :param number_one: number one 

28 :type number_one: int or float 

29 :param number_two: number two 

30 :type number_two: int or float 

31 :return: difference of two numbers 

32 :rtype: int or float 

33 """ 

34 try: 

35 return number_one - number_two 

36 except TypeError: 

37 return float(number_one) - float(number_two)