Overview
Dan Stanzione (TACC) (original author), Steve Lantz, Adam Brazier, Chris Myers
Cornell Center for Advanced Computing
Revisions: 5/2024, 7/2021, 8/2016, 10/2014, 2/2014, 3/2013, 6/2010 (original)
Python is a programming language designed with ease of programming and readable code as its foremost goals. Python has risen to prominence in scientific computing as an excellent tool for doing data conversions, scripting parameter studies, capturing complex algorithmic logic, and in general providing the “glue” to hook together many pieces of scientific workflows.
In this online course, a quick overview of the language is presented, along with a few tricks to improve the utility of Python for engineering and science modeling. Python naturally invites a “try it and see” approach, so mini-exercises are interspersed for practice.
This is not intended as a comprehensive syntax review for Python. Rather, it's enough to get started for beginners (with pointers to more detailed resources), plus a few hints for improvement once you make it out of the beginner phase. Although we will be learning Python on UNIX/Linux, nearly all of the Python language operates the same on Windows; this platform-independence is another contributor to Python's wider appeal.
Objectives
After you complete this workshop, you should be able to:
- Execute simple statements in a Python interpreter
- Create and run a Python script
- Use the basic variable types and do standard operations on them
- Manipulate strings
- Create conditional and loop constructs: if-else, for, while
- Use I/O functions to read and write to the command line or files
- Define classes and apply object-oriented programming concepts
- Work with modules, including ones from the Python standard library
- Distinguish between an interpreter and a compiler
- Explain the advantages of an ipython interpreter
- Name the modes in which Python can be used
- Run Python in interactive mode
- Run a saved Python program
Prerequisites
This workshop assumes the reader has no prior exposure to Python. A working knowledge of UNIX/Linux and general programming concepts is assumed. The target audience is scientists and engineers using high performance computing systems who wish to boost their productivity through the use of Python.