Answer to Question #282688 in Python for ramk

Question #282688

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)


1
Expert's answer
2021-12-27T08:39:37-0500
#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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS