Skip to main content

Section 1.11 Evaluate Expressions-WE4-P1

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.11.1

For all given problems below indicate if the code is valid or invalid. Each problem is independent of the others (e.g. Question 2 does not depend on Question 1, only the “Given” code).

Subsection 1.11.2 Expressions-WE4-P1

Given
alpha = 2
beta = 1 
delta = 3 
omega = 2.5 
theta = -1.3 
kappa = 3.0
gamma = '4'
zeta = '2.5'

Exercises Exercises

1.
    Q28:
    lambda = alpha / kappa + delta
    
  • valid
  • invalid
2.
    Q29:
    eta = alpha * beta + (gamma - theta) * kappa
    
  • valid
  • invalid
3.
    Q30:
    lambda = (gamma + zeta) * delta
    
  • valid
  • invalid
4.
    Q31:
    epsilon = (gamma + zeta) * omega
    
  • valid
  • invalid
You have attempted of activities on this page.