File tree 3 files changed +21
-16
lines changed
3 files changed +21
-16
lines changed Original file line number Diff line number Diff line change 1
1
def absVal (num ):
2
2
"""
3
3
Function to fins absolute value of numbers.
4
- >>> absVal(-5)
4
+ >>absVal(-5)
5
5
5
6
- >>> absVal(0)
6
+ >>absVal(0)
7
7
0
8
8
"""
9
9
if num < 0 :
Original file line number Diff line number Diff line change 1
- from abs import absVal
1
+ from Maths .abs import absVal
2
+
2
3
def absMax (x ):
3
4
"""
4
- >>>absMax([0,5,1,11])
5
+ # >>>absMax([0,5,1,11])
5
6
11
6
7
>>absMax([3,-10,-2])
7
8
-10
8
9
"""
9
- j = x [0 ]
10
+ j = x [0 ]
10
11
for i in x :
11
- if absVal (i ) < j :
12
+ if absVal (i ) > absVal ( j ) :
12
13
j = i
13
14
return j
14
15
#BUG: i is apparently a list, TypeError: '<' not supported between instances of 'list' and 'int' in absVal
15
-
16
+ #BUG fix
16
17
17
18
def main ():
18
- a = [1 , 2 , - 11 ]
19
- print (absVal (a )) # = -11
19
+ a = [- 13 , 2 , - 11 , - 12 ]
20
+ print (absMax (a )) # = -13
20
21
21
22
if __name__ == '__main__' :
22
23
main ()
24
+
25
+ """
26
+ print abs Max
27
+ """
Original file line number Diff line number Diff line change 1
- from abs import absVal
1
+ from Maths . abs import absVal
2
2
def absMin (x ):
3
3
"""
4
- >>>absMin([0,5,1,11])
4
+ # >>>absMin([0,5,1,11])
5
5
0
6
- >>absMin([3,-10,-2])
6
+ # >>absMin([3,-10,-2])
7
7
-2
8
8
"""
9
- j = absVal ( x [0 ])
9
+ j = x [0 ]
10
10
for i in x :
11
- if absVal (i ) < j :
11
+ if absVal (i ) < absVal ( j ) :
12
12
j = i
13
13
return j
14
14
15
15
def main ():
16
- a = [1 ,2 ,- 11 ]
17
- print (absMin (a )) # = 1
16
+ a = [- 3 , - 1 ,2 ,- 11 ]
17
+ print (absMin (a )) # = - 1
18
18
19
19
if __name__ == '__main__' :
20
20
main ()
You can’t perform that action at this time.
0 commit comments