Menu
Coddy logo textTech

More operators

Lesson 4 of 29 in Coddy's Calculator project using Python course.

We've added the basics operators: +, -, *, /

Let's add some more!

challenge icon

Challenge

Easy

Add support for the operators -

  • % - modulo operator
  • ^ - power operator, 2^3 equal to 23

Try it yourself

def calc(op, n1, n2):
    if op == '+':
        return n1 + n2
    if op == '-':
        return n1 - n2
    if op == '*':
        return n1 * n2
    if op == '/':
        return n1 / n2

All lessons in Calculator project using Python