From 0fc358682ab7b8fc41072f11e044c310b3078b6b Mon Sep 17 00:00:00 2001 From: cprutean <cip.pruteanu@ed.ac.uk> Date: Wed, 23 Aug 2023 22:18:05 +0100 Subject: [PATCH] Update 12 files - /CourseNotes/basicfunctions.ipynb - /CourseNotes/conditionalstatements.ipynb - /CourseNotes/fileIO.ipynb - /CourseNotes/functions.ipynb - /CourseNotes/loops.ipynb - /CourseNotes/MoreFunctions.ipynb - /CourseNotes/ObjectsandOOP.ipynb - /CourseNotes/ParsingInput.ipynb - /CourseNotes/plotting.ipynb - /CourseNotes/program.ipynb - /CourseNotes/simplelists.ipynb - /CourseNotes/terminalIO.ipynb --- CourseNotes/MoreFunctions.ipynb | 9 +++++---- CourseNotes/ObjectsandOOP.ipynb | 5 +++-- CourseNotes/ParsingInput.ipynb | 3 ++- CourseNotes/basicfunctions.ipynb | 3 ++- CourseNotes/conditionalstatements.ipynb | 3 ++- CourseNotes/fileIO.ipynb | 9 +++++---- CourseNotes/functions.ipynb | 3 ++- CourseNotes/loops.ipynb | 11 ++++++----- CourseNotes/plotting.ipynb | 9 +++++---- CourseNotes/program.ipynb | 3 ++- CourseNotes/simplelists.ipynb | 11 ++++++----- CourseNotes/terminalIO.ipynb | 9 +++++---- 12 files changed, 45 insertions(+), 33 deletions(-) diff --git a/CourseNotes/MoreFunctions.ipynb b/CourseNotes/MoreFunctions.ipynb index c56bdcb..4bc88dc 100644 --- a/CourseNotes/MoreFunctions.ipynb +++ b/CourseNotes/MoreFunctions.ipynb @@ -1,12 +1,13 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# More on Functions\n", "\n", - "In the section on basic functions, `Basic Functions`, we considered the simple case where a function took a number of arguments ard returned a single *value*, typically a `float`. We now want on extend this to look at more complex use of functions.\n", + "In the section on basic functions, [Basic Functions](basicfunctions.ipynb), we considered the simple case where a function took a number of arguments ard returned a single *value*, typically a `float`. We now want on extend this to look at more complex use of functions.\n", "\n", "\n", "## Returning more than one value\n", @@ -69,11 +70,11 @@ "\n", "\n", ">> **Code Example**\n", - "- Plot Planck Radiation curve :\n", + "- Plot Planck Radiation curve : [Planck Plot](../CodeExamples/PlanckPlot.ipynb)\n", "This is a more complicated example with a *function* that returns a\n", "*list*. You will see a better way to do this later in the course when we\n", "look at the `Map Function`.\n", - "- Volume of Sphere by random numbers :\n", + "- Volume of Sphere by random numbers : [SphereVolume](../CodeExamples/SphereVolume.ipynb)\n", "Program to calculate the volume of a sphere by counting three dimensional points; this is an example of a simple Monte Carlo simulation which you will hear more about next year.\n", "\n", ">> Both of these longer examples show how the use of *functions* simplifies\n", @@ -134,7 +135,7 @@ "> ####The Tuple\n", "There is a variant on the list called a `tuple` which holds multiple elements just like a `list`, is indexed by the same `[i]` syntax for read *but* cannot be written to, so its values are *fixed*. This is not frequently used in normal *user* programs, but is used inside complex libraries to implement constants.\n", "\n", - ">> You have now completed sufficient to attempt Checkpoint 5." + ">> You have now completed sufficient to attempt [Checkpoint 5](../Checkpoints/Checkpoint5.ipynb)." ] }, { diff --git a/CourseNotes/ObjectsandOOP.ipynb b/CourseNotes/ObjectsandOOP.ipynb index 2ba7415..be1854e 100644 --- a/CourseNotes/ObjectsandOOP.ipynb +++ b/CourseNotes/ObjectsandOOP.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -8,7 +9,7 @@ "\n", "The next level of program design and structure includes the concepts of\n", "*Objects* and *Object Orientated Programming* (OOP). You have been using\n", - "*Objects* in your code, for example in `Plotting and Graphics`, they now need some explanation.\n", + "*Objects* in your code, for example in [Plotting and Graphics](plotting.ipynb), they now need some explanation.\n", "\n", "Up to now the `Function`s you have been writing take a number of arguments, do a fixed calculation based on these arguments and return a *value* or a `list` of *values*. This means that functions have no *local internal state*, so they do the same thing every time they are called. This is where *objects* differ, they have a *local internal state*, so have local internal variables that retain their values. This sounds a bit abstract, and a fine point, but it does result in a totally new way of thinking about programming; that is the fundamental difference in OOP.\n", "\n", @@ -187,7 +188,7 @@ "- `C++` which (in my opinion) has an even more confusing OOP environment than `Python` with even more scope for *getting it wrong*. Again like `Python` most users make extensive use of OOP pre-written classes, for example by using template libraries, but a few write new classes from scratch.\n", "\n", ">> **Code Example:**\n", - "- More developed `Vector3d` class to play with\n", + "- More developed `Vector3d` class to play with : [Vector](../CodeExamples/Vector.ipynb)\n", "\n", ">> This class starts to develop the OOP ideas, but is nowhere near\n", "*complete*; I have written a *full* Vector2D and Vector3D class that\n", diff --git a/CourseNotes/ParsingInput.ipynb b/CourseNotes/ParsingInput.ipynb index 000a2c2..643891c 100644 --- a/CourseNotes/ParsingInput.ipynb +++ b/CourseNotes/ParsingInput.ipynb @@ -1,12 +1,13 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Parsing Input\n", "\n", - "We have seen in `File Input and Output` how to read the contents of a file into a list of `str`, the problem now is how to work with these, and in particular how to extract numerical values. How to do this depends on the detailed structure of the data in the file, here we will consider two simple cases:\n", + "We have seen in [File Input and Output](fileIO.ipynb) how to read the contents of a file into a list of `str`, the problem now is how to work with these, and in particular how to extract numerical values. How to do this depends on the detailed structure of the data in the file, here we will consider two simple cases:\n", "\n", "## Single `float` per line\n", "\n", diff --git a/CourseNotes/basicfunctions.ipynb b/CourseNotes/basicfunctions.ipynb index 76c8959..185bc5c 100644 --- a/CourseNotes/basicfunctions.ipynb +++ b/CourseNotes/basicfunctions.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -111,7 +112,7 @@ "This is *good programming practice* that we want you to learn, it also avoids many of the problems, pitfalls and complications associated with *scope of variables*, details of which are in the optional sections at\n", "the end of the course.\n", "\n", - "- Scope of variables\n", + "- [Scope of variables](Scope.ipynb)\n", "\n", "You will see how to do more complex operations with functions later, but this will get you started for now." ] diff --git a/CourseNotes/conditionalstatements.ipynb b/CourseNotes/conditionalstatements.ipynb index 638efe0..79e4443 100644 --- a/CourseNotes/conditionalstatements.ipynb +++ b/CourseNotes/conditionalstatements.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -170,7 +171,7 @@ "and see what type of \"crashes\" you get.\n", "\n", ">> Once you have practiced and understood the `if : elif: else:` syntax you have completed\n", - "enough to attempt Checkpoint 2\n", + "enough to attempt [Checkpoint 2](../Checkpoints/Checkpoint2.ipynb)\n", "Note, Checkpoint is much more tricky than it looks, read in instuctions\n", "and the **Hint** and plan out all the conditions that your program has\n", "to deal with." diff --git a/CourseNotes/fileIO.ipynb b/CourseNotes/fileIO.ipynb index 2d088af..a9bd631 100644 --- a/CourseNotes/fileIO.ipynb +++ b/CourseNotes/fileIO.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -54,8 +55,8 @@ "This is sufficient to get you started and for many scientific `Python`  programs that deal with small amounts of data this is the only strategy you will *ever need to use*.\n", "\n", "> **Code Examples**\n", - "- Write strings to a file:\n", - "- Write values to a file from a for loop:\n", + "- Write strings to a file: [WriteFile](../CodeExamples/WriteFile.ipynb)\n", + "- Write values to a file from a for loop: [RangeLooptoFIle](../CodeExamples/RangeLooptoFile.ipynb)\n", "\n", "> Download and \"play\".\n", "\n", @@ -96,7 +97,7 @@ "3. `lin(lines)` is the number of lines successfully read.\n", "\n", "How you now process this list of strings is the trickier bit, see next\n", - "section for details on this at `Parsing Input`.\n", + "section for details on this at [Parsing Input](ParsingInput.ipynb).\n", "\n", "\n", "## Closing the file\n", @@ -109,7 +110,7 @@ "where `filein` is the *filestream*. This will close the file and tidy up. When a program exits successfully or *crashes* all open files are automatically *closed* so this is not something you have worry about in short programs, but it is *good programming style* to close files after the read/write has been completed.\n", "\n", "> **Code Examples**\n", - "- Read text file as strings:\n", + "- Read text file as strings: [ReadingandPrintingStrings](../CodeExamples/ReadingandPrintingStrings.ipynb)\n", "\n", "> Download and \"play\".\n", "\n", diff --git a/CourseNotes/functions.ipynb b/CourseNotes/functions.ipynb index 123f2aa..c84a8d5 100644 --- a/CourseNotes/functions.ipynb +++ b/CourseNotes/functions.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -94,7 +95,7 @@ "These are the very basics you need to get started on  programming, you\n", "now have enough background to write a basic program, read in numbers, do\n", "basic arithmetic, apply mathematical functions, and print out to the\n", - "terminal. This means you are now ready to attempt Checkpoint 1." + "terminal. This means you are now ready to attempt [Checkpoint 1](../Checkpoints/Checkpoint1.ipynb)." ] }, { diff --git a/CourseNotes/loops.ipynb b/CourseNotes/loops.ipynb index f21c422..bd58bfa 100644 --- a/CourseNotes/loops.ipynb +++ b/CourseNotes/loops.ipynb @@ -390,6 +390,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -402,12 +403,12 @@ "out what is really happening.\n", "\n", "> **Code Examples**\n", - "- Loop to terminal using for range :\n", - "- Loop to list using for range :\n", - "- Loop to list using while :\n", - "- Guessing Game using `while` and `break`:\n", + "- Loop to terminal using for range : [RangeLoop](../CodeExamples/RangeLoop.ipynb)\n", + "- Loop to list using for range : [RangeLooptoList](../CodeExamples/RangeLooptoList.ipynb)\n", + "- Loop to list using while : [WhileLooptoList](../CodeExamples/WhileLooptoList.ipynb)\n", + "- Guessing Game using `while` and `break`: [GuessGame](../CodeExamples/GuessGame.ipynb)\n", "\n", - "> You should download these examples and \"play\" with them." + "> You should have a look at these examples and \"play\" with them." ] } ], diff --git a/CourseNotes/plotting.ipynb b/CourseNotes/plotting.ipynb index 2c7a310..7033ad4 100644 --- a/CourseNotes/plotting.ipynb +++ b/CourseNotes/plotting.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -109,9 +110,9 @@ "which will give a red line for `firstydata` and green line for `secondydata`. \n", "\n", "> #### Code Examples\n", - "- Plot of $\\cos(\\theta)$ in the range 0→4Ï€\n", - "- Plot of flight of particle given inital velocity and acceleration : \n", - "- Plot of a quadratic using a function: \n", + "- Plot of $\\cos(\\theta)$ in the range 0→4Ï€ : [CosPlot](../CodeExamples/CosPlot.ipynb)\n", + "- Plot of flight of particle given inital velocity and acceleration : [FlightPlot](../CodeExamples/FlightPlot.ipynb)\n", + "- Plot of a quadratic using a function: [QuadraticPlot](../CodeExamples/QuadraticPlot.ipynb) \n", "- More complex plot of a function using a function from the data `lists` \n", "\n", "> Download and play with range, number of points and colours.\n", @@ -160,7 +161,7 @@ "\n", "This is all you need for making basic plots; Matplotlib is a very powerful and flexible package that will plot just about any type of graph / plot you can imagine. Look up the on-line examples in the Matpoltlib documentation and “playâ€. \n", "\n", - "> You have now completed sufficient programming to attempt Checkpoint 3." + "> You have now completed sufficient programming to attempt [Checkpoint 3](../Checkpoints/Checkpoint3.ipynb)." ] }, { diff --git a/CourseNotes/program.ipynb b/CourseNotes/program.ipynb index d595c66..589bb9a 100644 --- a/CourseNotes/program.ipynb +++ b/CourseNotes/program.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -78,7 +79,7 @@ "1. conversion to low level instructions (syntax error),\n", "2. during load (not able to find libraries or modules),\n", "3. or execution (did something numerically wrong).\n", - "There are more details on this in `Finding and fixing bugs`.\n", + "There are more details on this in [Finding and fixing bugs](bugs.ipynb).\n", "\n", "### Key Point\n", "So a *computer program* actually is\n", diff --git a/CourseNotes/simplelists.ipynb b/CourseNotes/simplelists.ipynb index d7ee70a..f9368f9 100644 --- a/CourseNotes/simplelists.ipynb +++ b/CourseNotes/simplelists.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -142,9 +143,9 @@ "> Computationally intensive scientific programs typically use the `numpy` and `scipy` modules which use to hold numerical data; these are similar in but limited to fixed numerical types of a fixed length; you will learn about these in next year’s *Computer Modelling* course.\n", "\n", ">> **Code Examples:**\n", - "- Make and append to a list :\n", - "- Extract sub lists and add lists together :\n", - "- Print a list :\n", + "- Make and append to a list : [MakeandAppendList](../CodeExamples/MakeandAppendList.ipynb)\n", + "- Extract sub lists and add lists together : [ExtractSublist](../CodeExamples/ExtractSublist.ipynb)\n", + "- Print a list : [PrintList](../CodeExamples/PrintList.ipynb)\n", "\n", "This is just the start of lists and you will learn much more as you use\n", "them. There are on-line examples:\n", @@ -175,8 +176,8 @@ "\n", "This works exactly as expected and the returned `list` called `nl` on line 8 is the copy of list `first` and `second` added together, so is a `list` of 10 elements holding the numbers $1\\rightarrow9$.\n", "\n", - "> Download and experiment with the following `append` fuction, and see that it also works for other variable types.\n", - "- Code of `AppendFunction`.\n", + "> Experiment with the following `append` fuction, and see that it also works for other variable types.\n", + "- Code of [AppendFunction](../CodeExamples/AppendFunction.ipynb).\n", "\n", "However things get a little more complicated if you pass a `list` into a `function`, and then change values in the `list`, so for example consider the following piece of code that sorts the contents of a `list`:\n", "```python\n", diff --git a/CourseNotes/terminalIO.ipynb b/CourseNotes/terminalIO.ipynb index 611a80a..97e9562 100644 --- a/CourseNotes/terminalIO.ipynb +++ b/CourseNotes/terminalIO.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -51,7 +52,7 @@ "```\n", "This will prompt you at the terminal with `\"Type your name : \"`. It will read this into to `str` variable `name` and then print it back. \n", "\n", - "> **Example Code:** Reading and printing out a string. \n", + "> **Example Code:** Reading and printing out a string: [ReadingandPrintingStrings](../CodeExamples/ReadingandPrintingStrings.ipynb) \n", "Note: the lines that start with `#` are *comments* and do not form part of\n", "the code.\n", "\n", @@ -75,9 +76,9 @@ "of this are beyond the scope of this course.\n", "\n", ">> **Example Code :**\n", - "- Reading and printing floats:\n", - "- Reading and formatting floats:\n", - "- Reading int and float : (more complicated example)\n", + "- Reading and printing floats: [ReadingandPrintingFloats](../CodeExamples/ReadingandPrintingFloats.ipynb)\n", + "- Reading and formatting floats: [ReadingandFormatFloats](../CodeExamples/ReadingandFormatFloats.ipynb)\n", + "- Reading int and float : (more complicated example) [ReadingIntandFloat](../CodeExamples/ReadingIntandFloat.ipynb)\n", "Download and run these programs; also try giving the wrong input types\n", "and see what happens. It will *crash* with a *Traceback* which is\n", "**not** friendly; try this out and learn to make sense of this, you will\n", -- GitLab