Skip to main content\(\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 4.6 Evaluate Conditionals-WE3-P1
Subgoals for Evaluating Selection Statements.
-
Diagram which statements go together by indentation
-
For conditional, determine whether expression is true
-
If true, follow true branch
-
If false, follow next elif/else branch or exit conditional if no else branch
-
Repeat step 2 as necessary
Subsection 4.6.1 Conditionals-WE3-P1
Each question below is independent, but they all use this given setup
Exercises Exercises
1.
Q12: What is the only numerical value that has a truthiness of False?
No numerical values have a truthiness of False
All numerical values have a truthiness of False
2.
Q13: Click on all conditions that are true in the following code before the code is executed:
if a + c:
c = 12
if c:
b = 1
elif a:
a = c
elif b:
a = b
3.
Q14: Enter the value of each variable after the following code is executed:
if a + c:
c = 12
if c - a:
a = 1
if b:
a = b
elif a - a:
a = c
else:
a = 13
4.
Q15: What is the output of the following code?
if b >= c:
if b >= a:
print("b")
elif a >= c:
print("a")
elif b >= a:
print("c")
elif a >= c:
print("a")
else:
print("c")
5.
Q16: What is the output of the following code?
if c == 2*a:
print("double")
elif c == 3*a:
print("triple")
elif c == 4*a:
print("quadruple")
elif c == 5*a:
print("quintuple")
else:
print("unknown")
You have attempted
of
activities on this page.