Code_Aster, Salome-Meca course material
GNU FDL licence (http://www.gnu.org/copyleft/fdl.html)
Use of Python in the command file
2 - Code_Aster and Salome-Meca course material GNU FDL Licence
Outline
Python basis
Simple use of Python in the Code_Aster command file
Advanced use of Python
3 - Code_Aster and Salome-Meca course material GNU FDL Licence
Python basis
Some words about Python
Simple to use
Interpreted programming language, portable
Object Oriented
Free and Open Source
Widely used for scientific computing (many modules available)
4 - Code_Aster and Salome-Meca course material GNU FDL Licence
Python basis
Structure of a Python program
No type declaration. Variables directly affected by the sign =
b = 12.2
a = 4. * b + 2.
Code blocks indicated by indentation uniform (important)
i = 0
while i <10:
print i
i = i + 1
print 'finished'
Case sensitive
Mesh is different from MESH
Comments preceded by #
Reserved keywords
and, assert, break, class, continue, def, del, elif, else,
except, exec, finally, for, from, global, if, import, in, is,
lambda, not, or, pass, print, raise, return, try, while
5 - Code_Aster and Salome-Meca course material GNU FDL Licence
Python basis
Numbers
Integers and division
-1, 0, 4
>>> print 1/2 #return 0
Real, complex
0., 1.618, 6e23, 5.39e-44, 1+2j
Operations
+, -, *, /, **
Strings
Examples
>>> text=‘hello world’
Concatenation
>>> text=‘he’+’llo
Conversions number/text and text/number
>>> str(3)
>>> int(‘537’) ; float(‘3.14’)
1 / 19 100%
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !