100 Days of Python
Udemy
Angela Yu
Day 2
Data Types
- String, Int, Float, Boolean
- string[int] - Gets Nth char of a string, n starts at zero
- In #'s you can put underscores where commas might go
- 1,234,567 can be entered as 1_234_567
- Boolean True or False - always capitalized without quotes
- Can't concatenate int to string.
- type() function will give the type of what's in the parentheses
- python does lots of implicit conversions
Math Operators
- +, -, *, /, **
- division always results in float
- rules for precedence in python in this order:
- parantheses, exponents, (multiply, divide done Left to Right), (+, - done Left to Right)
Number Manipulation and F Strings
- round function can set number digits to round to, default is zero
- floor division (// rather than /) gives a truncated integer
- f strings used mostly in printing but works other places
- character f in front of the string, variables in curly braces.
- Don't have to convert everything to strings this way.