Skip to main content

Section 2.3 Assessment: Expressions

Subgoals for writing expressions:.

  1. Craft name of variable
  2. Determine operators, function calls, or method calls that will produce the value of variable
  3. Decide order of operands and operators
    1. Operators and operands must be compatible
    2. Decompose as necessary

Exercises Exercises

    1.

    Q1: What is the value of beta after the following code is executed?
    alpha = 3
    beta = 7
    gamma = -3.5
    delta = '5'
    epsilon = 'numbers'                    
    beta //= alpha
    

    2.

      Q2: Is the following code valid?
      alpha = 3
      beta = 7
      gamma = -3.5
      delta = '5'
      epsilon = 'numbers'                    
      gamma += beta
      
    • Yes
    • No

    3.

    Q3: What is the value of zeta after the following code is executed?
    alpha = 3
    beta = 7
    gamma = -3.5
    delta = '5'
    epsilon = 'numbers'                    
    zeta = epsilon or alpha
    

    4.

    Q4: What is the value of eta after the following code is executed?
    alpha = 3
    beta = 7
    gamma = -3.5
    delta = '5'
    epsilon = 'numbers'                    
    eta = alpha*delta
    

    5.

      Q5: What is the value of theta after the following code is executed?
      alpha = 3
      beta = 7
      gamma = -3.5
      delta = '5'
      epsilon = 'numbers'                    
      theta = gamma < beta + delta
      
    • True
    • False
    • This code is invalid
You have attempted of activities on this page.