Skip to main content

Section 1.1 Declaration and Initialization

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

Given the following code snippet, evaluate the final statement (the last line). If invalid, give the reason. If valid, what value is assigned to the variable?
beta = 1
omega = 2.5
alpha = 42
theta = 4

Subsection 1.1.2 SG1: Decide order of operations

There are no operators, so the only order is the order of the individual lines.

Subsection 1.1.3 SG2: Determine operator behavior based on operands

NOT USED IN THIS EXAMPLE.

Subsection 1.1.4 SG3: Solve arithmetic, expression, or operation

The value 1 is stored in beta, the value 2.5 is stored in omega, the value 42 is stored in alpha, and the value 4 is stored in the variable theta.
You have attempted of activities on this page.