Getting ready
- You need to download workshop repository files and necessary materials to follow this course. Download instructions are present at the Etherpad here:
http://mzl.la/1Svh6Qx
Why Python?
- It’s free, well-documented, and runs almost everywhere
- Large (and growing) user base among researchers and scientists
- Easier for beginners to grasp
- Goal is to teach basic programming concepts that can be applied to other programming languages
Python Introduction
- Interpreted, dynamically typed, object-oriented very high-level language, compiles to bytecode
- Close to pseudocode, indentation marks block structure
- Popular for application development on its own
- Used as scripting language in many applications and games
Basics: Variables, types and Data Structures
- Introduction to Python variables
- Creating and assigning values to variables
- Types: Built-in types and type handling
- Built-in: String, integers, boolean and floating point
- type(val) returns the type of a variable (also classes)
- int(val[,base]) converts to an integer (of base base)
- float(val): Corresponding to floats
- str(val): Corresponding to strings (classes allow this automatically)
Lists in Python
- Lists as arrays
- Indexing and Slicing
Using Python libraries
- This introduction to Python is built around an end to end scientific example: data analysis
- What is a library (module) and its usage
- Reading data from a file
- Numpy arrays and operations on arrays of data
- Selecting individual values and subsections of data
- Plotting data using
matplotlib
library
Control Flow: Repeating actions with loops
- What a loop does?
- Writing loops to repeat simple calculations
- Track changes to a loop variable as the loop runs
- Track changes to other variables as they are updated by a
for
loop
Control Flow: Making choices
- Write conditional statements including
if
, elif
and else
- Evaluate expressions containing
and
and or
Creating Functions
- Defining a function, the parameters that it takes, return value
- Test and debug a function
- Scope of variables
- Set default values for function parameters
- Divide programs into small, single-purpose functions
Command-line Programs
- Using values of command-line arguments in a program
- Handling flags and files separately in a command-line program
- Reading data from standard input in a program
/ − will be replaced by the title