Changes between Version 1 and Version 2 of ExpressionTour
- Timestamp:
- 06/20/10 04:12:38 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ExpressionTour
v1 v2 1 1 = Expression Tour = 2 2 3 This is a "tour" of various kinds of expressions in Cobra. It is not a reference manual for expressions, but is instead intended to help you learn Cobra.3 This is a "tour" of various kinds of expressions in Cobra. It is intended to help you learn Cobra by quickly highlighting some interesting expressions you can write. It is neither a reference nor an exhaustive list of features. It assumes that the reader has basic familiarity with programming. 4 4 5 5 == Displaying Expression Values == … … 16 16 17 17 You can, of course, use a [wiki:Print] statement. On a related note, you can validate the value of an expression with an [wiki:Assert] statement. 18 {{{ 19 #!python 20 print 'My name is', name 21 assert x > 0 22 }}} 23 24 == Arithmetic == 25 26 Arithmetic has the usual infix operators and parentheses for grouping. Note that division with a single slash (/) gives a fractional value. Use a double slash (//) for "integer" division. 27 {{{ 28 #!python 29 assert 4 / 5 = 0.8 30 assert 4 // 5 == 0 31 assert 6 / 5 == 1.2 32 assert 6 // 5 == 1 33 }}} 34 35 Augmented assignment operators can be used to change values: 36 {{{ 37 #!python 38 i += 1 39 p.x *= 2 40 }}} 41 42 Underscores can be put in numbers to separate groups of digits for easier reading: 43 {{{ 44 #!python 45 big = 10_000_000 46 }}}