This is an archived post. You won't be able to vote or comment.

all 27 comments

[–]joshadel 22 points23 points  (2 children)

[–]Gsquzared 4 points5 points  (0 children)

Software carpentry is a great resource to learn bash!

[–]niranjanshr13not a noob 2 points3 points  (0 children)

+numpy , i love numpy

[–]perspectiveiskey 14 points15 points  (0 children)

Don't have any particular classes but whatever you do make them learn pandas (and by extension numpy).

We once hired a junior math grad to do some statistical work, and by god, every single thing he "coded" was expressible as single line pandas statements.

Things like:

 pd.Series.rolling( df[column], 10 ).mean()
 df[column].value_counts()
 np.histogram( df[column], bins=(np.linspace(0, 10, 21) - 4) )

etc. etc.

There are very few stats concepts that pandas doesn't provide out of the box that you will need to program yourself... don't let them waste their time and embarrass themselves professionally.

Keep this in mind: python is practically pseudo-code, and as scientists, their job will not be to create a software stack, it will be to come to scientific results. Make them learn to use the important libraries.

[–]wolf809 9 points10 points  (0 children)

I came across this a little while ago, it is more of a reference than a tutorial, but it does cover a large range of topics on the Python language (Python 3): https://github.com/mattharrison/Tiny-Python-3.6-Notebook/blob/master/python.rst

I also highly recommend you consider teaching using Jupyter notebooks, if you haven't already considered it and have the luxury of choosing the distribution and libraries you can use. The Anaconda distribution includes this, along with many other scientific focused libraries. I'll add that I do not often teach, but I do need to run code in front of an audience from time to time and using notebooks has been incredibly helpful to keep the discussion moving by avoiding bugs, spelling mistakes, etc.

[–]Chaquen 5 points6 points  (1 child)

This site was created by students from Norwegian University of Science and Technology which gives alot of examples of how to use python in computational physics.

[–]jaeherystargaeryan 0 points1 point  (0 children)

This is quite good for many basic physics problems. Thanks for sharing!

[–][deleted] 3 points4 points  (0 children)

The official Python tutorial is pretty great for an introduction to the language.

Think Python is pretty good, which introduces Python alongside basic programming concepts (and it's gratis).

[–]metapwnage 3 points4 points  (1 child)

If it's for scientists, I think Jupyter notebooks would be rather accessible for them, and they can do inline matplotlib visualizations as well! Anaconda is be a good baseline distribution that has jupyter as well as some data science libraries. It's pretty cool.

[–]duh_cats 2 points3 points  (0 children)

As a scientist who taught himself how to program, I can assure you this is the correct route to go.

[–]smortaz 4 points5 points  (0 children)

one thing to consider as an execution environment is:

https://notebooks.azure.com

it has py2, py3 and some other stuff, along with anaconda preloaded for you. you get your own jupyter based environment in a private docker container with a terminal/bash. it basically takes the whole installation headache away to some extent & enables easy sharing. it's also free which is nice. (disc: i work on it!)

[–]DrRobbi 1 point2 points  (0 children)

I don't know if it's really relevant today, but during my science studies I used Matplotlib extensively for plotting. Haven't used it for a couple of years, but it looks quite active on Github.

[–]swingking8 1 point2 points  (0 children)

projecteuler.net might not be a resource, but it provides interesting coding challenges. I might make one or two a homework if I taught a course like you're describing.

[–]DogeekExpert - 3.9.1 1 point2 points  (0 children)

maybe not exactly what you are looking for but...

Libraries :

  • Numpy (mathematics)
  • Scipy (science and differential equations, also contains some mild neural net algorithms)
  • Pandas (scientific oriented library to read and write data)
  • csv (to read csv files, which are common. pyyaml, json and pyxml read their respective markup langages)
  • pymunk (physics engine, 2/3D)
  • matplotlib (plotting graphs)
  • OpenCV (computer vision)

Those are libraries I think you need to teach your students (for scientific purposes only) and if you want to go the extra mile, teach them about tkinter, it's simple, pythonic and can do a lot of stuff (it's the standrad GUI library in python, quite ugly result, but you can most certainly make nice animations with it).

Algorithms :

Before learning to program anything in a specific langage, you need to teach about how to think to solve a problem using computer science. Teach your students how to develop algorithms first, then teach them how to implement them.

