Skip to main content

Section 1.21 Evaluate Expressions-WE10-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.21.1

For all given problems below, evaluate what value is assigned to the variable . Each problem is independent of the others (e.g. Question 2 does not depend on Question 1, only the “Given” code).

Subsection 1.21.2 Expressions-WE10-P1

Given
alpha = 10
beta = 0
gamma = -2.5
delta = 'string'

Exercises Exercises

1.
    Q68: What is the value stored in result?
    result = alpha and beta
    
  • 0
  • 10
  • False
  • True
2.
    Q69: What is the value stored in result?
    result = beta or alpha or gamma + 5
    
  • 10
  • 15
  • 0.0
  • 2.5
  • -2.5
3.
    Q70: What is the value stored in result?
    result = True or alpha
    
  • True
  • False
  • 1
  • 10
  • Invalid Code
4.
    Q71: What is the value stored in result?
    result = delta or alpha
    
  • 10
  • True
  • False
  • ’string’
  • Invalid Code
5.
    Q72: What is the value stored in result?
    result = delta or gamma
    
  • -2.5
  • ’string’
  • True
  • False
  • Invalid Code
You have attempted of activities on this page.