Name | Type | notes |
---|---|---|
Integers | int | Whole numbers etc |
Floating point | float | Numbers with decimal point |
[[Strings]] | str | Sequence of characters e.g.: "hello" 'Sammy' "2000" |
Lists | list | Order sequence of objects e.g.: [10, "hello",200.3] |
Dictionaries | dict | Unordered Key:Value pairs e.g.: {"mykey":"value", "name":"Frankie"} |
Tuples | tup | Ordered immutable sequence of objects e.g.: (10,"hello",200.3) |
Sets | set | Unordered collection of unique objects e.g.: {"a","b"} |
Booleans | bool | Logical values indicating True or False |
In order to declare an empty set you cannot do
thisSet = {}
. Python will read this as a dictionary type. Instead you must usethisSet = set()
.
Operator | Function | Example |
---|---|---|
+ | Add (integers or floating point) or concatenate (strings) | x+y |
- | Subtract | x-y |
* | Multiply | x*y |
/ | Divide | x\y |
% | Modulo - returns the remainder of a division | 7 % 4 returns 3 (7 divided by 4 gives 1 remainder 3) |
Operator | Function | Example |
---|---|---|
== | Is equal to | if x == y: |
!= | Is NOT equal to | if x != y: |
> | is greater than | if x < y: |
< | is less than | if x < y: |
>= | is great than or equal to | if x >= y: |
<= | is less than or equal to | if x <= y: |