Mini Calculator
A calculator is a simple and useful way to practice conditions and choosing an action from a string. Write a function basic_op that takes an operator operation and two numbers a and b. Return the result of the requested operation: addition, subtraction, multiplication, or integer division.
Примеры
Ввод
"+", 4, 7Вывод
11Ввод
"-", 15, 18Вывод
-3Ввод
"*", 5, 5Вывод
25Нужно реализовать
def basic_op(operation: str, a: int, b: int) -> int:
Теги
mathstrings
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible tests
1
Input
"+", 4, 7Expected
112
Input
"-", 15, 18Expected
-33
Input
"*", 5, 5Expected
254
Input
"/", 49, 7Expected
75
Input
"+", 0, 0Expected
06
Input
"-", 15, 9Expected
6Focus radio
Paused · SomaFM · Fluid