Skip to content

Commit 6461f53

Browse files
committed
quebrando linhas de código
1 parent d0a5015 commit 6461f53

3 files changed

Lines changed: 26 additions & 19 deletions

File tree

online/cap02.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ O resultado tem seis itens.
335335
----
336336
>>> colors = ['black', 'white']
337337
>>> sizes = ['S', 'M', 'L']
338-
>>> tshirts = [(color, size) for color in colors for size in sizes] <1>
338+
>>> tshirts = [(color, size) for color in colors
339+
... for size in sizes] <1>
339340
>>> tshirts
340341
[('black', 'S'), ('black', 'M'), ('black', 'L'), ('white', 'S'),
341342
('white', 'M'), ('white', 'L')]
@@ -482,7 +483,8 @@ pois o significado de cada campo é dado por sua posição na tupla.
482483
[source, pycon]
483484
----
484485
>>> lax_coordinates = (33.9425, -118.408056) <1>
485-
>>> city, year, pop, chg, area = ('Tokyo', 2003, 32_450, 0.66, 8014) <2>
486+
>>> city, year, pop, chg, area = (
487+
... 'Tokyo', 2003, 32_450, 0.66, 8014) <2>
486488
>>> traveler_ids = [('USA', '31195855'), ('BRA', 'CE342567'), <3>
487489
... ('ESP', 'XDA205856')]
488490
>>> for passport in sorted(traveler_ids): <4>
@@ -910,10 +912,10 @@ Então, você poderia usar um método assim para interpretar mensagens naquele f
910912
self.beep(times, frequency)
911913
case ['NECK', angle]: # <3>
912914
self.rotate_neck(angle)
913-
case ['LED', ident, intensity]: # <4>
914-
self.leds[ident].set_brightness(ident, intensity)
915-
case ['LED', ident, red, green, blue]: # <5>
916-
self.leds[ident].set_color(ident, red, green, blue)
915+
case ['LED', pin, intensity]: # <4>
916+
self.leds[ident].set_brightness(pin, intensity)
917+
case ['LED', pin, red, green, blue]: # <5>
918+
self.leds[ident].set_color(pin, red, green, blue)
917919
case _: # <6>
918920
raise InvalidCommand(message)
919921
----

print/1/experimento-1/cap02.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ O resultado tem seis itens.
332332
----
333333
>>> colors = ['black', 'white']
334334
>>> sizes = ['S', 'M', 'L']
335-
>>> tshirts = [(color, size) for color in colors for size in sizes] <1>
335+
>>> tshirts = [(color, size) for color in colors
336+
... for size in sizes] <1>
336337
>>> tshirts
337338
[('black', 'S'), ('black', 'M'), ('black', 'L'), ('white', 'S'),
338339
('white', 'M'), ('white', 'L')]
@@ -479,7 +480,8 @@ pois o significado de cada campo é dado por sua posição na tupla.
479480
[source, pycon]
480481
----
481482
>>> lax_coordinates = (33.9425, -118.408056) <1>
482-
>>> city, year, pop, chg, area = ('Tokyo', 2003, 32_450, 0.66, 8014) <2>
483+
>>> city, year, pop, chg, area = (
484+
... 'Tokyo', 2003, 32_450, 0.66, 8014) <2>
483485
>>> traveler_ids = [('USA', '31195855'), ('BRA', 'CE342567'), <3>
484486
... ('ESP', 'XDA205856')]
485487
>>> for passport in sorted(traveler_ids): <4>
@@ -908,10 +910,10 @@ Então, você poderia usar um método assim para interpretar mensagens naquele f
908910
self.beep(times, frequency)
909911
case ['NECK', angle]: # <3>
910912
self.rotate_neck(angle)
911-
case ['LED', ident, intensity]: # <4>
912-
self.leds[ident].set_brightness(ident, intensity)
913-
case ['LED', ident, red, green, blue]: # <5>
914-
self.leds[ident].set_color(ident, red, green, blue)
913+
case ['LED', pin, intensity]: # <4>
914+
self.leds[ident].set_brightness(pin, intensity)
915+
case ['LED', pin, red, green, blue]: # <5>
916+
self.leds[ident].set_color(pin, red, green, blue)
915917
case _: # <6>
916918
raise InvalidCommand(message)
917919
----

vol1/cap02.adoc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ Considere o <<ex_listcomp_x_filter_map>>.
296296
>>> beyond_ascii = [ord(s) for s in symbols if ord(s) > 127]
297297
>>> beyond_ascii
298298
[162, 163, 165, 8364, 164]
299-
>>> beyond_ascii = list(filter(lambda c: c > 127, map(ord, symbols)))
299+
>>> beyond_ascii = list(filter(lambda c: c > 127,
300+
... map(ord, symbols)))
300301
>>> beyond_ascii
301302
[162, 163, 165, 8364, 164]
302303
----
@@ -337,7 +338,8 @@ O resultado tem seis itens.
337338
----
338339
>>> colors = ['black', 'white']
339340
>>> sizes = ['S', 'M', 'L']
340-
>>> tshirts = [(color, size) for color in colors for size in sizes] <1>
341+
>>> tshirts = [(color, size) for color in colors
342+
... for size in sizes] <1>
341343
>>> tshirts
342344
[('black', 'S'), ('black', 'M'), ('black', 'L'), ('white', 'S'),
343345
('white', 'M'), ('white', 'L')]
@@ -484,7 +486,8 @@ pois o significado de cada campo é dado por sua posição na tupla.
484486
[source, pycon]
485487
----
486488
>>> lax_coordinates = (33.9425, -118.408056) <1>
487-
>>> city, year, pop, chg, area = ('Tokyo', 2003, 32_450, 0.66, 8014) <2>
489+
>>> city, year, pop, chg, area = (
490+
... 'Tokyo', 2003, 32_450, 0.66, 8014) <2>
488491
>>> traveler_ids = [('USA', '31195855'), ('BRA', 'CE342567'), <3>
489492
... ('ESP', 'XDA205856')]
490493
>>> for passport in sorted(traveler_ids): <4>
@@ -912,10 +915,10 @@ Então, você poderia usar um método assim para interpretar mensagens naquele f
912915
self.beep(times, frequency)
913916
case ['NECK', angle]: # <3>
914917
self.rotate_neck(angle)
915-
case ['LED', ident, intensity]: # <4>
916-
self.leds[ident].set_brightness(ident, intensity)
917-
case ['LED', ident, red, green, blue]: # <5>
918-
self.leds[ident].set_color(ident, red, green, blue)
918+
case ['LED', pin, intensity]: # <4>
919+
self.leds[ident].set_brightness(pin, intensity)
920+
case ['LED', pin, red, green, blue]: # <5>
921+
self.leds[ident].set_color(pin, red, green, blue)
919922
case _: # <6>
920923
raise InvalidCommand(message)
921924
----

0 commit comments

Comments
 (0)