-
Notifications
You must be signed in to change notification settings - Fork 1
/
030_Fundamentals Return.py
76 lines (49 loc) · 1.21 KB
/
030_Fundamentals Return.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
Codewars Coding Challenge
Fundamentals: Return
Make multiple functions that will return the sum, difference, modulus, product, quotient, and the exponent respectively.
Please use the following function names:
addition = add
multiply = multiply
division = divide (both integer and float divisions are accepted)
modulus = mod
exponential = exponent
subtraction = subt
Note: All math operations will be: a (operation) b
https://www.codewars.com/kata/55a5befdf16499bffb00007b/train/python
"""
# My Solution
def add(a, b):
return a + b
def multiply(a, b):
return a * b
def divide(a, b):
return a / b
def mod(a, b):
return a % b
def exponent(a, b):
return a ** b
def subt(a, b):
return a - b
"""
Sample Test
import codewars_test as test
from solution import *
@test.describe("Fixed Tests")
def fixed_tests():
@test.it('Basic Test Cases')
def basic_test_cases():
test.assert_equals(add(1, 2), 3)
test.assert_equals(multiply(1, 2), 2)
test.assert_equals(divide(2, 1), 2)
test.assert_equals(mod(1, 2), 1)
test.assert_equals(exponent(1, 2), 1)
test.assert_equals(subt(1, 2), -1)
"""
"""
Perfect Solution From Codewars
=1=
=2=
=3=
=4=
"""