Skip to main content
Contents
Dark Mode Prev Up Next Scratch ActiveCode Profile
\(\newcommand{\N}{\mathbb N}
\newcommand{\Z}{\mathbb Z}
\newcommand{\Q}{\mathbb Q}
\newcommand{\R}{\mathbb R}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 2.12 Evaluate Expressions-WE4-P2
Subgoals for evaluating an assignment statement.
Decide order of operations
Determine operator behavior based on operands
Operator and operands must be compatible
Solve arithmetic, expression, or operation
Subsection 2.12.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).
If you must round a numeric answer, use 4 decimal places of precision.
Subsection 2.12.2 Expressions-WE4-P2
alpha = 2
beta = 1
delta = 3
omega = 2.5
theta = -1.3
kappa = 3.0
gamma = '4'
zeta = '2.5'
Exercises Exercises
1.
2.
3.
4.
Q35:
eta = alpha * beta + (omega - theta) * gamma
Why is this statement invalid?
Cannot perform addition or subtration on a string
eta does not have a value
cannot perform string operations on a number
5.
Which statement will calculate the volume of a sphere most accurately?
volume = 4 // 3 * 3.14 * r * r * r
volume = 4 // 3 * 3.14159 * r * r * r
volume = 4 / 3 * 3.14 * r * r * r
An accurate result is not possible with these data types
You have attempted
of
activities on this page.