Python 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
Type "copyright", "credits" or "license" for more information.
IPython 7.9.0 -- An enhanced Interactive Python.
In [1]: import lezione11 as im
In [2]: im.Immagine(200, 400)
Out[2]: <lezione11.Immagine at 0x7eff080e8c50>
In [3]: img = im.Immagine(200, 400)
In [4]: print(img)
Immagine(200, 400)
In [5]: import lezione11 as im
In [6]: img = im.Immagine(200, 400)
In [7]: print(img)
Immagine(200, 400)
In [8]: img
Out[8]: Immagine(200, 400)
In [9]: import lezione11 as im
In [10]: rossiccio = im.Colore(255, 12, 57)
In [11]: rossiccio
Out[11]: Colore(255, 12, 57)
In [12]: rossiccio*1.5
Traceback (most recent call last):
File "<ipython-input-12-2b6833a2c481>", line 1, in <module>
rossiccio*1.5
TypeError: unsupported operand type(s) for *: 'Colore' and 'float'
In [13]:
In [13]: import lezione11 as im
In [14]: rossiccio = im.Colore(255, 12, 57)
In [15]: rossiccio*1.5
Traceback (most recent call last):
File "<ipython-input-15-2b6833a2c481>", line 1, in <module>
rossiccio*1.5
TypeError: unsupported operand type(s) for *: 'Colore' and 'float'
In [16]:
In [16]: import lezione11 as im
In [17]: rossiccio = im.Colore(255, 12, 57)
...:
In [18]: rossiccio*1.5
Out[18]: Colore(255, 18, 86)
In [19]: import lezione11 as im
[autoreload of lezione11 failed: Traceback (most recent call last):
File "/opt/anaconda3/envs/F19/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 245, in check
superreload(m, reload, self.old_objects)
File "/opt/anaconda3/envs/F19/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 394, in superreload
module = reload(module)
File "/opt/anaconda3/envs/F19/lib/python3.7/imp.py", line 314, in reload
return importlib.reload(module)
File "/opt/anaconda3/envs/F19/lib/python3.7/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 630, in _exec
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 11, in <module>
class Colore:
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 13, in Colore
BIANCO = Colore(255, 255, 255)
NameError: name 'Colore' is not defined
]
In [20]: import lezione11 as im
[autoreload of lezione11 failed: Traceback (most recent call last):
File "/opt/anaconda3/envs/F19/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 245, in check
superreload(m, reload, self.old_objects)
File "/opt/anaconda3/envs/F19/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 394, in superreload
module = reload(module)
File "/opt/anaconda3/envs/F19/lib/python3.7/imp.py", line 314, in reload
return importlib.reload(module)
File "/opt/anaconda3/envs/F19/lib/python3.7/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 630, in _exec
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 11, in <module>
class Colore:
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 13, in Colore
BIANCO = Colore(255, 255, 255)
NameError: name 'Colore' is not defined
]
In [21]: import lezione11 as im
[autoreload of lezione11 failed: Traceback (most recent call last):
File "/opt/anaconda3/envs/F19/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 245, in check
superreload(m, reload, self.old_objects)
File "/opt/anaconda3/envs/F19/lib/python3.7/site-packages/IPython/extensions/autoreload.py", line 394, in superreload
module = reload(module)
File "/opt/anaconda3/envs/F19/lib/python3.7/imp.py", line 314, in reload
return importlib.reload(module)
File "/opt/anaconda3/envs/F19/lib/python3.7/importlib/__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 630, in _exec
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 860, in get_code
File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 43
def __mul__(self, fattore):
^
IndentationError: unexpected indent
]
In [22]: import lezione11 as im
In [23]: im.Colore.ROSSO
Out[23]: Colore(255, 0, 0)
In [24]: im.Colore.ROSSO.inverso()
Traceback (most recent call last):
File "<ipython-input-24-a5314dac58fa>", line 1, in <module>
im.Colore.ROSSO.inverso()
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 26, in inverso
return Colore.BIANCO - self
TypeError: unsupported operand type(s) for -: 'Colore' and 'Colore'
In [25]:
In [25]: import lezione11 as im
In [26]: im.Colore.ROSSO.inverso()
Out[26]: Colore(0, 255, 255)
In [27]: import lezione11 as im
In [28]: c = Colore(27, 180, 50)
Traceback (most recent call last):
File "<ipython-input-28-24ab020a6a79>", line 1, in <module>
c = Colore(27, 180, 50)
NameError: name 'Colore' is not defined
In [29]:
In [29]: c = im.Colore(27, 180, 50)
In [30]: c.contrasto(1.5)
Out[30]: Colore(128, 206, 128)
In [31]: im.Colore.GRIGIO
Out[31]: Colore(128, 128, 128)
In [32]: c.contrasto(1.5)
Out[32]: Colore(128, 206, 128)
In [33]: %trace
UsageError: Line magic function `%trace` not found.
In [34]: %debug
> <ipython-input-28-24ab020a6a79>(1)<module>()
----> 1 c = Colore(27, 180, 50)
ipdb>
ipdb>
ipdb> q
In [35]: %debug c.contrasto(1.5)
NOTE: Enter 'c' at the ipdb> prompt to continue execution.
> <string>(1)<module>()
ipdb> l
ipdb> ?
Documented commands (type help <topic>):
========================================
EOF cl disable interact next psource rv unt
a clear display j p q s until
alias commands down jump pdef quit source up
args condition enable l pdoc r step w
b cont exit list pfile restart tbreak whatis
break continue h ll pinfo return u where
bt d help longlist pinfo2 retval unalias
c debug ignore n pp run undisplay
Miscellaneous help topics:
==========================
exec pdb
ipdb> s
--Call--
> /home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py(32)contrasto()
30 return self.r, self.g, self.b
31
---> 32 def contrasto(self, fattore):
33 return Colore.GRIGIO + ((self - Colore.GRIGIO)*fattore)
34
> /home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py(33)contrasto()
31
32 def contrasto(self, fattore):
---> 33 return Colore.GRIGIO + ((self - Colore.GRIGIO)*fattore)
34
35 # TODO
ipdb> --Call--
> /home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py(45)__sub__()
43 return Colore(self.r+other.r, self.g+other.g, self.b+other.b)
44
---> 45 def __sub__(self,other):
46 return Colore(self.r-other.r, self.g-other.g, self.b-other.b)
47
ipdb> > /home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py(46)__sub__()
44
45 def __sub__(self,other):
---> 46 return Colore(self.r-other.r, self.g-other.g, self.b-other.b)
47
48
ipdb>
ipdb>
ipdb>
ipdb>
ipdb> --Return--
Colore(0, 52, 0)
> /home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py(46)__sub__()
44
45 def __sub__(self,other):
---> 46 return Colore(self.r-other.r, self.g-other.g, self.b-other.b)
47
48
ipdb> --Call--
> /home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py(39)__mul__()
37 # - somma di colori
38
---> 39 def __mul__(self, fattore):
40 return Colore(self.r*fattore, self.g*fattore, self.b*fattore)
41
ipdb>
ipdb>
ipdb> q
In [36]: c = im.Colore(120, 140, 128)
In [37]: c.contrasto(1.5)
Out[37]: Colore(128, 146, 128)
In [38]: import lezione11 as im
In [39]: c = im.Colore(27, 180, 50)
In [40]: c.contrasto(1)
Out[40]: Colore(27.0, 180.0, 50.0)
In [41]: c.contrasto(2)
Out[41]: Colore(-73.5, 232.5, -27.5)
In [42]: c.contrasto(0.5)
...:
Out[42]: Colore(77.25, 153.75, 88.75)
In [43]: import lezione11 as im
In [44]: i = im.Immagine(1,1)
In [45]: i.load("3cime.png")
In [46]: contrastata = i.contrasto(1.5)
In [47]: contrastata.save("3cime-CCC.png")
Traceback (most recent call last):
File "<ipython-input-47-7e00fb6b7873>", line 1, in <module>
contrastata.save("3cime-CCC.png")
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 76, in save
triple = self.asTriple()
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 72, in asTriple
for riga in self.img]
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 72, in <listcomp>
for riga in self.img]
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 71, in <listcomp>
return [ [ c.asTripla() for c in riga ]
File "/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py", line 30, in asTripla
return (max(0,min(255, round(r))),
NameError: name 'r' is not defined
In [48]:
In [48]: import lezione11 as im
In [49]: i = im.Immagine(1,1)
In [50]: i.load("3cime.png")
In [51]: contrastata = i.contrasto(1.5)
In [52]: contrastata.save("3cime-CCC.png")
In [53]: import IPython.display as ipd
In [54]: ipd.Image("3cime.png")
Out[54]:
In [55]: ipd.Image("3cime-CCC.png")
Out[55]:
In [56]: runfile('/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py', wdir='/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni')
Reloaded modules: lezione11, immagini, png
In [57]: im.fatt(3)
Out[57]: 6
In [58]: im.fatt(4)
Out[58]: 24
In [59]: L = list(range(30))
In [60]: L
Out[60]:
[0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29]
In [61]: L = list(range(10))
In [62]: L
Out[62]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
In [63]: im.stampaR(L)
0
1
2
3
4
5
6
7
8
9
In [64]: im.stampaRovescio(L)
9
8
7
6
5
4
3
2
1
0
In [65]: runfile('/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py', wdir='/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni')
Reloaded modules: immagini, png
In [66]: L
Out[66]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
In [67]: sommaRicorsiva(L)
Out[67]: 45
In [68]: runfile('/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py', wdir='/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni')
Reloaded modules: immagini, png
In [69]: sommaR_con_indice(L, 0)
Out[69]: 45
In [70]: runfile('/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni/lezione11.py', wdir='/home/andrea/Documents/Uni/Didattica/Prog1/2019-20/Lezioni')
Reloaded modules: immagini, png
In [71]: sommaR_con_indice(L)
Out[71]: 45
In [72]: