Computational Physics Object Oriented Programming in Python
Computational Physics Object Oriented Programming in Python
Outline
What is Object Oriented Programming? Why design programs to be Object Oriented? Features of Object Oriented Programs Implementation in Python
Procedural Programming
Design emphasis is on setting up the logic of the program and its supporting functions.
? We can improve things if we structure the program to make use of functions to do things we do a lot.
Define or input the data you want to operate on.
? Write read and write functions ? Set up structures for the data
Generally, you need to know a lot about the procedures and the data structures to make use of the program or modify it.
Ultimately provide some output....
imimppoorrttnnuummppyyaassnnpp imimppoorrttmmaattpplolottlilbib.p.pyypplolottaassppll ddeeffffaalllilningg__bbaalll(lx(x00,v,v00,g,g,t,t):):
rreettuurrnnxx00++vv00**tt++00.5.5**gg**tt****22 ddeeffmmaainin()(:):
##sseettvvaarriaiabbleless xx00==110000.. vv00==00.. gg==99.8.8 tt==nnpp.a.arraannggee(1(10011.).) ##ddeeffnneeoouuttppuuttaarrrraayy xx==nnpp.z.zeerrooss(1(10011)) ##ccoommppuuttee ffoorri,it,tttinineennuummeerraattee(t(t):):
xx[i[]i]==ffaalllilningg__bbaalll(lx(x00,v,v00,g,g,t,ttt)) ##nnoowwddoossoommeetthhiningg,,lilkikeepplolott......ee.g.g.. ppl.lp.plolott(t(t,x,x)) mmaainin()()
Procedural Example
Define a function we'll call a lot.
Initialize variables (data) we need to do the calculation.
Set up a structure to hold the result. Note that we have to be careful about Making x the correct size.
Now do the calculation. Again we have to be careful to write our program so that things come out even.
Finally we want to do something with the result
Object Oriented Programming
Emphasis is on writing "objects" Objects contain data; data is maintained in a
structure Objects contain "methods" which operate on the
data. Objects have well defined ways to interface to
other objects and programmers. Individual Objects can belong to the same
"class" of objects. The same thing ... just different data and properties.
................
................
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
- object oriented programming
- object oriented python tutorial rxjs ggplot2
- computational physics object oriented programming in python
- object oriented design with python
- object oriented programming in python
- object oriented python an introduction
- python object oriented university of kentucky
- object oriented programming in python documentation
- course description
- laboratory manual for computer programming with python
Related searches
- object oriented programming in matlab
- matlab object oriented programming pdf
- object oriented programming tutorial pdf
- object oriented programming book pdf
- object oriented programming c pdf
- object oriented programming 2 pdf
- object oriented programming pdf download
- object oriented programming c book
- object oriented programming java examples
- object oriented programming language pdf
- object oriented programming python pdf
- c object oriented programming examples