
Problem
Solution
Submissions
Implement a Simple Calculator Using Functions
Certification: Intermediate Level
Accuracy: 75%
Submissions: 4
Points: 15
Write a Python program that implements a simple calculator with functions for addition, subtraction, multiplication, and division. The program should take two numbers and an operator as input and return the result.
Example 1
- Input: 10, 5, "+"
- Output: 15
Example 2
- Input: 10, 5, "*"
- Output: 50
Constraints
- Supported operators: "+", "-", "*", "/"
- -10^9 ≤ operands ≤ 10^9
- Handle division by zero
- Time Complexity: O(1)
- Space Complexity: O(1)
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Create separate functions for each operation
- Use a dictionary to map operators to functions
- Handle edge cases like division by zero
- Validate input type and operation