Programs are composed of modules
Modules contain statements
Statements contain expression
Expression create and process objects
Everything we process is a kind of object.
1. numbers
2. strings
3. lists
4. dictionaries
5. tuples
6. files
7. sets
8. other core types: booleans,types,none
9.program unit type:functions,modules,classes
10. implementation-related types: compiled code,stack trackback
Python is dynamically typed, a model that keeps track of types for you automatically instead of requiring declaration code, but it is also strongly typed,a constraint that means you can perform on an object only operations that are valid for its type.
sets: &:intersection
|:union
- difference
set comprehension {n ** 2 for n in [1, 2, 3, 4]}
Even less mathematically inclined programmers often find sets useful for common tasks
such as filtering out duplicates, isolating differences, and performing order-neutral
equality tests without sorting—in lists, strings, and all other iterable objects:
Sets also support in membership tests, though all other collection types in Python do
too:
'p' in set('spam'), 'p' in 'spam', 'ham' in ['eggs', 'spam', 'ham']
(True,True,True)
fraction(rational numbers with both a numerator and a denominator)
from fractions import Fraction # Fractions: numerator+denominator
>>> f = Fraction(2, 3)
>>> f + 1
Fraction(5, 3)
>>> f + Fraction(1, 2)
Fraction(7, 6)
decimal(fixed-precision)
import decimal # Decimals: fixed precision
>>> d = decimal.Decimal('3.141')
>>> d + 1
Decimal('4.141')
User-Defined Type:class