@@ -412,6 +412,11 @@ from math import inf, nan, isinf, isnan
412
412
float (' inf' ), float (' nan' )
413
413
```
414
414
415
+ ### Statistics
416
+ ``` python
417
+ from statistics import mean, median, variance, pvariance, pstdev
418
+ ```
419
+
415
420
### Random
416
421
``` python
417
422
from random import random, randint, choice, shuffle
@@ -1088,6 +1093,28 @@ Recursion Limit
1088
1093
```
1089
1094
1090
1095
1096
+ CSV
1097
+ ---
1098
+ ``` python
1099
+ import csv
1100
+ ```
1101
+
1102
+ ### Read Rows from CSV File
1103
+ ``` python
1104
+ def read_csv_file (filename ):
1105
+ with open (filename, encoding = ' utf-8' ) as file :
1106
+ return csv.reader(file , delimiter = ' ;' )
1107
+ ```
1108
+
1109
+ ### Write Rows to CSV File
1110
+ ``` python
1111
+ def write_to_csv_file (filename , rows ):
1112
+ with open (filename, ' w' , encoding = ' utf-8' ) as file :
1113
+ writer = csv.writer(file , delimiter = ' ;' )
1114
+ writer.writerows(rows)
1115
+ ```
1116
+
1117
+
1091
1118
JSON
1092
1119
----
1093
1120
``` python
@@ -1366,8 +1393,8 @@ from itertools import *
1366
1393
>> > chain([1 , 2 ], range (3 , 5 ))
1367
1394
[1 , 2 , 3 , 4 ]
1368
1395
1369
- >> > compress(' abc ' , [True , 0 , 1 ])
1370
- [' a ' , ' c ' ]
1396
+ >> > compress([ 1 , 2 , 3 , 4 ], [True , False , 1 , 0 ])
1397
+ [1 , 3 ]
1371
1398
1372
1399
>> > # islice(<collection>, from_inclusive, to_exclusive)
1373
1400
>> > islice([1 , 2 , 3 ], 1 , None )
@@ -1468,8 +1495,7 @@ class MyMetaClass(type):
1468
1495
1469
1496
``` python
1470
1497
class MyClass (metaclass = MyMetaClass ):
1471
- def __init__ (self ):
1472
- self .b = 12345
1498
+ b = 12345
1473
1499
```
1474
1500
1475
1501
0 commit comments