Introduction to Python for Computational Physics
Introduction to Python for Computational Physics
Prof. Brian D'Urso
University of Pittsburgh Department of Physics and Astronomy
Week 1
PHYS 1321
Introduction to Python
What is Python?
PHYS 1321
A high-level language. Built-in high level data structures. Object oriented.
An interpreted language. You don't compile your programs. Exception framework with tracebacks (no segmentation faults). Automatic memory management (no malloc or free). Dynamic typing, dynamic binding.
Huge standard library with all sorts of functionality.
Extensible and embeddable.
Cross platform and free.
Great as both a scripting/glue language and for full-blown application development.
Introduction to Python
Installation
Lab computers have the software pre-installed in Windows. If you want to use your personal machine:
Mac Install Parallels Desktop: Install Windows and follow installation below.
Windows Python, libraries, and related utilities. Download and install pythonxy - Windows only! see
Linux/Mac OS: Download and compile/install the packages.
PHYS 1321
Introduction to Python
Running Python
PHYS 1321
There are many ways Python can be used: Interactively: Run the python program with no arguments and get:
Introduction to Python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" ... >>>
Useful for tests, debugging, and for demonstrations. This is where we'll start today.
Non-interactively: Write a script (a text file) and run it. Used for programs with more than a line or two.
The program
What is a program?
A sequence of instructions to the computer, written in a programming language, which is somewhat like English, but very much simpler ? and very much stricter!
In this course we shall use the Python language
Our first example program:
Evaluate
y (t)
=
v0t
-
1 2
gt
2
for
v0
=
5,
g
=
9.81
and
t
=
0.6:
y
=
5
?
0.6
-
1 2
?
9.81
?
0.62
Python program for doing this calculation:
print 5*0.6 - 0.5*9.81*0.6**2
................
................
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
- scientific and mathematical computing using python
- pandas format numbers with commas
- s e c t i o n 2 4 p o w e r f u l o u t p u t f o r m
- numbers lists and tuples
- str s format method for introduction to programming using
- python course rutgers university
- introduction to python university of pennsylvania
- programming in python 3 smu
- using python in labeling and field calculations esri
- formatting numbers with c output streams
Related searches
- introduction to financial management pdf
- introduction to finance
- introduction to philosophy textbook
- introduction to philosophy pdf download
- introduction to philosophy ebook
- introduction to marketing student notes
- how to cite introduction to sociology 2e
- introduction to matlab for engineers pdf
- introduction to matlab for engineers
- introduction to python pdf
- introduction to python programming pdf
- python how to ask for user input