%reload_ext rubberizeAssignments
Assignments are rendered with the expression on the right-hand side using the same display modes.
%%tap
import math
x = 3.0
y = 4.0
z = math.sqrt(x**2 + y**2)\( \displaystyle x = 3.00 \)
\( \displaystyle y = 4.00 \)
\( \displaystyle z = \sqrt{x^{2} + y^{2}} = \sqrt{3.00^{2} + 4.00^{2}} = 5.00 \)
The expression math.sqrt(x**2 + y**2) is evaluated using the same definition, substitution, and result stages described in the expressions section.
Hiding Assignments
The special shortcut @hide prevents the rendering of the whole assignment.
Note
@hide is a special shortcut. It has no equivalent set of config options.
%%tap
x = 3.0 # @hide
y = 4.0 # @hide
z = math.sqrt(x**2 + y**2)\( \displaystyle z = \sqrt{x^{2} + y^{2}} = \sqrt{3.00^{2} + 4.00^{2}} = 5.00 \)
The code is still executed normally. The hidden assignments can still be accessed in subsequent cells.
Hiding Multiple Statements
To hide multiple statements, use the @hide shortcut as a line comment. Subsequent lines are hidden until the @endhide shortcut is used as a line comment.
Note
@endhide is also a special shortcut.
%%tap
a_1 = 3
a_2 = 8
# @hide
total = a_1 + a_2
difference = a_1 - a_2
product = a_1 * a_2
quotient = a_1 / a_2
# @endhide
total, difference, product, quotient\( \displaystyle a_{1} = 3 \)
\( \displaystyle a_{2} = 8 \)
\( \displaystyle \left( \mathrm{total},\, \mathrm{difference},\, \mathrm{product},\, \mathrm{quotient} \right) = \left( 11,\, -5,\, 24,\, 0.38 \right) \)
Multiple Targets
Assignment to multiple targets is supported.
%%tap
a_1, a_2 = b = (3, 8)
a_1
a_2
b\( \displaystyle a_{1},\, a_{2} = b = \left( 3,\, 8 \right) \)
\( \displaystyle a_{1} = 3 \)
\( \displaystyle a_{2} = 8 \)
\( \displaystyle b = \left( 3,\, 8 \right) \)
Type Hints
Type hints are ignored.
%%tap
a_1: int = 3