Coder Social home page Coder Social logo

cambridgeengineering / partia-computing-michaelmas Goto Github PK

View Code? Open in Web Editor NEW
148.0 10.0 208.0 5.87 MB

Activities and exercises for the Part IA computing course in Michaelmas Term

Jupyter Notebook 100.00%
python educational-materials scientific-computing part-1a jupyter-notebook

partia-computing-michaelmas's Introduction

Introduction to computing with Python for engineering and scientific applications

These Jupyter notebooks provide a self-study introduction to computing with Python. They have been developed for the computing course in Part IA (Michaelmas Term) of the Engineering Tripos at University of Cambridge. This is a first computing course for undergraduate students.

The notebooks can be freely used, shared and modified. See the copyright and license notice below.

Viewing and running

Open In Colab

Cambridge users should use their University credentials (CRSid) to log in.

Getting started

Each notebook covers a topic, with a number of exercises for completion at the end of each notebook. Start with the notebook Part IA Michaelmas Term computing. Model solutions to the exercises are available - contact Garth N. Wells to request the solutions.

Cambridge students/staff: When prompted to sign in to the Google Colaboratory service, use your University of Cambridge email address, e.g. [email protected].

Accompanying exercises

For each notebook there are a set of exercises in the directory Exercises for completion at end the of each Activity notebook.

Feedback and corrections

These notebooks are maintained at https://github.com/CambridgeEngineering/PartIA-Computing-Michaelmas. Please report suggestions or errors at:

https://github.com/CambridgeEngineering/PartIA-Computing-Michaelmas/issues

Author

These notebooks are developed by Garth N. Wells (@garth-wells, [email protected]).

Acknowledgements

Valuable feedback during the development of the notebooks was provided by Quang T. Ha, Hugo Hadfield, Tim Love, Chris Richardson and Joanna Stadnik.

License and copyright

All material is copyright of Garth N. Wells ([email protected]).

All text is made available under the Creative Commons Attribution-ShareAlike 4.0 International Public License (https://creativecommons.org/licenses/by-sa/4.0/legalcode).

All computer code is released under the MIT license.

The MIT License (MIT) Copyright (c) 2016-2022 Garth N. Wells

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

partia-computing-michaelmas's People

Contributors

ahgee2 avatar filip-cermak avatar garth-wells avatar tomwyllie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

partia-computing-michaelmas's Issues

Notebook 9 - comments and typos

"There are two types of program errors: syntax errors and exceptions" - using the word "exceptions" here (rather than "run-time errors") leads to awkward discussions when talking about error-handing and languages more generally - e.g. "If the language you're using doesn't support exceptions you'll have to deal with exceptions by returning special values.

"guard against easy-to-detect to errors" -> "guard against easy-to-detect errors"

"This help detect errors that might inadvertently creep in to a program" -> "This helps detect errors that might inadvertently creep into a program"

"Try changing one of the check" -> "Try changing one of the checks"

Scope issues

Issues regarding scope are made more confusing by the notebooks. Sometimes the code in a cell only worked because of a variable that had by chance been set in an earlier cell. I don't know what to do about that; insist that each solution works in a self-contained cell?

Small Typo in Notebook 3

Hate to be pedantic but I believe there is a small typo in the third code box in the section 'Strings' in Notebook 3.
Here is what is written

# Get first six characters, print and check type
s3 = my_string[0:6]
print(s3)
print(type(s2))

# Get last four characters and print
s3 = my_string[-4:]
print(s3)

The line print(type(s2)) (line 4) I think it should be print(type(s3)) . Whilst both yield the same output the new line actually checks the type of s3.

End of Notebook 4

At the End of Notebook 4 there's an "Optional extension" heading but nothing after

Typos in Exercise 08.1

In Exercise 08.1 (function plotting):

Consider the function
f(x) = e(x/10) sin⁡(ω2x) cos⁡(ω1x) [formula edited for readability on GitHub]
from x = −4π to x = 4π.

Above there are references to ω1 and ω2.

But later in the task description:

  1. Plot the function when ω0 = ω1 = 1. Label the axes.
  2. Create an interactive plot with sliders for ω0 and ω1, varying from 0 to 2.

I assume that ω1 in the first section means ω0 in the numbered list, and similarly for ω2 and then ω1?

11.1 clarification

"Determine by operating counting ..." typo? In any case, it's confusing. Maybe "Determine by counting the number of mathematical operations performed"

07.02 clarification

"Modify your function for the min, max and mean to optionally exclude the highest and lowest score" - several students wrote a function that asked the user interactively whether they wanted to exclude the highest and lowest scores. Yuck, but the wording of the question allows that solution

Typo error in Exercise 07.2?

Should

A function that takes a NumPy array of the raw scores and returns the scores as a percentage sorted from lowest to highest (try using scores.sort(), where scores is an Numpy array).

instead read

A function that takes a NumPy array of the raw scores and returns the scores as a percentage sorted from lowest to highest (try using numpy.sort()).

scores.sort() does not seem to work but numpy.sort() does.

Expand material on complexity analysis

Some students struggled in 2016 with the algorithmic complexity analysis. Expand material, either in the notebook or create some supplementary material.

Exercise 07.3: Clarify transpose question

The text of Exercise 07.3 indicates that array slicing should be used to compute the transpose, whereas the intention is that a function should be used. The question text should be clarified.

Some features that could be removed

  • Decorators

  • %time - a mysterious feature for which there's a more general and easily understood alternative (even if the results might not be as good)

import time
start_time = time.time()
print("hello")
end_time = time.time()
print("Time taken=",end_time - start_time)

  • list comprehensions - because they're not easily transferable to other languages, and they're guessed/borrowed without being understood

12.2 clarification

This was commonly misunderstood. Many students performed a sort in the lt method and called it explicitly. One user created an It [sic] method and called it explicitly (she called it It (that's a capital I) because it involved Iteration). repr was often called explicitly too. Even those who realised that sort used lt sometimes thought that they needed to create gt and eq too. If the topic's going to be dealt with I think the explanation needs to be far longer - or links to appropriate tutorials provided

Minor notes

I stumbled upon your notebooks as I have enrolled in an edge EDX course on data science on the built environment.

I originally didn't realize it wasn't from the course author, so I had taken some detailed notes in an attempt to be helpful. I think they could still be useful though :)

I am an experienced python coder, but I did skim through each of the notebooks (I skipped most of the exercises though). IMHO it looks like it'd indeed make a good introduction for beginners! Good stuff!

Couple of (very) small remarks:

  • 01 Variables and assignment and operator precedence.ipynb has a typo:

"Languages have rules for what charcters can be used in variable names"

"Languages have rules for what charcters can be used in variable names. As a rough guide, in Python variable names can use letters and digits, but cannot start with a digit.\n",

  • 02: print(10 < 9 or 15 < 20). Similar to the previous operator precedence notebook I'd prefer print((10 < 9) or (15 < 20)) to make it completely unambiguous what's happening.

  • 03: I really liked the "Example: inexact representation", very powerful demonstration of roundoff errors.

  • Early on, I would probably mention help(function) and the notebook equivalent function?. This is an invaluable tool to quickly know what a function does, and its arguments, without having to go check online. It would fit well in the "Library functions" notebook for eg, or even before the first time you mention that range doesn't include end. range? => range(start, stop[, step]) -> range object

  • 08:

    • RuntimeError: Unable to install quandl. On the other hand, !pip install quandl shows its already fine. Might be confusing a bit. Wrap that in a try: import quandl like you do in 09 instead.
    • I would probably mention fig, ax = plt.plot(...). I would probably mention ax.axhline / ax.axvline which is often useful to annotate a graph, include limits etc.
    • Pie charts? Really? :)
  • 09, USS Yorktown Smart Ship: image broken.

  • 11: complexity and timings against libraries. True, numpy probably has good heuristics to avoid worse case complexity. It's also coded in Cython checking types (https://github.com/numpy/numpy/blob/464f79eb1d05bf938d16b49da1c39a4e02506fa3/numpy/core/src/npysort/quicksort.c.src)... (np.sort? will also show you that it takes a 'kind' argument to use something else than quicksort, edit: You do use it in 12 actually). This is just a side note, I realize this is aimed at beginners.

    • Using Jupyter (or IPython) you can use 'tab-completion' to see the available attributes and methods. You will often know from the name which one you need. Perhaps that should be mentionned in one of the first notebooks (and completing existing variable names)
  • 12: very minor: you mention __repr__ but not __str__. There's a difference, and technically __repr__ isn't called when print if __str__ is defined... https://stackoverflow.com/questions/1436703/difference-between-str-and-repr

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.