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
Copy file name to clipboardExpand all lines: 2_programs_in_files.html
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -117,8 +117,8 @@ <h3><span class="section-number">2.2.1. </span>Installing packages from PyPI<a c
117
117
<p><aclass="reference external" href="https://pypi.org">PyPI</a> is the Python Package Index. It is the
118
118
official download location for publicly released Python packages which
119
119
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.9)"><spanclass="xref std std-doc">Python Standard Library</span></a>. Many important mathematical packages
120
-
including <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.19)"><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
121
-
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.19)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a>
120
+
including <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.20)"><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
121
+
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.20)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a>
122
122
installed and you need it. You would install it with the following
@@ -396,14 +396,14 @@ <h3><span class="section-number">2.5.2. </span>Other forms of import<a class="he
396
396
don’t really want to write <aclass="reference external" href="https://docs.python.org/3/library/math.html#math.sin" title="(in Python v3.9)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">math.sin()</span></code></a> in every trig formula you
397
397
ever write. One alternative is to rename the module on import. This is
398
398
achieved using the keyword <aclass="reference external" href="https://docs.python.org/3/reference/simple_stmts.html#import" title="(in Python v3.9)"><codeclass="xref std std-keyword docutils literal notranslate"><spanclass="pre">as</span></code></a> in an import statement. For example,
399
-
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.19)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> in the
399
+
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.20)"><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.19)"><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.19)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a>,
404
+
<p>This creates the local name <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.20)"><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.20)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a>,
405
405
so that the function for creating an evenly spaced sequence of values
406
-
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.19)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">np.linspace</span></code></a>.</p>
406
+
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.20)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">np.linspace</span></code></a>.</p>
407
407
<p>A second option is to import particular names from a module directly
408
408
into the current namespace. For example, if we planned to use the
409
409
functions <aclass="reference external" href="https://docs.python.org/3/library/math.html#math.sin" title="(in Python v3.9)"><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.9)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">math.cos()</span></code></a> a lot in our script, we
the practical details of including tests in your code here.</p>
651
651
<p>There are a number of Python packages which support code testing. The
652
652
concepts are largely similar so rather than get bogged down in the
653
-
details of multiple frameworks, we will introduce <aclass="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v6.3.0.dev104+gd4f8e4b40)"><spanclass="xref std std-doc">pytest</span></a>, which is one of the most widely used. Pytest is simply a Python
653
+
details of multiple frameworks, we will introduce <aclass="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v6.3.0.dev194+g16e21c22a)"><spanclass="xref std std-doc">pytest</span></a>, which is one of the most widely used. Pytest is simply a Python
654
654
package, so you can install it into your current environment using:</p>
<h3><spanclass="section-number">4.7.4. </span>Long docstrings<aclass="headerlink" href="#long-docstrings" title="Permalink to this headline">¶</a></h3>
1004
1004
<p>Conversely, a more complex object will require much more information in its
1005
-
docstring. Consider <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.array.html#numpy.array" title="(in NumPy v1.19)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.array()</span></code></a> (click on the link for the
1005
+
docstring. Consider <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.array.html#numpy.array" title="(in NumPy v1.20)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.array()</span></code></a> (click on the link for the
1006
1006
documentation). The web documentation, also generated from the docstring, needs
1007
1007
to cover 5 parameters, and detail the return type. It also contains several
1008
1008
examples, references to other functions, and an explanatory note. This is an
@@ -1185,7 +1185,7 @@ <h2><span class="section-number">4.10. </span>Exercises<a class="headerlink" hre
1185
1185
reflected or rotated.</p>
1186
1186
<olclass="arabic simple">
1187
1187
<li><p>Add a class <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Pattern</span></code> to <codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">life.life</span></code>. The <aclass="reference internal" href="3_objects.html#term-constructor"><spanclass="xref std std-term">constructor</span></a> should
1188
-
take in a <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.19)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> array containing a pattern of 1s and 0s, and
1188
+
take in a <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.20)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> array containing a pattern of 1s and 0s, and
1189
1189
assign it to the <aclass="reference internal" href="3_objects.html#term-attribute"><spanclass="xref std std-term">attribute</span></a><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">grid</span></code>.</p></li>
1190
1190
<li><p>Add <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Pattern</span></code> to the <aclass="reference external" href="https://docs.python.org/3/reference/simple_stmts.html#import" title="(in Python v3.9)"><codeclass="xref std std-keyword docutils literal notranslate"><spanclass="pre">import</span></code></a> statement in
Copy file name to clipboardExpand all lines: 7_midterm.html
+14-12Lines changed: 14 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -76,10 +76,12 @@
76
76
<divclass="section" id="test-format">
77
77
<h2><spanclass="section-number">7.1. </span>Test format<aclass="headerlink" href="#test-format" title="Permalink to this headline">¶</a></h2>
78
78
<p>The final exam will be two hours long and comprise 4 questions, each of which
79
-
will be marked out of 20. The midterm test will be one hour long, so to keep the
80
-
question format consistent with the final exam, there will be two questions.
81
-
Each question will be subdivided into identified parts with a specified number
82
-
of marks associated with each.</p>
79
+
will be marked out of 20. The midterm test will be 40 minutes long, so to keep
80
+
the question format consistent with the final exam, there will a single
81
+
question. The extra 10 minutes is to give you some flexibility, because in the
82
+
final exam you could spend more time on some questions than others. The
83
+
question will be subdivided into identified parts with a specified number of
84
+
marks associated with each.</p>
83
85
<p>The test will work using GitHub Classroom. The link to accept the test
84
86
“assignment” will be distributed at the start time of the test, simultaneously in the
85
87
course Teams channel, by email, and in the Piazza forum. The test repository
@@ -103,7 +105,7 @@ <h2><span class="section-number">7.2. </span>The mark scheme<a class="headerlink
103
105
optimal <aclass="reference internal" href="5_abstract_data_types.html#term-algorithmic-complexity"><spanclass="xref std std-term">algorithmic complexity</span></a>, and be elegant and readable. The tests
104
106
provided are an aid to writing correct code: passing the tests does not prove
105
107
that your answer is correct. For example, your code could produce the correct
106
-
output in the cases test but nonetheless fail to implement the specification in
108
+
output in the cases tested but nonetheless fail to implement the specification in
107
109
the question. For the avoidance of doubt, a correct answer is one which
108
110
correctly implements the specification, not simply one which passes the tests
109
111
provided.</p>
@@ -114,18 +116,18 @@ <h2><span class="section-number">7.2. </span>The mark scheme<a class="headerlink
114
116
</div>
115
117
<divclass="section" id="using-git-in-the-test">
116
118
<h2><spanclass="section-number">7.3. </span>Using git in the test<aclass="headerlink" href="#using-git-in-the-test" title="Permalink to this headline">¶</a></h2>
117
-
<p>You should clone the test repository into the folder you created for the course,
118
-
just like you have been doing for the exercise repositories. This will help
119
-
ensure that you are programming in the same environment you have been using all
120
-
along, and therefore avoid any unfortunate misconfiguration surprises in the
121
-
test.</p>
119
+
<p>You should accept the test from GitHub classroom, and clone the test repository
120
+
into the folder you created for the course, just like you have been doing for
121
+
the exercise repositories. This will help ensure that you are programming in
122
+
the same environment you have been using all along, and therefore avoid any
123
+
unfortunate misconfiguration surprises in the test.</p>
122
124
<p>This is a test of programming as a whole, so using git correctly is a part of
123
125
the test. This has some consequences for how you should go about the test:</p>
124
126
<olclass="arabic simple">
125
127
<li><p>Commit <em>and</em> push your work as you go along. Do not rely on committing once
126
128
at the end of the test. You will be marked on what you have pushed to GitHub
127
129
at the end of the test period. If the first time that you try to push
128
-
something to GitHub is at the end of the hour, and something goes wrong, then
130
+
something to GitHub is at the end of the test time, and something goes wrong, then
129
131
you will receive 0% for the test, because you will not have pushed any
130
132
answers.</p></li>
131
133
<li><p>Don’t forget to <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">git</span><spanclass="pre">add</span></code> any files you need to create. If you don’t add them
@@ -154,7 +156,7 @@ <h2><span class="section-number">7.4. </span>Preparing for the test<a class="hea
154
156
questions here. Each of these is a question similar in format and length to the
155
157
questions on the exam. Just like on the exam, the question is specified in the
156
158
<codeclass="file docutils literal notranslate"><spanclass="pre">README.rst</span></code> file in the exercise repository. When you first attempt each
157
-
of these exercises, you should set yourself a 30 minute timer and see what you
159
+
of these exercises, you should set yourself a 40 minute timer and see what you
158
160
can get done (and committed and pushed!) in the time you would have in the test.
159
161
After that, if you haven’t finished, then go on and finish the exercise.
160
162
Programming is a practical discipline, and finishing one exercise will make you
order <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">n</span></code>. You will need to implement the group operation and the validation
784
784
of group element values. Group elements can be represented by sequences
785
785
containing permutations of the integers from 0 to <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">n-1</span></code>. You will find it
786
-
advantageous to convert these permutations to <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.array.html#numpy.array" title="(in NumPy v1.19)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.array()</span></code></a> using
787
-
<aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.asarray.html#numpy.asarray" title="(in NumPy v1.19)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.asarray()</span></code></a> because the indexing rules for that type mean that the
786
+
advantageous to convert these permutations to <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.array.html#numpy.array" title="(in NumPy v1.20)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.array()</span></code></a> using
787
+
<aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.asarray.html#numpy.asarray" title="(in NumPy v1.20)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.asarray()</span></code></a> because the indexing rules for that type mean that the
788
788
group operation can simply be implemented by indexing the first permutation
789
789
with the second: <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">a[b]</span></code>.</p>
790
790
<p>You will also need to set the <aclass="reference internal" href="#term-class-attribute"><spanclass="xref std std-term">class attribute</span></a><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">notation</span></code>. For this
0 commit comments