13.07.2015 Views

Analysis of Structures - Baustatik-Info-Server

Analysis of Structures - Baustatik-Info-Server

Analysis of Structures - Baustatik-Info-Server

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1.3. PYTHON CALCULATOR Page 11Figure 1.10: Executing the HelloWorld.py Script and Console WindowSo, if we want to calculate the vertical position for an initial velocity v 0 = 5m/s after 0,6 seconds, wecan calculate the y(t = 0, 6) with one simple Python call.>>> print 5*0.6 -0.5*9.81*0.6**21.2342>>>A second version <strong>of</strong> the calculation can be performed introducing and using variables as follows. So wecan check every Python command within the Interactive Window.>>> v0 = 5>>> g = 9.81>>> t = 0.6>>> y = v0*t - 0.5*g*t**2>>> print y1.2342>>>A third version <strong>of</strong> our calculation <strong>of</strong> the ball’s height could be a Python script, which we can load andexecuted within the PythonWin IDE. To comment the code we insert some comments, which starts withthe # character. Characters at the right side <strong>of</strong> the # character are ignored by the Python interpreter.First small Example# program for computing the height <strong>of</strong> a ball thrown up in the airv0 = 5# initial velocityg = 9.81# acceleration <strong>of</strong> gravityt = 0.6# timey = v0*t - 0.5*g*t**2 # vertical positionprint y# printing the resultEnd <strong>of</strong> Coding2.12.2011

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!