- Introduction to Python Data Types
- Number
- Integers
- Floating Point
- E.g. Numbers with a decimal point: 1.12
- Modulo or "Mod" Operators
In: 7%4
Out: 3
In: 2 ** 3
Out: 8
- Strings
- The ordered sequence of characters: “hello”, “2000”
- Indexing and slicing to grab sub-section of the string
- Indexing notation uses [ ] notation after the string (or variable assigned the string)
- Allow to grab a single character from the string
mystring = "Hello World"
mystring[-2]
Out: l
- Slicing allows to grab a subsection of multiple characters, a “slice” of the string
- Has the following syntax: [start:stop:step]
- Start is a numerical index for the slice start
- Stop is the index you will go up to
- Step is the size of the “jump” you take
mystring = "abcdefghijk"
mystring[2:7:2]
Out: 'ceg'
- Booleans
- Logical value indicating True or False
- Examples:
- 2 > 3 is False
- 3 <= 2 is False
- 3.0 == 3 is True