| Integers are numbers without a decimal point. Contrary to other programming languages,
they can be defined with leading zeroes and remember them. Examples:
a = 5
b = -4003
c = 000
d = 000005
To wheat your appetite, here is an example which takes away some things explained later,
but illustrates the point. Imagine you want to load 10 PDB files, named Model001 to Model010.
As a C programmer, you would type:
char filename[9];
int i;
for (i=1;i<=10;i++)
{ sprintf(filename,"Model%03d",i);
LoadPDB(filename); }
As a Python programmer, you save a lot and earn percents and a mysterious
'11':
for i in range(1,11):
LoadPDB("Model%03d"%i)
As a Yanaconda programmer, your life is easy:
for i=001 to 010
LoadPDB Model(i)
Floats are numbers with a decimal point and an optional exponent. If you specify an exponent or just a dot without decimal digits,
calculations will be done at maximum precision. Otherwise the result will be rounded to the number of digits after the decimal point.
Examples: |
a = 5.000
| A float with a precision of three decimal digits |
b = 4e0
| A float with maximum precision (4*10^0 = 4) |
c = 3.
| Just a dot without decimal digits also gives maximum precision |
d = -2.5e3
| A float with maximum precision (-2.5*10^3 = -2500) |
e = 7.345e-4
| Another float with maximum precision (7.345*10^-4 = 0.0007345) |
f = 0.0034
| A float with a precision of four decimal digits |
|
You already met some weak strings in the section about
explicit evaluators. They are called weak because of two reasons:
- Explicit evaluators inside the string are indeed evaluated.
- When a weak string is explicitly evaluated, it loses the single quotes.
Example:
a = 2
b = 3
# Assign '5' to MyWeakString
MyWeakString = '(a+b)'
Print 'Result is (MyWeakString)'
Result is 5
Note that the result is 5, not '5', not (a+b) and not
'(a+b)'. Strong strings are somehow complementary to weak strings:
- Explicit evaluators inside the string are ignored.
- When a strong string is explicitly evaluated, it keeps the double quotes.
Example:
a = 2
b = 3
MyStrongString = "(a+b)"
Print 'Result is (MyStrongString)'
Result is "(a+b)"
|