"Take these and work / modify them and explore what happens:\n",
"\n",
"> [OneWayConditional](OneWayConditional.ipynb): Simple one way (if) conditional.\n",
"\n",
"> [TwoWayConditional](TwoWayConditional.ipynb): Simple two way (if else) conditional\n",
"\n",
"> [RootTwo](RootTwo.ipynb): Simply math.sqrt(x)**2 = x test to show the dangers of using test on floats; also the solution.\n",
"\n",
"> [ThreeWayConditional](ThreeWayConditional.ipynb): Basic if elfi else structure, look at this carefully and understand it.\n",
"\n",
"> [OneWayConditional](OneWayConditional.ipynb): Simple one way (if) conditional. \n",
"> [TwoWayConditional](TwoWayConditional.ipynb): Simple two way (if else) conditional. \n",
"> [RootTwo](RootTwo.ipynb): Simply math.sqrt(x)**2 = x test to show the dangers of using test on floats; also the solution. \n",
"> [ThreeWayConditional](ThreeWayConditional.ipynb): Basic if elfi else structure, look at this carefully and understand it. \n",
"> [ComplexQuadrant](ComplexQuadrant.ipynb): Determine the quadrant of a complex numbers with a conditional chain in a function with multiple return options. \n",
"\n",
"> [InsideSphere](InsideSphere.ipynb): Two way conditional in function and main program to test if a point is within a sphere.\n",
"\n",
"> [FunctionCall](FunctionCall.ipynb): Example with function calls if conditional tests, a bit tricky, but important concepts here.\n",
"> [InsideSphere](InsideSphere.ipynb): Two way conditional in function and main program to test if a point is within a sphere. \n",
"> [FunctionCall](FunctionCall.ipynb): Example with function calls if conditional tests, a bit tricky, but important concepts here. \n",
"\n",
"- ## File\n",
"\n",
...
...
@@ -38,7 +32,7 @@
"\n",
"> [WriteFile](WriteFile.ipynb): Writes a bit of text (and culture) to a file. (this write / overwrites \"burns.txt\").\n",
"\n",
"> [RangeLooptoFile](RangeLooptoFile.ipynb): Write data to a file from a a loop.\n",
"> [RangeLooptoFile](RangeLooptoFile.ipynb): Write data to a file from a loop.\n",
"\n",
"> [LineCount](LineCount.ipynb): Open a file and countv the number of lines (with error trap for wrong filename).\n",
"\n",
...
...
@@ -46,15 +40,22 @@
"\n",
"Data supplied\n",
"\n",
"> burns.txt\t\tA bit of culture !!! \n",
"> cosdata.txt\t\tOutput from RangeLooptoFile.py \n",
"> sample.txt\t\tData for Checkpoint 4 \n",
"> stones.jpg\t\tStones on Scottish beach \n",
"> [burns.txt](burns.txt): A bit of culture !!! \n",
"> [cosdata.txt](cosdata.txt): Output from RangeLooptoFile.py \n",
"> [sample.txt](sample.txt): Data for [Checkpoint 4](../Checkpoints/Checkpoint4.ipynb). \n",
"> [stones.jpg](stones.jpg):\tStones on Scottish beach. \n",
"\n",
"- ## Format\n",
"\n",
"Example Python programs to show formatted output.\n",
"\n",
"> [FloatFormat](FloatFormat.ipynb): Example of formatting floats with .format()\n",
"\n",
"> [IntegerFormat](IntegerFormat.ipynb): Example of specifying and printing int in various bases.\n",
"\n",
"- ## Functions\n",
"\n",
"\n",
"- Format\n",
"- Functions\n",
"- Further Functions\n",
"- Getting Started\n",
"- Lists\n",
...
...
%% Cell type:markdown id:52c89cc7 tags:
# Code Examples
The code examples are grouped together along certain themes. They can all be accessed below:
- ## Conditionals
Set of examples to demonstrate conditional statements (if elif else).
Take these and work / modify them and explore what happens:
> [OneWayConditional](OneWayConditional.ipynb): Simple one way (if) conditional.
> [TwoWayConditional](TwoWayConditional.ipynb): Simple two way (if else) conditional
> [TwoWayConditional](TwoWayConditional.ipynb): Simple two way (if else) conditional.
> [RootTwo](RootTwo.ipynb): Simply math.sqrt(x)**2 = x test to show the dangers of using test on floats; also the solution.
> [ThreeWayConditional](ThreeWayConditional.ipynb): Basic if elfi else structure, look at this carefully and understand it.
> [ComplexQuadrant](ComplexQuadrant.ipynb): Determine the quadrant of a complex numbers with a conditional chain in a function with multiple return options.
> [InsideSphere](InsideSphere.ipynb): Two way conditional in function and main program to test if a point is within a sphere.
> [FunctionCall](FunctionCall.ipynb): Example with function calls if conditional tests, a bit tricky, but important concepts here.
- ## File
Set of examples for reading and writing to simple text file.
> [ReadTextFile](ReadTextFile.ipynb): Read a text file and print out again (discussed "\n" problem with print()).
> [WriteFile](WriteFile.ipynb): Writes a bit of text (and culture) to a file. (this write / overwrites "burns.txt").
> [RangeLooptoFile](RangeLooptoFile.ipynb): Write data to a file from a a loop.
> [RangeLooptoFile](RangeLooptoFile.ipynb): Write data to a file from a loop.
> [LineCount](LineCount.ipynb): Open a file and countv the number of lines (with error trap for wrong filename).
> [ImageShow](ImageShow.ipynb): Read and display an image file using Matplotlib.
Data supplied
> burns.txt A bit of culture !!!
> cosdata.txt Output from RangeLooptoFile.py
> sample.txt Data for Checkpoint 4
> stones.jpg Stones on Scottish beach
> [burns.txt](burns.txt): A bit of culture !!!
> [cosdata.txt](cosdata.txt): Output from RangeLooptoFile.py
> [sample.txt](sample.txt): Data for [Checkpoint 4](../Checkpoints/Checkpoint4.ipynb).
> [stones.jpg](stones.jpg): Stones on Scottish beach.
- ## Format
Example Python programs to show formatted output.
> [FloatFormat](FloatFormat.ipynb): Example of formatting floats with .format()
> [IntegerFormat](IntegerFormat.ipynb): Example of specifying and printing int in various bases.