<p>Consider a hypothetical magnetic field pointing out of your computer screen. Now imagine an electron traveling from right to leftin the plane of your screen. A diagram of this situation is show below.</p>
For each of the following functions, specify the type of its <bclass="bfseries">output</b>. You can assume each function is called with an appropriate argument, as specified by its docstring. </p>
<p>
If the output can be either an int or a float, select num, which isn't a real Python type, but which we'll use to indicate that either basic numeric type is legal. </p>
<p>
In fact, in Python, booleans True and False can be operated on as if they were the integers 1 and 0; but it is ugly and confusing to take advantage of this fact, and we will resolutely pretend that it isn't true. </p><!-- so why even mention it? -->
<p>
<sectionclass="hints">
<divclass="collapsible">
<header>
<ahref="#"id="id41">What are those lines under the function definitions?</a>
</header>
<sectionid="id41">
<p>
In this and future problems, you'll see function definitions that look like this: </p>
<pre>
def a(x):
'''
x: int or float.
'''
return x + 1
</pre>
<p>
What are those three lines between <code>def a(x):</code> and <code>return x + 1</code>? These lines are called the <iclass="it">docstring</i> of the function. A docstring is a special type of comment that is used to document what your function is doing. Typically, docstrings will explain what the function expects the type(s) of the argument(s) to be, and what the function is returning. </p>
<p>
In Python, docstrings appear immediately after the <code>def</code> line of a function, before the body. Docstrings start and end with triple quotes - this can be triple single quotes or triple double quotes, it doesn't matter as long as they match. To sum up this general form: </p>
<pre>
def myFunction(argument):
"""
Docstring goes here. Explain what type argument(s) should have, and what your function
is going to return.
"""
< Code for your function (the body of the function) goes here >
</pre>
<p>
As you begin coding your own functions, we strongly encourage you to document all your functions by using properly-formatted docstrings! </p>
</section>
</div>
</section>
</p>
<olclass="enumerate">
<li>
<pre>
def a(x):
'''
x: int or float.
'''
return x + 1
</pre>
<p>
Indicate the type of the output that the function <code>a</code> will yield. <optionresponse><optioninputoptions="('NoneType','num','int','float','boolean')"correct="num"/></optionresponse></p>
</li>
<li>
<pre>
def b(x):
'''
x: int or float.
'''
return x + 1.0
</pre>
<p>
Indicate the type of the output that the function <code>b</code> will yield. <optionresponse><optioninputoptions="('NoneType','num','int','float','boolean')"correct="float"/></optionresponse></p>
</li>
<li>
<pre>
def c(x, y):
'''
x: int or float.
y: int or float.
'''
return x + y
</pre>
<p>
Indicate the type of the output that the function <code>c</code> will yield. <optionresponse><optioninputoptions="('NoneType','num','int','float','boolean')"correct="num"/></optionresponse></p>
</li>
<li>
<pre>
def d(x, y):
'''
x: Can be of any type.
y: Can be of any type.
'''
return x > y
</pre>
<p>
Indicate the type of the output that the function <code>d</code> will yield. <optionresponse><optioninputoptions="('NoneType','num','int','float','boolean')"correct="boolean"/></optionresponse></p>
</li>
<li>
<pre>
def e(x, y, z):
'''
x: Can be of any type.
y: Can be of any type.
z: Can be of any type.
'''
return x >= y and x <= z
</pre>
<p>
Indicate the type of the output that the function <code>e</code> will yield. <optionresponse><optioninputoptions="('NoneType','num','int','float','boolean')"correct="boolean"/></optionresponse></p>
</li>
<li>
<pre>
def f(x, y):
'''
x: int or float.
y: int or float
'''
x + y - 2
</pre>
<p>
Indicate the type of the output that the function <code>f</code> will yield. <optionresponse><optioninputoptions="('NoneType','num','int','float','boolean')"correct="NoneType"/></optionresponse></p>
</li>
</ol>
<p>
<bclass="bfseries">Part 2: Transcript</b>
</p>
<p>
Below is a transcript of a session with the Python shell. Assume the functions from Part 1 (above) have been defined. Provide the type and value of the expressions being evaluated. If evaluating an expression would cause an error, select NoneType and write 'error' in the box. If the value of an expression is a function, select function as the type and write 'function' in the box. </p>
<problemdisplay_name="S3E3: Deflection of a Proton">
<startouttext/>
<p>Suppose you were to pass a hydroge ion (H+) through an electric field and measure the deflection of the ion. How would its deflection compare to the deflection of an electron passed through the same electric field? </p>
<choicelocation="random"correct="false"name="1"><text>The ion would deflect identically as both species have the same charge.</text></choice>
<choicelocation="random"correct="false"name="2"><text>The ion would deflect by an amount identical in magnitude but opposite in direction because the charges are of opposite sign but equal in magnitude.</text></choice>
<choicelocation="random"correct="false"name="3"><text>The deflection will be in the same direction but smaller in magnitude due to the larger mass of the ion.</text></choice>
<choicelocation="random"correct="true"name="4"><text>The deflection will be smaller in magnitude due to the increased mass of the ion, as well as in the opposite direction due to the opposite sign of the charge.</text></choice>
<p>Metallothermic production of zirconium (Zr) would involve the reaction of sodium (Na) with zirconium tetrachloride (ZrCl<sub>4</sub>).</p>
<p><b>(a)</b> Write a balanced chemical equation.</p>
<!-- chemformularesponse
[mathjax] \text{a ZrCl}_{4 } + \text{ b }\text{Na} -> \text{ c }\text{NaCl } + \text{ d } \text{Zr} [/mathjax]
ratio of (a, b, c, d) = (1, 4, 4, 1)
-->
<customresponse>
<chemicalequationinputsize="50"/>
<answertype="loncapa/python">
if chemcalc.chemical_equations_equal(submission[0], 'ZrCl4 + 4 Na -> 4 NaCl + Zr'):
correct = ['correct']
else:
correct = ['incorrect']
</answer>
</customresponse>
<p><b>(b)</b> Write the balanced chemical equation using lowest whole numbers.</p>
<!-- chemformularesponse
as above, with (a, b, c, d) = (1, 4, 4, 1)
-->
<customresponse>
<chemicalequationinputsize="50"/>
<answertype="loncapa/python">
if chemcalc.chemical_equations_equal(submission[0], 'ZrCl4 + 4 Na -> 4 NaCl + Zr', exact=True):
correct = ['correct']
else:
correct = ['incorrect']
</answer>
</customresponse>
<p><b>(c)</b> Calculate the amount of zirconium produced (in kg) if a reactor were charged with 111 kg [mathjaxinline]\text{ZrCl}_4[/mathjaxinline] and 11.1 kg [mathjaxinline]\text{Na}[/mathjaxinline].
<p>[mathjaxinline]11.1\text{ kg Na} = 11100/22.99 = 483\text{ moles C}[/mathjaxinline]</p>
<p>stoichiometry of reaction further dictates that on a molar basis there needs to be 4 x amount of [mathjaxinline]\text{Na}[/mathjaxinline] as there is [mathjaxinline]\text{ZrCl}_4[/mathjaxinline], but calculations show there to be a shortfall of [mathjaxinline]\text{Na}[/mathjaxinline] </p>
<p>[mathjaxinline]\therefore[/mathjaxinline] reaction yield is contrained by [mathjaxinline]\text{Na}[/mathjaxinline] present </p>
<p>stoichiometry of reaction further dictates that if [mathjaxinline]\text{Na}[/mathjaxinline] controls the yield, then the amount of [mathjaxinline]\text{Zr}[/mathjaxinline] produced = 1/4 x molar quantity of [mathjaxinline]\text{Na}[/mathjaxinline] = 1/4 x 483 moles = 121 </p>
[mathjaxinline]121 \text{ moles Zr} \times 91.22\text{ g / mol } \mathbf{= 11.0 \text{ kg Zr} }[/mathjaxinline]<br/>
<p>Hints can be provided to students, based on the last response given, as well as the history of responses given. Here is an example of a hint produced by a Formula Response problem.</p>
<p>
What is the equation of the line which passess through ($x1,$y1) and
($x2,$y2)?</p>
<p>The correct answer is <tt>$answer</tt>. A common error is to invert the equation for the slope. Enter <tt>
<problemdisplay_name="S3E3: Deflection of a Proton">
<startouttext/>
<p>Suppose you were to pass a hydroge ion (H+) through an electric field and measure the deflection of the ion. How would its deflection compare to the deflection of an electron passed through the same electric field? </p>
<choicelocation="random"correct="false"name="1"><text>The ion would deflect identically as both species have the same charge.</text></choice>
<choicelocation="random"correct="false"name="2"><text>The ion would deflect by an amount identical in magnitude but opposite in direction because the charges are of opposite sign but equal in magnitude.</text></choice>
<choicelocation="random"correct="false"name="3"><text>The deflection will be in the same direction but smaller in magnitude due to the larger mass of the ion.</text></choice>
<choicelocation="random"correct="true"name="4"><text>The deflection will be smaller in magnitude due to the increased mass of the ion, as well as in the opposite direction due to the opposite sign of the charge.</text></choice>