Programming Essentials - Python Programming and Jupyter Notebooks (PE100)
Welcome to the Programming Essentials - Python Programming and Jupyter Notebooks component of the X-CITE training materials. The intent behind this unit is to show new CHESS users how to write programs in Python for experimental data analysis.
Prerequisites? None.
The training materials before you are designed both for scientists who may not have any programming experience whatsoever and for those who have at least some basic programming capability but in a language other than Python.
Python’s adoption has exploded in the last decade. Much of its success can be attributed to productivity. Many programming languages force the programmer to deal with very small details to do even the simplest things. Python’s attitude is to just take care of all the minutae so we don’t have to. On top of that, Python’s popularity has resulted in hundreds of thousands of packages of useful code for specific tasks. If there is something you need to write a program for, it’s almost definite that someone else has had the same problem. There’s a good chance at least one of those people neatly wrapped up some of their code and made it available in one of the repositories on the internet. There’s no reason for you to reinvent the proverbial wheel again - take advantage of their work (don’t forget to cite it!) and get back to doing actual science that much sooner.
You’re currently looking at PE100-01 Introduction. If you are new to Python and especially if you’re new to programming, you should work through each of the modules in order. More experienced programmers might benefit from skipping directly to topics that interest them. Select one of the following:
- PE100-02 Types, Variables, and Operators - the heart of any programming language.
- PE100-03 Decision Structures - conditional statements (“if” statements”) change the program flow.
- PE100-04 Repetition - “while” and “for” loops let us do things over and over.
- PE100-05 Functions - Python comes with a lot of functions, but we can write even more.
- PE100-06 Files - Reading input from and storing your results to disk.
- PE100-07 Exceptions - Dealing with unexpected contingencies.
- PE100-08 Lists - Another kind of variable, and the key to structuring data storage.
- PE100-09 Strings - More details on working with text.
- PE100-10 Dictionaries - Like a simple database, look up information quickly.