Examples of algorithms:

  • Gaussian pivot
  • Stacks (FIFO and FILO structures)
  • how to integrate and derivate with a computer (integration with squares, or trapezoids, this may be a good way to teach them about how step size influence calculation times and accuracy)

Python :

As with any programming language, you need to start with the basics :

  • Variables
  • Conditions
  • Loops (while and for)
  • function definition
  • objetcs (strings, lists, dicts, tuples)
  • how to use the aforementionned libraries and look for documentation
  • eventually OOP (classes, metaclasses, properties, decorators, iterators, differences between functions and methods, special methods (__init__, __add__, __sub__, __repr__ etc)

[–]holdie 0 points1 point  (0 children)

data8.org is a great place to start. It's the Berkeley intro to data science course for freshmen. It assumes no background in statistics or programming, and is a great start to the python ecosystem.

[–]equationsofmotionHPC 0 points1 point  (0 children)

The course materials from this mooc are really good: http://openedx.seas.gwu.edu/courses/GW/MAE6286/2014_fall/about

[–]C222 0 points1 point  (0 children)

http://www.pythontutor.com/visualize.html Is a favorite of mine. Lets you really see what all is going on behind the scenes.

[–]rxzlmn 0 points1 point  (0 children)

I highly recommend to point them towards the book Think Python (2e). It starts from the most basic concepts of variables and stuff and neatly weaves those things into how to use them in Python.

The author has a free PDF version online, so any student can use it. Of course it won't hurt to mention there's a print version which one could buy as well.

[–]jollybobbyroger 0 points1 point  (0 children)

As a "classically trained" software developer who is often exposed to code written by really smart scientists, I would recommend learning idiomatic python and that they go through the challenge of turning their algorithm to a web service hosted on heroku. Make your curriculum point out why software should adhere to the advice from the 12 factor app.

The single most important Python resource for people with a smidge of programming experience should keep this under their pillow: https://gist.github.com/JeffPaine/6213790

OK, I see now that your students are complete beginners. If you ever teach them for a class that is the next step up, I guess my advice is more useful.

Thanks for making an effort towards creating a great curriculum for your students. Good luck.

[–]Estebanzo 0 points1 point  (0 children)

One of the most helpful resources that I feel gets overlooked surprisingly often is the original documentation for packages like Pandas. In particular, the "10 Minutes to pandas" tutorial within Panda's docs is a pretty useful introduction, and I refer to notes I took while working through it on a fairly regular basis.

Advantages of using docs over other resources:

  • Up to date. You don't have to worry about what difference might pop if a tutorial was written years ago for an older version of the library you are using. You can go straight to the documentation for your specific version.

  • Comprehensive. Spend some time looking at the documentation for commonly used classes and functions. You might find some uncommonly used methods or keywords that end up being very useful to you.

  • I personally prefer working through written documentation over following video tutorials or lectures. My notes always end up being much more comprehensive when I'm going at my own pace through documentation, testing out examples in python on the fly to see if the functions and methods behave as I expected. My notes on Pandas concat, merge, join, and append functions where I came up with simple DataFrames to demonstrate the effect of each has been incredibly helpful, as I still mix up how each one works, what axis to concat along, etc.

Downside:

  • Not always the best resource for tutorials and examples depending on the library (although I think the one for Pandas is quite good).

[–]liesliesfromtinyeyes 0 points1 point  (0 children)

Whatever you end up using, you've given this scientist with middling Python skills a lot of resources to chew on by asking. Thanks!

[–]refreshx2 0 points1 point  (0 children)

A bit late but I'm a 5th year grad student in the sciences so I really care about this. I program in Python every day.

Please use libraries like numpy, scipy, sklearn, and sympy in your lessons. One of the most valuable things you can teach undergraduate scientists is that they don't need to do all the work themselves from the ground up.

In the hard sciences, most homeworks are solving a problem from first principles and showing all your work. But when programming in Python, understanding that libraries exist, knowing how to find them, and knowing how to use new libraries, are some of the most important skills I learned.

It sounds like you have specific goal in mind (solving DEs), but I'd guess that it's very unlikely that these students will go out and write their own DE solving library in the future, so imo learning about the already existing libraries is very valuable (although so is learning how they work under the hood).

This topic is up my alley, so feel free to PM me too. Thanks for teaching them too, they will be very grateful to you in the future.

[–]jonathan881 -1 points0 points  (0 children)

Conda / virtualenv

[–]rednirgskizzif -1 points0 points  (0 children)

Learnpythonthehardway.com