← Indietro
Altro

Laboratory 3 Python

Altro di Molecular Modeling of Materials per il corso di Biomedical Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Molecular Modeling of MaterialsAltro

Informazioni sul documento

Cosa trovi in questo materiale

Altro di Molecular Modeling of Materials per il corso di Biomedical Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Qualità dell’importazione: il testo è stato estratto direttamente dal documento originale.

Contenuti estratti dal documento

Passaggi rappresentativi riconosciuti nelle diverse parti del materiale. Il testo completo resta presente nella pagina per la ricerca, mentre l’anteprima compatta rende più semplice la lettura.

Pagina 1

PYTHON INTRODUCTION (SEE ALSO JUPITER) In Python 3, the division of 2 integer with an integer result in obtained with the // symbol. After you explicitly import the math module. In addition, the cmath module should be imported to operate on complex numbers. The cm notation is a namespace, and it says to uses the square root function specifically imported from cmath . It is important because the generic sqrt function comes from the math library and it does not support complex numbers. Therefore, you need to use the cm.sqrt : specific for complex numbers. In general, in Python i twill be necessary to import several modules. In order to avoid problems, this AS notation must be used, necessary to understand where the function comes from. NumPy package is bigger the math. VARIABLES In Python you don’t need to specify the type of variable you are declaring. The function TYPE return the type of the variable. Python provides some functions to convert values. For example, you can declare b = ‘5’ as a string, but if you type int(b), it is converted in the numerical number five. The same using float and str for string. (it doesn’t work however). LISTS Is one type of data structures, often used, and can contain different type of items. It is an array of heterogeneous things, basically. (you can also have a list within a list) Very long lists could be CPU consuming. The indexing is done using square brackets. List[0] refers to the first element and -1 refers to the last one. Lists can also be sliced, for example if we define a listC = [‘A’, ‘B’, ‘C’, [1,2,3] ]. I can print only B, by specifying [1:2]. Note that those indexes are lying between the components of the list. So it is if like A has a pedix 1 on its right and same for B. Print(listC[1:2]) Print(listC[-1][1]) will print…

Anteprima

Prima pagina del documento.

Prima pagina: Laboratory 3 Python