Today I learned some Python basics on how printing works, how variables works, and the different data types in python.
print()
- printing strings and variables that stored strings
- concatenating strings
- formatted strings
- escape sequence like
\n
,\t
and raw strings to skip escape - print numbers and result of expressions like add, sub, multiply, divide, power, etc
- printing lists and dicts
- separator and end arguments
- printing loops and range function
- string multiplication
- casting when combining strings and numbers
- use case of
print()
in debugging -
.format()
method
variables
- naming rules: letters or underscore, case-sensitive, no reserved keywords
- assigning values, multiple assignments
- unpacking sequence
- dynamically assigning values
- constant variables: uppercase, not truly immutable
Data types
- numbers
- string
- boolean
- none
- List (mutable, ordered)
- Tuple (immutable, ordered)
- Dictionary (key-value pairs)
- Set (unordered, unique)
- Frozenset (immutable set)
print()
has a lot more to it than just basic output (formatting, sep/end, debugging)
Top comments (0)