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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.6. CODE BLOCKS Page 21The last data type used in Python is a string consisting <strong>of</strong> one or more characters.The data type <strong>of</strong> a variable can be determined using the build in function type, as shown in the followingexample. Within a first step different variables were created by a simple assignment. The content <strong>of</strong> thevariable determines the type <strong>of</strong> the variable, no explicit declaration is needed or available, like in C. Afterhaving created the variables the type <strong>of</strong> the variables will be determined by subsequent type calls.To check the data type within a program the following tests can be made.1. if type(d).__name__ == ’int’You can check the type with the types __name__ member.2. if type(d) == int... or you can check the type with the type class name (discussed later).>>> a = 2>>> b = 3L>>> c = 4.5>>> d = 6 + 7j>>> e = "Hello World">>> type (a)>>> type (b)>>> type (c)>>> type(d)>>> type(e)You see, ’int’ is integer, ’long’ is long integer, ’float’ is float, ’complex’ is complex and’str’ is string data type.Furthermore there are some sequences in Python available, which combines the mentioned data types ina more or less sophisticated mode. More about that later.2.6 Code BlocksOne very imported feature <strong>of</strong> Python is, that code blocks are bracketed by an unique indent. The mostprogramming languages uses there specific code parenthesis. There is one opening parenthesis whichstarts the code block and there is one closing parenthesis, which closes the code block.The following example shows a code block in C.if (a > b){c = a + bd = a - bFurther Lines <strong>of</strong> C-Code}2.12.2011

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

Saved successfully!

Ooh no, something went wrong!