2020-10-19 21:08:55

This commit is contained in:
wizardforcel
2020-10-19 21:08:55 +08:00
parent 7f63048035
commit ab0caba1f0
140 changed files with 3982 additions and 3982 deletions

View File

@@ -6,40 +6,40 @@
In [1]:
```
```py
2 + 2
```
Out[1]:
```
```py
4
```
In [2]:
```
```py
3 - 4
```
Out[2]:
```
```py
-1
```
In [3]:
```
```py
4 * 5
```
Out[3]:
```
```py
20
```
@@ -49,14 +49,14 @@ Out[3]:
In [4]:
```
```py
12 / 5
```
Out[4]:
```
```py
2
```
@@ -64,14 +64,14 @@ Out[4]:
In [5]:
```
```py
2 ** 5
```
Out[5]:
```
```py
32
```
@@ -79,14 +79,14 @@ Out[5]:
In [6]:
```
```py
32 % 5
```
Out[6]:
```
```py
2
```
@@ -94,7 +94,7 @@ Out[6]:
In [7]:
```
```py
a = 1
a
@@ -102,7 +102,7 @@ a
Out[7]:
```
```py
1
```
@@ -110,14 +110,14 @@ Out[7]:
In [8]:
```
```py
type(a)
```
Out[8]:
```
```py
int
```
@@ -129,7 +129,7 @@ int
In [9]:
```
```py
import sys
sys.maxint
@@ -137,7 +137,7 @@ sys.maxint
Out[9]:
```
```py
2147483647
```
@@ -147,13 +147,13 @@ Out[9]:
In [10]:
```
```py
a = sys.maxint + 1
print type(a)
```
```
```py
<type 'long'>
```
@@ -162,14 +162,14 @@ print type(a)
In [11]:
```
```py
a
```
Out[11]:
```
```py
2147483648L
```
@@ -177,7 +177,7 @@ Out[11]:
In [12]:
```
```py
b = 1234L
type(b)
@@ -185,7 +185,7 @@ type(b)
Out[12]:
```
```py
long
```
@@ -193,14 +193,14 @@ long
In [13]:
```
```py
a - 4
```
Out[13]:
```
```py
2147483644L
```
@@ -208,7 +208,7 @@ Out[13]:
In [14]:
```
```py
a = 1.4
type(a)
@@ -216,7 +216,7 @@ type(a)
Out[14]:
```
```py
float
```
@@ -224,40 +224,40 @@ float
In [15]:
```
```py
12.0 / 5.0
```
Out[15]:
```
```py
2.4
```
In [16]:
```
```py
12 / 5.0
```
Out[16]:
```
```py
2.4
```
In [17]:
```
```py
12.0 / 5
```
Out[17]:
```
```py
2.4
```
@@ -265,14 +265,14 @@ Out[17]:
In [18]:
```
```py
5 + 2.4
```
Out[18]:
```
```py
7.4
```
@@ -280,53 +280,53 @@ Out[18]:
In [19]:
```
```py
3.4 - 3.2
```
Out[19]:
```
```py
0.19999999999999973
```
In [20]:
```
```py
12.3 + 32.4
```
Out[20]:
```
```py
44.7
```
In [21]:
```
```py
2.5 ** 2
```
Out[21]:
```
```py
6.25
```
In [22]:
```
```py
3.4 % 2.1
```
Out[22]:
```
```py
1.2999999999999998
```
@@ -338,14 +338,14 @@ Out[22]:
In [23]:
```
```py
'{:.52}'.format(3.4 - 3.2)
```
Out[23]:
```
```py
'0.199999999999999733546474089962430298328399658203125'
```
@@ -353,12 +353,12 @@ Out[23]:
In [24]:
```
```py
print 3.4 - 3.2
```
```
```py
0.2
```
@@ -367,7 +367,7 @@ print 3.4 - 3.2
In [25]:
```
```py
import sys
sys.float_info
@@ -375,7 +375,7 @@ sys.float_info
Out[25]:
```
```py
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)
```
@@ -383,14 +383,14 @@ sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.
In [26]:
```
```py
sys.float_info.max
```
Out[26]:
```
```py
1.7976931348623157e+308
```
@@ -398,14 +398,14 @@ Out[26]:
In [27]:
```
```py
sys.float_info.min
```
Out[27]:
```
```py
2.2250738585072014e-308
```
@@ -413,14 +413,14 @@ Out[27]:
In [28]:
```
```py
sys.float_info.epsilon
```
Out[28]:
```
```py
2.220446049250313e-16
```
@@ -430,7 +430,7 @@ Out[28]:
In [29]:
```
```py
a = 1 + 2j
type(a)
@@ -438,7 +438,7 @@ type(a)
Out[29]:
```
```py
complex
```
@@ -446,40 +446,40 @@ complex
In [30]:
```
```py
a.real
```
Out[30]:
```
```py
1.0
```
In [31]:
```
```py
a.imag
```
Out[31]:
```
```py
2.0
```
In [32]:
```
```py
a.conjugate()
```
Out[32]:
```
```py
(1-2j)
```
@@ -489,14 +489,14 @@ Out[32]:
In [33]:
```
```py
1 + 2 - (3 * 4 / 6) ** 5 + 7 % 5
```
Out[33]:
```
```py
-27
```
@@ -511,27 +511,27 @@ Out[33]:
In [34]:
```
```py
12.3 // 5.2
```
Out[34]:
```
```py
2.0
```
In [35]:
```
```py
12.3 // -4
```
Out[35]:
```
```py
-4.0
```
@@ -541,14 +541,14 @@ Out[35]:
In [36]:
```
```py
abs(-12.4)
```
Out[36]:
```
```py
12.4
```
@@ -556,14 +556,14 @@ Out[36]:
In [37]:
```
```py
round(21.6)
```
Out[37]:
```
```py
22.0
```
@@ -571,13 +571,13 @@ Out[37]:
In [38]:
```
```py
print min(2, 3, 4, 5)
print max(2, 4, 3)
```
```
```py
2
4
@@ -589,14 +589,14 @@ print max(2, 4, 3)
In [39]:
```
```py
type(max)
```
Out[39]:
```
```py
builtin_function_or_method
```
@@ -604,7 +604,7 @@ builtin_function_or_method
In [40]:
```
```py
max = 1
type(max)
@@ -612,18 +612,18 @@ type(max)
Out[40]:
```
```py
int
```
In [41]:
```
```py
max(4, 5)
```
```
```py
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-41-c60446be959c> in <module>()
@@ -638,13 +638,13 @@ TypeError: 'int' object is not callable
In [42]:
```
```py
print int(12.324)
print int(-3.32)
```
```
```py
12
-3
@@ -654,12 +654,12 @@ print int(-3.32)
In [43]:
```
```py
print float(1.2)
```
```
```py
1.2
```
@@ -672,14 +672,14 @@ print float(1.2)
In [44]:
```
```py
1e-6
```
Out[44]:
```
```py
1e-06
```
@@ -687,14 +687,14 @@ Out[44]:
In [45]:
```
```py
0xFF
```
Out[45]:
```
```py
255
```
@@ -702,14 +702,14 @@ Out[45]:
In [46]:
```
```py
067
```
Out[46]:
```
```py
55
```
@@ -717,14 +717,14 @@ Out[46]:
In [47]:
```
```py
0b101010
```
Out[47]:
```
```py
42
```
@@ -734,7 +734,7 @@ Out[47]:
In [48]:
```
```py
b = 2.5
b += 2
print b
@@ -745,7 +745,7 @@ print b
```
```
```py
4.5
9.0
6.0
@@ -758,7 +758,7 @@ print b
In [49]:
```
```py
q = True
type(q)
@@ -766,7 +766,7 @@ type(q)
Out[49]:
```
```py
bool
```
@@ -774,20 +774,20 @@ bool
In [50]:
```
```py
q = 1 > 2
print q
```
```
```py
False
```
常用的比较符号包括:
```
```py
<, >, <=, >=, ==, !=
```
@@ -795,7 +795,7 @@ False
In [51]:
```
```py
x = 2
1 < x <= 3
@@ -803,7 +803,7 @@ x = 2
Out[51]:
```
```py
True
```