Now the function returns test instead of giving an 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(): for x in range(1000): test.assert_equals(return_test(), 'test')
- 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)- for x in range(1000):
- test.assert_equals(return_test(), 'test')
I added a bit more to it. I'm not sure, is it unethical to fork my own code? Also I feel like there isn't much point in this after I added "age % 1" to the original one. Feel free to remove that and think of something more creative if you are forking it.
def takeYourAge(age): import math age *= 3 age %= 1.233 age **= 100 age *= 1000000 age // 0.2 age ** 1 ** 8 age %= 1 age = math.floor(age) age += 21 return age
- def takeYourAge(age):
- import math
- age *= 3
- age %= 1.233
- age **= 100
- age *= 1000000
- age // 0.2
- age ** 1 ** 8
- age %= 1
- age = math.floor(age)
- age += 21
- return age
I added a few other things to say hello to.
This kumite is similar to one of those things where you take your age and do a lot of things to it. I wanted to see how many steps we can get and then return an answer of 21. Use as many functions as you can.
def takeYourAge(age):
import math
age *= 3
age %= 1.233
age **= 100
age *= 1000000
age %= 1
age = math.floor(age)
age += 21
return age
import random
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 random_cases():
for x in range(100):
test.assert_equals(takeYourAge(random.randint(0,100)), 21)
I fixed the typo in the title, and also added a pass to the preloaded code to prevent errors.
import codewars_test as test import random # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Random test cases") def random_tests(): @test.it("Random test") def test_case(): for x in range(100): randomValue = random.randint(-1000, 1000) test.assert_equals(is_more_than_2(randomValue), randomValue > 2)
I added 100 test cases, and put in the preloded code.
import codewars_test as test import random # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Random test cases") def random_tests(): @test.it("Random test") def test_case(): for x in range(100): randomValue = random.randint(-1000, 1000) test.assert_equals(is_more_then_2(randomValue), randomValue > 2)
- import codewars_test as test
- import random
- # 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")- @test.describe("Random test cases")
- def random_tests():
- @test.it("Random test")
- def test_case():
test.assert_equals(1 + 1, 2)- for x in range(100):
- randomValue = random.randint(-1000, 1000)
- test.assert_equals(is_more_then_2(randomValue), randomValue > 2)
Added Testcases, and also made it so that it knew that 9+10=21 like from the meme.
def testFunction(n): if n == 9 + 10: return 21 #haha funny number return eval(str(n))
def test(n):return eval(n)- def testFunction(n):
- if n == 9 + 10:
- return 21 #haha funny number
- return eval(str(n))
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("FixedCases") def fixedCases(): @test.it("One plus one") def testCase(): test.assert_equals(testFunction(1+1), 2) @test.it("nine plus ten") def testCase(): test.assert_equals(testFunction(9+10), 21)
- 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.describe("FixedCases")
- def fixedCases():
- @test.it("One plus one")
- def testCase():
- test.assert_equals(testFunction(1+1), 2)
- @test.it("nine plus ten")
- def testCase():
- test.assert_equals(testFunction(9+10), 21)
I changed the program so it does the modulation with a while loop.
import random import time def not_even(n): pizza_time = time.ctime() while n > 1: n -= 2 if n == 0: return 'its not even', pizza_time else: return 'its still not even', pizza_time return pizza_time n = random.randint(0, 10000) print(not_even(n))
- import random
- import time
- def not_even(n):
- pizza_time = time.ctime()
if n % 2 == 0:- while n > 1:
- n -= 2
- if n == 0:
- return 'its not even', pizza_time
- else:
- return 'its still not even', pizza_time
- return pizza_time
- n = random.randint(0, 10000)
- print(not_even(n))
# TODO Write tests import solution # or from solution import example import time # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): if time.ctime() == time.ctime(): test.assert_equals('its not even', 'its not even') or test.assert_equals('its still even', 'its still even')
- # TODO Write tests
- import solution # or from solution import example
- import time
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- if time.ctime() == time.ctime():
- test.assert_equals('its not even', 'its not even') or test.assert_equals('its still even', 'its still even')
Creates a fixed test for the denominator being zero, and makes it so that when it is zero None is returned.
def division(a, b): if b == 0: return None return a / b
- def division(a, b):
- if b == 0:
- return None
- return a / b
import codewars_test as test import random # Random test cases @test.describe("Fixed tests") def fixed_tests(): test.assert_equals(division(random.randint(-1000,1000), 0), None) @test.describe("Random tests") def random_tests(): @test.it("Random tests") def random_test_cases(): for _ in range(100): a = random.randint(-1000, 1000) b = random.randint(-1000, 1000) expected = a / b test.assert_equals(division(a,b), expected)
- import codewars_test as test
- import random
- # Random test cases
- @test.describe("Fixed tests")
- def fixed_tests():
- test.assert_equals(division(random.randint(-1000,1000), 0), None)
- @test.describe("Random tests")
- def random_tests():
- @test.it("Random tests")
- def random_test_cases():
- for _ in range(100):
- a = random.randint(-1000, 1000)
- b = random.randint(-1000, 1000)
- expected = a / b
- test.assert_equals(division(a,b), expected)
I fixed the error in the test cases, and I added 99 more test cases that all are the same thing.
import codewars_test as test # TODO Write tests import solution # or from solution import example print("hi") # 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(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2) test.assert_equals(1 + 1, 2)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- print("hi")
- # 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(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)
- test.assert_equals(1 + 1, 2)