Skip to content

Commit 0fe8be3

Browse files
committed
Libraries
1 parent 15b70c5 commit 0fe8be3

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,9 @@ Progress Bar
16241624
```python
16251625
# $ pip3 install tqdm
16261626
from tqdm import tqdm
1627+
```
1628+
1629+
```python
16271630
from time import sleep
16281631
for i in tqdm([1, 2, 3]):
16291632
sleep(0.2)
@@ -1637,6 +1640,9 @@ Plot
16371640
```python
16381641
# $ pip3 install matplotlib
16391642
from matplotlib import pyplot
1643+
```
1644+
1645+
```python
16401646
pyplot.plot(<data_1> [, <data_2>, ...])
16411647
pyplot.savefig(<filename>, transparent=True)
16421648
pyplot.show()
@@ -1645,10 +1651,13 @@ pyplot.show()
16451651

16461652
Table
16471653
-----
1648-
#### Prints CSV file as ASCII table:
16491654
```python
16501655
# $ pip3 install tabulate
16511656
from tabulate import tabulate
1657+
```
1658+
1659+
#### Prints CSV file as ASCII table:
1660+
```python
16521661
import csv
16531662
with open(<filename>, encoding='utf-8') as file:
16541663
lines = csv.reader(file, delimiter=';')
@@ -1663,7 +1672,9 @@ Curses
16631672
```python
16641673
# $ pip3 install curses
16651674
from curses import wrapper
1675+
```
16661676

1677+
```python
16671678
def main():
16681679
wrapper(draw)
16691680

@@ -1695,19 +1706,17 @@ height = 100
16951706
size = width * height
16961707
pixels = [255 * i/size for i in range(size)]
16971708

1698-
img_hsv = Image.new('HSV', (width, height))
1699-
img_hsv.putdata([(int(a), 255, 255) for a in pixels])
1700-
img_rgb = img_hsv.convert(mode='RGB')
1701-
img_rgb.save('test.png')
1709+
img = Image.new('HSV', (width, height))
1710+
img.putdata([(int(a), 255, 255) for a in pixels])
1711+
img.convert(mode='RGB').save('test.png')
17021712
```
17031713

1704-
#### Adds noise to image:
1714+
#### Adds noise to an image:
17051715
```python
17061716
from random import randint
17071717
add_noise = lambda value: max(0, min(255, value + randint(-20, 20)))
1708-
img = Image.open('test.png').convert(mode='HSV')
1709-
pixels = [(add_noise(h), s, v) for h, s, v in img.getdata()]
1710-
img.putdata(pixels)
1718+
img = Image.open('test.png').convert(mode='HSV')
1719+
img.putdata([(add_noise(h), s, v) for h, s, v in img.getdata()])
17111720
img.convert(mode='RGB').save('test.png')
17121721
```
17131722

0 commit comments

Comments
 (0)