Scientific Programming — Syllabus

taxidermistplateSoftware and s/w Development

Nov 7, 2013 (3 years and 9 months ago)


Alberto Paoluzzi

Scientific Programming

12 CFU


The main objective of this course is to teach programming skills and computational
thinking. Some programming skill is needed in all areas of science and engineering,
although very different programming
languages are used. The second is perhaps even
more important, as it influences how you go about solving a problem.

uses the programming language Python, that was designed to be easy to
learn. Python is used by many universities worl
wide for teaching introductory
programming. It is free, open
source, and multi


Every paragraph correspond to a week of either lectures or lab work (25%). It is supposed
that the students already have some small programming experience,
maybe in a College

Introduction to programming

The Python programming language: Python: multi
paradigm language with efficient built
data structures and simple/effective approach to OO programming. Python’s elegant
syntax and dynamic typing, and

its interpreted nature, make it ideal for scripting and RAD.
Installing Python. Command
line interface, Unix
like operating system commands.
Compilers and interpreters. The first Python programs.

Variables, expressions, statements, functions

Values and ty
pes, Variables, Variable names and keywords, Statements, Operators and
operands, Expressions, Order of operations, String operations, Comments. Function calls,
Type conversion functions, Math functions, Composition, Adding new functions, Definitions
and us
es, Flow of execution, Parameters and arguments, Variables and parameters are
local, Stack diagrams, Fruitful functions and void functions, Why functions?

Python modules and packages (Lab)

Pytrhon scripts, A module is a file containing Python definitions a
nd statements, definitions
from a module can be imported into other modules or into the main module, Packages are
a way of structuring Python’s module namespace by using “dotted module names”.
Expression in terms of a hierarchical filesystem. Useful module

Control flow, conditionals and iteration

Modulus operator, Boolean expressions, Logical operators, Conditional execution,
Alternative execution, Chained conditionals, Nested conditionals, Recursion, Stack
diagrams for recursive functions, Infinite recur
sion, Keyboard input, Multiple assignment,
Updating variables, The while statement, break, Square roots, Algorithms

Strings and lists

A string is a sequence, len, Traversal with a for loop, String slices, Strings are immutable,
Searching, Looping and count
ing, string methods, The in operator, String comparison, A
list is a sequence, Lists are mutable, Traversing a list, List operations, List slices, List
methods, Map, filter and reduce, Deleting elements, Lists and strings, Objects and values,

es and dictionaries

Tuples are immutable, Tuple assignment, Tuples as return values, Variable
argument tuples, Lists and tuples, Dictionaries and tuples, Comparing tuples, Sequences
of sequences, Dictionary as a set of counters, Looping and dictiona
ries, Reverse lookup,
Dictionaries and lists, Memos, Global variables, Long integers

Programming with Files

Persistence, Reading and writing, Format operator, Filenames and paths, Catching
exceptions, Databases, Pickling, Pipes, Writing modules

n to image processing (Lab)

The Python Imaging Library (PIL) adds image processing capabilities to your Python
interpreter. This library supports many file formats, and provides powerful image
processing and graphics capabilities. Converting files to JPEG,

Splitting and merging color
bands, Geometrical Transforms, Colour Transforms, Image Enhancement: Filters, Point
Operations. Image Sequences.

Classes and objects, functions, methods

defined types, Attributes, Rectangles, Instances as return values, Ob
jects are
mutable, Copying, Time, Pure functions, Modifiers, Prototyping versus planning,
Debugging. Object
oriented features, Printing objects, Another example, A more
complicated example, The init method, The str method, Operator overloading, Type
dispatch, Polymorphism

Graphical User Interfaces (Lab)

TurtleWorld, Simple repetition, Encapsulation, Generalization, Interface design,
Refactoring, A development plan, docstring, GUI, Buttons and callbacks, Canvas widgets,
Coordinate sequences, More widge
ts, Packing widgets, Menus and Callables, Binding

Numerical Python

NumPy is the fundamental package needed for scientific computing with Python. It
contains among other things: a powerful N
dimensional array object, sophisticated
(broadcasting) functions,
tools for integrating C/C++ and Fortran code, useful linear
algebra, Fourier transform, and random number capabilities. Besides its obvious scientific
uses, NumPy can also be used as an efficient multi
dimensional container of generic data.
Arbitrary data
types can be defined. This allows NumPy to seamlessly and speedily
integrate with a wide variety of databases.

Scientific Python

SciPy is the package for mathematics, science, and engineering. The SciPy library is built
to work with NumPy arrays, and provi
des many user
friendly and efficient numerical
routines such as routines for numerical integration and optimization. Together, they run on
all popular operating systems, are quick to install, and are free of charge. NumPy and
SciPy are easy to use, but pow
erful enough to be depended upon by some of the world’s
leading scientists and engineers.

Introduction to geometric programming (Lab)

PyPlasm is the package for Multidimensional Geometric Programming at Function Level,
to work with points, curves, surfaces
, solids and higher
dim manifolds. Domain:
Hierarchical polyhedral complexes. Representations: BSP trees, Polytopes, Hasse graphs.
Geometric operators: Affine maps, Hierarchical structures, Boolean Ops, Cartesian
products, Minkowski sums, Charts and atlase
s, d
Skeletons, 0 ≤ d ≤ n, Convex hulls,
Domain integrals of polynomials



Allen B. Downey,
Python for Software Design: How to Think Like a Computer
, Cambridge University Press, Marc
h 2009


Jennifer Campbell, Paul Gries, Jason Montojo, and Greg Wilson,
Programming: An Introduction to Computer Science Using Python
, Pragmatic Bookshelf,
May 200