def calculator(a,b,c): if b=='+': return a+c elif b=='-': return a-c elif b=='*': return a*c elif b=='/': if c==0: raise ZeroDivisionError("Cannot divide by zero!") else: return a/c else: print('error')
- def calculator(a,b,c):
- if b=='+':
print(a+c)- return a+c
- elif b=='-':
print(a-c)- return a-c
- elif b=='*':
print(a*c)- return a*c
- elif b=='/':
print(a/c)- if c==0:
- raise ZeroDivisionError("Cannot divide by zero!")
- else:
- return a/c
- else:
print('error')calculator(3,'s',7)- print('error')
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(calculator(1, '+', 1), 2)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(1 + 1, 2)- test.assert_equals(calculator(1, '+', 1), 2)
def exp(): print("\a", "\a", "\a", "\a", chr(10000), chr(10001), chr(10002), chr(10003), chr(10004), chr(10005), sep="\n")
- def exp():
print("\a")print("\a")print("\a")print("\a")print(chr(10000))print(chr(10001))print(chr(10002))print(chr(10003))print(chr(10004))print(chr(10005))- print("\a", "\a", "\a", "\a", chr(10000), chr(10001), chr(10002), chr(10003), chr(10004), chr(10005), sep="\n")