jagomart
digital resources
picture1_Python Pdf 185000 | Oop Item Download 2023-02-01 11-55-02


 122x       Filetype PDF       File size 0.67 MB       Source: people.astro.umass.edu


File: Python Pdf 185000 | Oop Item Download 2023-02-01 11-55-02
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 ...

icon picture PDF Filetype PDF | Posted on 01 Feb 2023 | 2 years ago
Partial capture of text on file.
                 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....
       import numpy as np
        import numpy as np                                     Procedural
       import matplotlib.pyplot as pl
        import matplotlib.pyplot as pl
       def falling_ball(x0,v0,g,t):                               Example
        def falling_ball(x0,v0,g,t):
            return x0 + v0*t + 0.5*g*t**2
             return x0 + v0*t + 0.5*g*t**2
       def main():                                             Define a function we'll call a lot.
        def main():
            # set variables
             # set variables
            x0 = 100.                                          Initialize variables (data) we need to
             x0 = 100.
            v0 = 0.                                            do the calculation.
             v0 = 0.
            g = 9.8
             g = 9.8                                           Set up a structure to hold the result.
            t = np.arange(101.)
             t = np.arange(101.)                               Note that we have to be careful about
            # defne output array                               Making x the correct size.
             # defne output array
            x = np.zeros(101)
             x = np.zeros(101)
                                                               Now do the calculation.  Again we have
            # compute                                          to be careful to write our program so
             # compute
            for i,tt in enumerate(t):                          that things come out even.
             for i,tt in enumerate(t):
                 x[i] = falling_ball(x0,v0,g,tt)
                  x[i] = falling_ball(x0,v0,g,tt)              Finally we want to do something with 
            # now do something, like plot... e.g.              the result
             # now do something, like plot... e.g.
            pl.plot(t,x)
             pl.plot(t,x)
        main()                                         
        main()
The words contained in this file might help you see if this file matches what you are looking for:

...Computational physics object oriented programming in python outline what is why design programs to be features of implementation procedural emphasis on setting up the logic program and its supporting functions we can improve things if structure make use do a lot define or input data you want operate write read set structures for generally need know about procedures modify it ultimately provide some output import numpy as np matplotlib pyplot pl def falling ball x v g t example return main function ll call variables initialize calculation hold result arange note that have careful defne array making correct size zeros now again compute our so i tt enumerate come out even finally something with like plot e...

no reviews yet
Please Login to review.