Menu
Coddy logo textTech

The basics

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

Let's start with the calculation!

challenge icon

Challenge

Easy

Create function calc which gets operator and two numbers and returns the calculation result.

 

Examples:

calc('+', 1, 3)  ->  4

calc('*', 2, 3)  ->  6

calc('/', 1, 4) - >  0.25

calc('-', 1, 3)  ->  -2

 

for now deal only with the basic operators - +, -, *, / 

The return value can be float and not only int!

Try it yourself

All lessons in Calculator project using Python