|
@@ -14,7 +14,9 @@ An examples of an integer is `2` which is just a whole number.
|
|
|
|
|
|
Examples of floating point numbers (or *floats* for short) are `3.23` and `52.3E-4`. The `E` notation indicates powers of 10. In this case, `52.3E-4` means `52.3 * 10^-4^`.
|
|
Examples of floating point numbers (or *floats* for short) are `3.23` and `52.3E-4`. The `E` notation indicates powers of 10. In this case, `52.3E-4` means `52.3 * 10^-4^`.
|
|
|
|
|
|
-*Note for Experienced Programmers:* There is no separate 'long int' type. The default integer type can be a value of any length.
|
|
|
|
|
|
+Note for Experienced Programmers
|
|
|
|
+
|
|
|
|
+: There is no separate 'long int' type. The default integer type can be a value of any length.
|
|
|
|
|
|
## Strings
|
|
## Strings
|
|
|
|
|
|
@@ -67,11 +69,17 @@ If you need to specify some strings where no special processing such as escape s
|
|
|
|
|
|
This means that once you have created a string, you cannot change it. Although this might seem like a bad thing, it really isn't. We will see why this is not a limitation in the various programs that we see later on.
|
|
This means that once you have created a string, you cannot change it. Although this might seem like a bad thing, it really isn't. We will see why this is not a limitation in the various programs that we see later on.
|
|
|
|
|
|
-*Note for C/C++ Programmers:* There is no separate `char` data type in Python. There is no real need for it and I am sure you won't miss it.
|
|
|
|
|
|
+Note for C/C++ Programmers
|
|
|
|
+
|
|
|
|
+: There is no separate `char` data type in Python. There is no real need for it and I am sure you won't miss it.
|
|
|
|
+
|
|
|
|
+Note for Perl/PHP Programmers
|
|
|
|
|
|
-*Note for Perl/PHP Programmers:* Remember that single-quoted strings and double-quoted strings are the same - they do not differ in any way.
|
|
|
|
|
|
+: Remember that single-quoted strings and double-quoted strings are the same - they do not differ in any way.
|
|
|
|
|
|
-*Note for Regular Expression Users:* Always use raw strings when dealing with regular expressions. Otherwise, a lot of backwhacking may be required. For example, backreferences can be referred to as `'\\1'` or `r'\1'`.
|
|
|
|
|
|
+Note for Regular Expression Users
|
|
|
|
+
|
|
|
|
+: Always use raw strings when dealing with regular expressions. Otherwise, a lot of backwhacking may be required. For example, backreferences can be referred to as `'\\1'` or `r'\1'`.
|
|
|
|
|
|
### The format method
|
|
### The format method
|
|
|
|
|
|
@@ -137,7 +145,9 @@ Variables can hold values of different types called **data types**. The basic ty
|
|
|
|
|
|
Remember, Python refers to anything used in a program as an *object*. This is meant in the generic sense. Instead of saying 'the *something*', we say 'the *object*'.
|
|
Remember, Python refers to anything used in a program as an *object*. This is meant in the generic sense. Instead of saying 'the *something*', we say 'the *object*'.
|
|
|
|
|
|
- Note for Object Oriented Programming users:* Python is strongly object-oriented in the sense that everything is an object including numbers, strings and functions.
|
|
|
|
|
|
+Note for Object Oriented Programming users
|
|
|
|
+
|
|
|
|
+: Python is strongly object-oriented in the sense that everything is an object including numbers, strings and functions.
|
|
|
|
|
|
We will now see how to use variables along with literal constants. Save the following example and run the program.
|
|
We will now see how to use variables along with literal constants. Save the following example and run the program.
|
|
|
|
|
|
@@ -182,7 +192,9 @@ Then we add `1` to the value stored in `i` and store it back. We then print it a
|
|
|
|
|
|
Similarly, we assign the literal string to the variable `s` and then print it.
|
|
Similarly, we assign the literal string to the variable `s` and then print it.
|
|
|
|
|
|
-*Note for static language programmers:* Variables are used by just assigning them a value. No declaration or data type definition is needed/used.
|
|
|
|
|
|
+Note for static language programmers
|
|
|
|
+
|
|
|
|
+: Variables are used by just assigning them a value. No declaration or data type definition is needed/used.
|
|
|
|
|
|
### Logical And Physical Line
|
|
### Logical And Physical Line
|
|
|
|
|