You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h2><spanclass="section-number">10.4. </span>Exercises<aclass="headerlink" href="#exercises" title="Permalink to this headline">¶</a></h2>
553
-
<p>Using the information on the <aclass="reference external" href="https://object-oriented-programming.github.io/edition1/exercises.html">book website</a>
553
+
<p>Using the information on the <aclass="reference external" href="https://object-oriented-python.github.io/edition1/exercises.html">book website</a>
554
554
obtain the skeleton code for these exercises.</p>
555
555
<divclass="proof proof-type-exercise" id="id8">
556
556
@@ -593,7 +593,7 @@ <h2><span class="section-number">10.4. </span>Exercises<a class="headerlink" hre
593
593
you really want to know how some part of the language works.</p>
<p><aclass="reference external" href="https://pypi.org">PyPI</a> is the Python Package Index. It is the
316
316
official download location for publicly released Python packages which
317
317
aren’t themselves a part of the built-in <aclass="reference external" href="https://docs.python.org/3/library/index.html" title="(in Python v3.10)"><spanclass="xref std std-doc">Python Standard Library</span></a>. Many important mathematical packages
318
-
including <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.21)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> and <aclass="reference external" href="https://www.sympy.org">sympy</a> are
319
-
distributed from PyPI. Suppose your venv doesn’t have <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.21)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a>
318
+
including <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.22)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> and <aclass="reference external" href="https://www.sympy.org">sympy</a> are
319
+
distributed from PyPI. Suppose your venv doesn’t have <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.22)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a>
320
320
installed and you need it. You would install it with the following
Copy file name to clipboardExpand all lines: 2_programs_in_files.html
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -356,14 +356,14 @@ <h3><span class="section-number">2.3.2. </span>Other forms of import<a class="he
356
356
don’t really want to write <aclass="reference external" href="https://docs.python.org/3/library/math.html#math.sin" title="(in Python v3.10)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">math.sin()</span></code></a> in every trig formula you
357
357
ever write. One alternative is to rename the module on import. This is
358
358
achieved using the keyword <aclass="reference external" href="https://docs.python.org/3/reference/simple_stmts.html#import" title="(in Python v3.10)"><codeclass="xref std std-keyword docutils literal notranslate"><spanclass="pre">as</span></code></a> in an import statement. For example,
359
-
it is usual to import the numerical Python module <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.21)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> in the
359
+
it is usual to import the numerical Python module <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.22)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> in the
<p>This creates the local name <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.21)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">np</span></code></a> instead of <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.21)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a>,
364
+
<p>This creates the local name <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.22)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">np</span></code></a> instead of <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.22)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a>,
365
365
so that the function for creating an evenly spaced sequence of values
366
-
between to end points is now accessible as <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy.linspace" title="(in NumPy v1.21)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">np.linspace</span></code></a>.</p>
366
+
between to end points is now accessible as <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy.linspace" title="(in NumPy v1.22)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">np.linspace</span></code></a>.</p>
367
367
<p>A second option is to import particular names from a module directly
368
368
into the current namespace. For example, if we planned to use the
369
369
functions <aclass="reference external" href="https://docs.python.org/3/library/math.html#math.sin" title="(in Python v3.10)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">math.sin()</span></code></a> and <aclass="reference external" href="https://docs.python.org/3/library/math.html#math.cos" title="(in Python v3.10)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">math.cos()</span></code></a> a lot in our script, we
<spanid="dependency-setup-py"></span><divclass="code-block-caption"><spanclass="caption-number">Listing 2.3 </span><spanclass="caption-text">An extension to the <codeclass="file docutils literal notranslate"><spanclass="pre">setup.py</span></code> from
616
-
<aclass="reference internal" href="#minimal-setup-py"><spanclass="std std-numref">Listing 2.2</span></a> to require that <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.21)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> is installed.</span><aclass="headerlink" href="#id10" title="Permalink to this code">¶</a></div>
616
+
<aclass="reference internal" href="#minimal-setup-py"><spanclass="std std-numref">Listing 2.2</span></a> to require that <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.22)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> is installed.</span><aclass="headerlink" href="#id10" title="Permalink to this code">¶</a></div>
<p>There are a number of Python packages which support code testing. The concepts
648
648
are largely similar so rather than get bogged down in the details of multiple
649
-
frameworks, we will introduce <aclass="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v7.1.0.dev46+g47df71d23)"><spanclass="xref std std-doc">Pytest</span></a>, which is one of the
649
+
frameworks, we will introduce <aclass="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v7.1.0.dev95+g71baf24b6)"><spanclass="xref std std-doc">Pytest</span></a>, which is one of the
650
650
most widely used. Pytest is simply a Python package, so you can install it into
<p>Using the information on the <aclass="reference external" href="https://object-oriented-programming.github.io/edition1/exercises.html">book website</a>
867
+
<p>Using the information on the <aclass="reference external" href="https://object-oriented-python.github.io/edition1/exercises.html">book website</a>
868
868
create your first exercise repository for this module and clone it
869
869
into your working folder. The exercise repository just contains a
870
870
<codeclass="file docutils literal notranslate"><spanclass="pre">README</span></code> and some tests. Your job in the following exercises will be
<h2><spanclass="section-number">3.6. </span>Exercises<aclass="headerlink" href="#exercises" title="Permalink to this headline">¶</a></h2>
816
-
<p>Using the information on the <aclass="reference external" href="https://object-oriented-programming.github.io/edition1/exercises.html">book website</a>
816
+
<p>Using the information on the <aclass="reference external" href="https://object-oriented-python.github.io/edition1/exercises.html">book website</a>
817
817
obtain the skeleton code for these exercises. The skeleton code contains a
818
818
<codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">polynomial</span></code> package with a version of the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Polynomial</span></code> class.</p>
0 commit comments