Week 5 subject 1: Numbers (cont.)
- Floating point numbers are numbers with decimal points
- Floating point operations
- Same as integers
- % and // also works for floats!
- Type conversion from int to float
- Automatic and manual conversion with float()
- Never compare if floats are equal!
Week 5 subject 2: Lists
- List is a Python advance data type.
- There are list variables and list literals.
- List is an ordered set of objects, can be of different types.
- List elements can be accessed with subscripts (which makes Lists iterables), subscript ranges start at 0.
- You can have lists as elements of lists. Note one data element is different from one list with only one data element. Example: “abc” is different from [“abc”].
- Operating Lists: accessing elements with index, .append(), del, .pop(), .remove() (note they have different syntax).
- Slicing: [begin:end:step], omitting begin or end, negative step
No comments:
Post a Comment