Question: Write a python function perform _ arithmetic _ operation to perform basic arithmetic operations on two numbers. The function takes 3 inputs: num 1 ,

Write a python function perform_arithmetic_operation to perform basic arithmetic operations on two numbers. The function takes 3 inputs: num1, num2, and symbol in which symbol denotes the particular arithmetic operation to be performed on the numbers num1 and num2. The function should then calculate and return the result.
The arithmetic operations and their corresponding symbols are:
Arithmetic operation symbol
Addition (i.e num1+ num2)'+'
Subtraction (i.e num1- num2)'-'
Multiplication (i.e num1* num2)'*'
Division (i.e num1/num2)'/'
Note that the function should handle division by zero and invalid input (which corresponds to symbol being anything other than the four symbols listed above) gracefully by returning -1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!