Welcome to kaju bakery,
Kaju bakery deals with large number of orders of cake. So to handle the cake demand we need a function that takes in the number of servings of cake required and price of cake in dollar and returns the total price for that cake.
We also impose tax of 1$ so keep that in mind too
Have the function named deliver and return the total price customer has to pay in the counter.
also check if the number of servings <= 0 then just return zero.
def price(servings, price): if servings >0: cost = servings * price cost += 1 return cost else: return 0
def multiply_and_add_one(a, b):c = a * bc += 1return c- def price(servings, price):
- if servings >0:
- cost = servings * price
- cost += 1
- return cost
- else:
- return 0
import codewars_test as test from solution import price @test.describe("Kaju bakery") def _(): @test.it("Basic tests") def test_case(): test.assert_equals(price(2, 3), 7) test.assert_equals(price(4, 5), 21) test.assert_equals(price(0, 10), 0) test.assert_equals(price(-1, 5), 0)
- import codewars_test as test
from solution import multiply_and_add_one- from solution import price
@test.describe("Multiply and Add One Tests")- @test.describe("Kaju bakery")
- def _():
- @test.it("Basic tests")
- def test_case():
test.assert_equals(multiply_and_add_one(2, 3), 7)test.assert_equals(multiply_and_add_one(4, 5), 21)test.assert_equals(multiply_and_add_one(0, 10), 1)test.assert_equals(multiply_and_add_one(-1, 5), -4)- test.assert_equals(price(2, 3), 7)
- test.assert_equals(price(4, 5), 21)
- test.assert_equals(price(0, 10), 0)
- test.assert_equals(price(-1, 5), 0)