Python 1
Contents
小孩子才做选择！
图片来源：https://mp.weixin.qq.com/s/crkjqbV5ljerVKMXVegUYA。
Variables, Names, and Objects
In Python, everything—booleans, integers, floats, strings, even large data structures, functions, and programs—is implemented as an object. This gives the language a consistency (and useful features) that some other languages lack.
The type also determines if the data value contained by the box can be changed (mutable) or is constant (immutable). Think of an immutable object as a closed box with a clear window: you can see the value but you can’t change it. By the same analogy, a mutable object is like an open box: not only can you see the value inside, you can also change it; however, you can’t change its type.
if you want to know the type of anything (a variable or a literal value), use type()
. In Python, “class” and “type” mean pretty much the same thing.


Variable names can only contain these characters. Names cannot begin with a digit.
 Lowercase letters (a through z)
 Uppercase letters (A through Z)
 Digits (0 through 9)
 Underscore (_)
Finally, don’t use any of these for variable names, because they are Python’s reserved words:


Numbers
Here’s how to get both the (truncated) quotient and remainder at once:


Otherwise, you could have calculated them separately:


Bases
A base is how many digits you can use until you need to “carry the one.” In base 2 (binary), the only digits are 0 and 1. 0 is the same as a plain old decimal 0, and 1 is the same as a decimal 1. However, in base 2, if you add a 1 to a 1, you get 10 (1 decimal two plus 0 decimal ones).
In Python, you can express literal integers in three bases besides decimal:
0b
or0B
for binary (base 2).0o
or0O
for octal (base 8).0x
or0X
for hex (base 16).
The interpreter prints these for you as decimal integers. Let’s try each of these bases.


In case you’re wondering what “digits” base 16 uses, they are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f. 0xa is a decimal 10, and 0xf is a decimal 15. Add 1 to 0xf and you get 0x10 (decimal 16). See more:https://hoas.xyz/post/gettingstartedwithhtmlandcsscss/#webcolors.
int()
will make integers from floats or strings of digits, but won’t handle strings containing decimal points or exponents:

