Closed valentineap closed 6 years ago
Thought: do you also want to introduce sets here? It might be a bit abstract at this point, but is a really useful type that often gets lost in intro courses.
Reviewed, added a simple exercise. The solution should be:
import numpy as np\\ d = {"color":["blue","green","red"],"proba":[0.0,2.0/3.0,1.0/3.0]}\\ d["results"]=np.random.choice(d["color"],size=90,p=d["proba"])
if I am right...
The example @charlesll added requires the use of np.random, which has not been introduced at this point. I think I would prefer to save this for a later exercise. I've therefore replaced this with a different example.
I've also added a brief section on sets (which I'm not that familiar with myself!) as suggested by @oscarbranson.
I think this is now ready for @rmcgirr94 ...
I note the link above is broken; click here for the exercise: https://github.com/valentineap/ComputationalGeoscienceCourse/tree/master/Practicals/Exercise%2005%20-%20Lists%2C%20tuples%20and%20dictionaries
Finished testing, some very minor additions (added a.values() to dictionary section and some annotations to the sets section) This was my first encounter with sets, so good to see this being introduced!
Ready for review.
https://github.com/valentineap/ComputationalGeoscienceCourse/tree/master/Practicals/Exercise%205%20-%20Lists%2C%20tuples%20and%20dictionaries
If anyone has bright ideas for another little example/exercise at the end of this, please add. I intend that Exercise 6 will deal with constructs of the form 'for x in list' etc.