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
new concepts than just the vocabulary, so don’t be tempted to skip reading the
151
151
chapter and just jumping to the glossary!</p>
152
152
<p>The chapters broadly alternate between introducing new programming concepts,
153
-
such as <aclass="reference internal" href="2_objects.html#objects"><spanclass="std std-ref">Objects and abstraction</span></a>, <spanclass="xref std std-ref">abstract data types</span>, or <aclass="reference internal" href="6_inheritance.html#inheritance"><spanclass="std std-ref">Inheritance and composition</span></a>, and
154
-
covering various aspects of the craft of programming, such as <spanclass="xref std std-ref">style</span>,
155
-
<aclass="reference internal" href="7_debugging.html#debugging"><spanclass="std std-ref">Debugging and testing</span></a>. In this way the course combines specific programming knowledge
153
+
such as <aclass="reference internal" href="2_objects.html#objects"><spanclass="std std-ref">objects</span></a>, <aclass="reference internal" href="4_abstract_data_types.html#abstract-data-types"><spanclass="std std-ref">abstract data types</span></a>, or <aclass="reference internal" href="6_inheritance.html#inheritance"><spanclass="std std-ref">inheritance</span></a>, and
154
+
covering various aspects of the craft of programming, such as <aclass="reference internal" href="6_inheritance.html#inheritance"><spanclass="std std-ref">style</span></a> and
155
+
<aclass="reference internal" href="7_debugging.html#debugging"><spanclass="std std-ref">debugging</span></a>. In this way the course combines specific programming knowledge
writing code. The core of each week’s activities is therefore to put the new
181
181
concepts and programming structures you’ve learned into practice. The
182
182
programming exercises are given at the end of each chapter, just before the
183
-
glossary. Each time there will be a skeleton code available from GitHub
184
-
Classroom (we’ll introduce that in <codeclass="xref std std-numref docutils literal notranslate"><spanclass="pre">github_classroom</span></code>) which provides
185
-
the starting point. Sometimes you might be asked to complete a piece of code
186
-
while on other occasions you’ll need to write a whole Python module from
187
-
scratch. Each set of exercises will come with a matching set of tests. These are
188
-
small programs which check whether your code produces the correct responses to a
189
-
range of inputs. Tests like this provide immediate feedback and enable you to
190
-
know how you are doing without having to wait for code to be submitted and
191
-
marked.</p>
183
+
glossary. Each time there will be a skeleton code available from
184
+
<aclass="reference external" href="https://imperial-fons-computing.github.io/git.html#github-classroom-exercise" title="(in Installation instructions for FoNS v2020.0)"><spanclass="xref std std-ref">GitHub Classroom</span></a> which provides the starting
185
+
point. Sometimes you might be asked to complete a piece of code while on other
186
+
occasions you’ll need to write a whole Python module from scratch. Each set of
187
+
exercises will come with a matching set of tests. These are small programs which
188
+
check whether your code produces the correct responses to a range of inputs.
189
+
Tests like this provide immediate feedback and enable you to know how you are
190
+
doing without having to wait for code to be submitted and marked.</p>
192
191
</div>
193
192
<divclass="section" id="getting-help">
194
193
<h3><spanclass="section-number">1.1.5. </span>Getting help<aclass="headerlink" href="#getting-help" title="Permalink to this headline">¶</a></h3>
@@ -221,81 +220,15 @@ <h2><span class="section-number">1.2. </span>Obtaining the right software tools<
221
220
the instructions in this course will assume that this is what you are using.</p></li>
222
221
</ol>
223
222
</div></blockquote>
224
-
<divclass="section" id="windows">
225
-
<h3><spanclass="section-number">1.2.1. </span>Windows<aclass="headerlink" href="#windows" title="Permalink to this headline">¶</a></h3>
226
-
<p>If you already have Python (3.6 or later) installed, for example because you
227
-
have installed Anaconda then this is likely to be fine. Otherwise, Python for
228
-
Windows can be obtained from the <aclass="reference external" href="https://www.python.org/downloads/">official Python website</a>. Simply click on the download button and
229
-
follow the instructions.</p>
230
-
<p>Git for Windows can be downloaded from the <aclass="reference external" href="https://git-scm.com/download/win">official Git website</a>.</p>
231
-
<p>Visual Studio Code can be downloaded from <aclass="reference external" href="https://code.visualstudio.com">Microsoft</a>.</p>
232
-
</div>
233
-
<divclass="section" id="macos">
234
-
<h3><spanclass="section-number">1.2.2. </span>MacOS<aclass="headerlink" href="#macos" title="Permalink to this headline">¶</a></h3>
235
-
<p>MacOS comes with Python3, but unfortunately it’s a broken version. Usually the
236
-
best option is to install the package manager <aclass="reference external" href="https://brew.sh">Homebrew</a> and
237
-
use that to install Python (and Git). In order to do this, you’ll need to open a
238
-
terminal. This is a program which comes with MacOS and enables you to run other
239
-
programs by typing text commands. Press ⌘ + <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">space</span></code> to open Spotlight Search,
240
-
and type <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">terminal</span></code> followed by return. Now copy the following line and paste it
<p>Once again, you finish by pressing the return key (⏎).</p>
252
-
<p>To install Visual Studio Code, follow the instructions on the <aclass="reference external" href="https://code.visualstudio.com/docs/setup/mac">Microsoft website</a>.</p>
253
-
</div>
254
-
<divclass="section" id="linux">
255
-
<h3><spanclass="section-number">1.2.3. </span>Linux<aclass="headerlink" href="#linux" title="Permalink to this headline">¶</a></h3>
256
-
<p>If you are running a fairly recent version of Linux then you almost certainly
257
-
have a suitable Python installed already, and may also have git installed. Open
258
-
a terminal (the way you do this depends a little on distribution, but if you’re
259
-
a Linux user we’ll assume you know how to do this). At the terminal prompt run
<h2><spanclass="section-number">1.3. </span>Working with revision control<aclass="headerlink" href="#working-with-revision-control" title="Permalink to this headline">¶</a></h2>
292
-
<p>In this section we’ll introduce the revision control system Git to the extent to
293
-
which we’ll need it in this module, and show how to use it in conjunction with
294
-
Visual Studio Code. This is not a comprehensive Git introduction, and readers
295
-
are invited to take a little more time to undertake the excellent <aclass="reference external" href="https://swcarpentry.github.io/git-novice/">Git tutorial</a> tutorial from <aclass="reference external" href="https://software-carpentry.org">Software Carpentry</a>.</p>
<h3><spanclass="section-number">1.3.1. </span>What is revision control, and why should you care?<aclass="headerlink" href="#what-is-revision-control-and-why-should-you-care" title="Permalink to this headline">¶</a></h3>
298
-
<p>The best way to understand</p>
223
+
<p>The Faculty of Natural Sciences at Imperial has centralised instructions for
224
+
installing all of these tools, and we’ll follow those.</p>
225
+
<divclass="section" id="python">
226
+
<h3><spanclass="section-number">1.2.1. </span>Python<aclass="headerlink" href="#python" title="Permalink to this headline">¶</a></h3>
227
+
<p>Follow the <aclass="reference external" href="https://docs.python.org/3/library/python.html#python" title="(in Python v3.9)"><spanclass="xref std std-ref">FoNS Python instructions</span></a>. We will exclusively
228
+
use <aclass="reference external" href="https://imperial-fons-computing.github.io/python.html#python-virtual-environments" title="(in Installation instructions for FoNS v2020.0)"><spanclass="xref std std-ref">virtual environments</span></a> so for Mac and Linux users, it doesn’t matter at
229
+
all whether you use Python from Anaconda or from another source. Mac users
230
+
should note, though that the built-in Python will not do, so you should use
the practical details of including tests in your code here.</p>
621
621
<p>There are a number of Python packages which support code testing. The
622
622
concepts are largely similar so rather than get bogged down in the
623
-
details of multiple frameworks, we will introduce <aclass="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v0.1.dev266+g69419cb)"><spanclass="xref std std-doc">pytest</span></a>, which is one of the most widely used.</p>
623
+
details of multiple frameworks, we will introduce <aclass="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v0.1.dev280+gf453460)"><spanclass="xref std std-doc">pytest</span></a>, which is one of the most widely used.</p>
624
624
<divclass="section" id="pytest-tests">
625
625
<h3><spanclass="section-number">2.7.1. </span>Pytest tests<aclass="headerlink" href="#pytest-tests" title="Permalink to this headline">¶</a></h3>
626
626
<p>A Pytest test is simply a function whose name starts with <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">test_</span></code>. In
<dtid="term-attribute">attribute</dt><dd><p>A value encapsulated in another object, such as a
623
623
<aclass="reference internal" href="#term-class"><spanclass="xref std std-term">class</span></a>. Attributes are accessed using dot syntax, so if
624
624
<codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">b</span></code> is an attribute of <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">a</span></code> then its value is accessed using the
syntax <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">a.b</span></code>.<aclass="reference internal" href="#term-method"><spanclass="xref std std-term">Methods</span></a> are a special case of attributes.</p>
626
626
</dd>
627
627
<dtid="term-class">class</dt><dtid="term-type">type</dt><dd><p>An abstraction defined by a set of possible values, and a set
628
628
of operators valid for objects of that type. <aclass="reference external" href="https://docs.python.org/3/reference/compound_stmts.html#class" title="(in Python v3.9)"><codeclass="xref std std-keyword docutils literal notranslate"><spanclass="pre">Class</span></code></a> and <aclass="reference external" href="https://docs.python.org/3/library/functions.html#type" title="(in Python v3.9)"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">type</span></code></a> are essentially synonymous, though
responsible for setting up the object. The constructor modifies
634
634
<codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">self</span></code> in place: constructors never return a value.</p>
635
635
</dd>
636
+
<dtid="term-data-attribute">data attribute</dt><dd><p>An <aclass="reference internal" href="#term-attribute"><spanclass="xref std std-term">attribute</span></a> which is not a <aclass="reference internal" href="#term-method"><spanclass="xref std std-term">method</span></a>. As the name
637
+
suggests, these are used to store data in an object.</p>
638
+
</dd>
636
639
<dtid="term-encapsulation">encapsulation</dt><dd><p>The bundling up of attributes and methods into an object which
637
640
can be dealt with as a single unit.</p>
638
641
</dd>
642
+
<dtid="term-infix-operator">infix operator</dt><dd><p>A mathematical operator whose symbol is written between its arguments.
643
+
Examples include addition, subtraction, division and multiplication.</p>
644
+
</dd>
639
645
<dtid="term-instance">instance</dt><dd><p>An object of a particular class. <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">a</span></code> is an instance of
640
646
<codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">MyClass</span></code> means that <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">a</span></code> has class <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">MyClass</span></code>. We will
641
647
return to this concept when we learn about <aclass="reference internal" href="6_inheritance.html#inheritance"><spanclass="std std-ref">inheritance</span></a>.</p>
0 commit comments