@@ -1624,6 +1624,9 @@ Progress Bar
1624
1624
``` python
1625
1625
# $ pip3 install tqdm
1626
1626
from tqdm import tqdm
1627
+ ```
1628
+
1629
+ ``` python
1627
1630
from time import sleep
1628
1631
for i in tqdm([1 , 2 , 3 ]):
1629
1632
sleep(0.2 )
@@ -1637,6 +1640,9 @@ Plot
1637
1640
``` python
1638
1641
# $ pip3 install matplotlib
1639
1642
from matplotlib import pyplot
1643
+ ```
1644
+
1645
+ ``` python
1640
1646
pyplot.plot(< data_1> [, < data_2> , ... ])
1641
1647
pyplot.savefig(< filename> , transparent = True )
1642
1648
pyplot.show()
@@ -1645,10 +1651,13 @@ pyplot.show()
1645
1651
1646
1652
Table
1647
1653
-----
1648
- #### Prints CSV file as ASCII table:
1649
1654
``` python
1650
1655
# $ pip3 install tabulate
1651
1656
from tabulate import tabulate
1657
+ ```
1658
+
1659
+ #### Prints CSV file as ASCII table:
1660
+ ``` python
1652
1661
import csv
1653
1662
with open (< filename> , encoding = ' utf-8' ) as file :
1654
1663
lines = csv.reader(file , delimiter = ' ;' )
@@ -1663,7 +1672,9 @@ Curses
1663
1672
``` python
1664
1673
# $ pip3 install curses
1665
1674
from curses import wrapper
1675
+ ```
1666
1676
1677
+ ``` python
1667
1678
def main ():
1668
1679
wrapper(draw)
1669
1680
@@ -1695,19 +1706,17 @@ height = 100
1695
1706
size = width * height
1696
1707
pixels = [255 * i/ size for i in range (size)]
1697
1708
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' )
1702
1712
```
1703
1713
1704
- #### Adds noise to image:
1714
+ #### Adds noise to an image:
1705
1715
``` python
1706
1716
from random import randint
1707
1717
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()])
1711
1720
img.convert(mode = ' RGB' ).save(' test.png' )
1712
1721
```
1713
1722
0 commit comments