Skip to main content

Section 1.15 Evaluate Expressions-WE5-P2

Subgoals for evaluating an assignment statement.

  1. Decide order of operations
    1. Decompose as necessary
  2. Determine operator behavior based on operands
    1. Operator and operands must be compatible
  3. Solve arithmetic, expression, or operation
    1. Decompose as necessary

Subsection 1.15.1

For the assignment statements below, either give the new value of the assigned variable, or enter “invalid” if the statement would result in an error. Each problem is independent of the others (e.g. Question 2 does not depend on Question 1, only the “Given” code).

Subsection 1.15.2 Expressions-WE5-P2

Given
alpha = 2 
beta = 1
delta = 3
omega = 2.5
theta = -1.3
kappa = '3'

Exercises Exercises

1.
Q41: What is the value of kappa?
kappa /= beta
2.
Q42: What is the value of alpha?
alpha *= beta + delta
3.
Q43: What is the value of alpha?
alpha *= kappa
4.
    Q44: kappa *= omega
    Why is this statement invalid?
  • omega does not have a value
  • cannot multiple by a non-integer value
  • cannot perform string operations on a number
  • cannot perform math operations on a string
You have attempted of activities on this page.