Identify and execute the respective operations in the following expression using regular expression and functions:
(5+3)*(8+4)
This means you have to first execute the addition operation by implementing the addition function first then execute the multiplication operation
Input: (5+3)*(8+4)
implement the following operations using python: addition, subtraction, multiplication, and division
segregate the patterns begins and ends with parenthesis together with the operations between them: (5+3), *,(8+4)
identify the operations inside each parenthesis and extract the operands: 5,3,+and 8,4,+
call the appropriate function along with the respective arguments: add(5,3), add(8,4) and then call multiplication(8,12)
#Adding the first parenthesis using input function
num1=int(input("Enter the first number: "))
num2=int(input("Enter the second number: "))
sum1= num1+num2
#Adding the second parenthesis using input function
num3=int(input("Enter the third number: "))
num4=int(input("Enter the fourth number: "))
sum2 = num3+num4
#Multipluying the sum of both parentheses
mul = sum1*sum2
print("The sum of both parenthesis is: ", "(", sum1,",", sum2, ")")
print ("The result of multiplication of both parenthesis is: ", mul)
Comments
Leave a comment