Content will go here.
Data Types
Built-In Data Types In Python
Name | Type | Description |
---|---|---|
Integer | int | Positive, negative, or zero whole number, e.g. 7 |
Floating point | float | Decimal value, e.g. 12.345 |
Boolean | bool | True or False value |
String | str | Immutable ordered sequence of characters, e.g. "Python!" |
Tuple | tuple | Immutable ordered sequence of objects, e.g. (3, 2.5, "cat") |
List | list | Mutable ordered sequence of objects, e.g. ("dog", 7, 9.2) |
Set | set | Unordered collection of distinct objects, e.g. {"a", "b", "c"} |
Dictionary | dict | Pairs of keys/values, e.g. {"name":"Bob", "age":42} |
Variables
Assignment Operators for Numeric Types
Operator | Description | Example (a=9, b=2) | Result |
---|---|---|---|
= | Assign a value | a=b | a has the value 2 |
+= | Add and assign | a+=b | a has the value 11 |
-= | Subtract and assign | a-=b | a has the value 7 |
*= | Multiply and assign | a*=b | a has the value 18 |
/= | Divide and assign | a/=b | a has the value 4.5 |
//= | Integer divide and assign | a//=b | a has the value 4 |
%= | Find remainder and assign | a%=b | a has the value 1 |
**= | Exponentiate and assign | a**=b | a has the value 81 |
Assignment Operators for Strings
Operator | Description | Example (s="abc") | Result |
---|---|---|---|
= | Assign a value | s="def" | s has the value "def" |
+= | Append and assign | s+="def" | s has the value "abcdef" |
*= | Repeat and assign | s*=2 | s has the value "abcabc" |