12.010 Computational Methods of Scientific Programming
12.010 Computational Methods of Scientific Programming
Lecturers Thomas A Herring
Chris Hill
Overview
? Part 1: Python Language Basics ? getting started. ? Part 2: Python Advanced Usage ? the utility of Python
11/15/2011
12.010 Lec P2
2
Refresh
? Previous class:
? History ? Python features ? Getting Python and help ? Modes of running Python ? Basics of Python scripting ? Variables and Data types ? Operators ? Conditional constructs and loops
11/15/2011
12.010 Lec P2
3
Part 2: Advanced Python
? Today we will look at:
? Functions ? Modules ? File IO ? Time ? Exceptions ? Parsing command line options/arguments ? CGI programming ? Database access ? Math Modules numpy and scipy ? Graphics with python matplotlib
11/15/2011
12.010 Lec P2
4
Functions
? A function is a block of organized, reusable code that is used to perform a single, related action. Functions provides better modularity for your application and a high degree of code reusability.
? As you already know, Python gives you many built-in functions like print() etc. but you can also create your own functions. These functions are called user-defined functions.
? Here are simple rules to define a function in Python:
? Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).
? Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.
? The first statement of a function can be an optional statement - the documentation string of the function or docstring.
? The code block within every function starts with a colon (:) and is indented.
? The statement return [expression] exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return None.
11/15/2011
12.010 Lec P2
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- 12 010 computational methods of scientific programming
- developer study guide bluetooth
- tkinter 8 5reference aguifor python
- introduction to network programming with python
- python cheat sheet programming with mosh
- raspberry pi pico python sdk
- implementing micropython as a uefi test framework
- python software carpentry
- installing pynomo on a windows machine
- keyboard input using directinput
Related searches
- educational methods of teaching
- methods of monitoring and evaluation
- methods of teaching pdf
- methods of analysis data
- methods of financial statement analysis
- instructional methods of teaching
- different methods of education
- teacher methods of teaching
- different methods of problem solving
- best scientific programming languages
- scientific programming language
- scientific programming languages ranking