Question: Language: Python (PyCharm) Hello, I need help with these questions. [2] (val1.py) Consider the parenthesized expression 2 + (3 - 1) * 10/5* (2 +
Language: Python (PyCharm)
Hello, I need help with these questions.
![Language: Python (PyCharm) Hello, I need help with these questions. [2] (val1.py)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f393f1a21b8_15366f393f123aa5.jpg)
[2] (val1.py) Consider the parenthesized expression 2 + (3 - 1) * 10/5* (2 + 3). Write a program which breaks this expression down into a series of assignment statements, each of the form var = el op e2, where var is some variable, where op is one of the arithmetic operators +,-/,* and each of e1 and e2 (expressions) are either (a) an int literal or (b) a variable you assigned a value to in earlier statements. Your final assignment statement should be of the form result = e1 op e2. Note that each of your assignment statements should have only ONE operator and TWO operands on the right- hand side. After this, add the two print statements print(result) and print(2+(3-1)*10/5* (2+3)). Be sure you evaluate the sub-expressions in the correct order when calculating result, so that the output of both is the exactly the same. Note: In this assignment, you must NOT do this for the example expression, but for the expression: 2 + (3 - 1) * 10/5 * (2+3). [3] (val2.py) Do this again for a different expression using different operators - similar to the previous assign- ment item, but for the expression: 1.0+ 2.0 * 5 ** 6** 2%3-6 // 4. Note the use of the two operators ** (exponentiation) and // (integer division). [2] (val1.py) Consider the parenthesized expression 2 + (3 - 1) * 10/5* (2 + 3). Write a program which breaks this expression down into a series of assignment statements, each of the form var = el op e2, where var is some variable, where op is one of the arithmetic operators +,-/,* and each of e1 and e2 (expressions) are either (a) an int literal or (b) a variable you assigned a value to in earlier statements. Your final assignment statement should be of the form result = e1 op e2. Note that each of your assignment statements should have only ONE operator and TWO operands on the right- hand side. After this, add the two print statements print(result) and print(2+(3-1)*10/5* (2+3)). Be sure you evaluate the sub-expressions in the correct order when calculating result, so that the output of both is the exactly the same. Note: In this assignment, you must NOT do this for the example expression, but for the expression: 2 + (3 - 1) * 10/5 * (2+3). [3] (val2.py) Do this again for a different expression using different operators - similar to the previous assign- ment item, but for the expression: 1.0+ 2.0 * 5 ** 6** 2%3-6 // 4. Note the use of the two operators ** (exponentiation) and // (integer division)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
