Add only one pair of parenthesis to the following expression so that it produces 0 as the output.     4**2+12%7+4*2-18     You must not add or delete any other operators and/or operands. You must write your answer without any extra spaces between the symbols.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Add only one pair of parenthesis to the following expression so that it produces 0 as the output.
 
 
4**2+12%7+4*2-18
 
 
You must not add or delete any other operators and/or operands. You must write your answer without any extra spaces between the symbols.
Expert Solution
Step 1

This question is related to the python programming language since the double-asterisk (star) (**)operator is the python's exponential or power operator for computing the mathematical powers of a number raised to a value of a number.

 

The concept used in this expression value evaluation is the precedence and associativity rules of math operators.

 

In python, the parenthesis "()" operator has maximum precedence among all operators, and hence it will be computed first of all.

 

Then, comes the power (**) operator, so it is computed after "()".

 

Then comes multiplication "*", division "/" and mod "%" operators which are put at the same level of precedence but are computed from the left direction to the right in the expression due to the associativity concept.

 

Now, in last the add (+) and subtraction (-) operators are also put in the same precedence level but they are computed from the left direction to the right in the expression due to the associativity concept.

 

By using this concept the answer to this question can be obtained.

 

 

steps

Step by step

Solved in 4 steps

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education