2021-01-04 17:33:43 +03:00
|
|
|
print([x * 5 for x in [1,2,3,4,5]])
|
2021-01-02 13:41:51 +03:00
|
|
|
|
2021-01-04 17:33:43 +03:00
|
|
|
print("Continuing...")
|
2021-01-02 13:41:51 +03:00
|
|
|
|
2020-12-30 15:56:02 +03:00
|
|
|
# Simple list comprehensions
|
|
|
|
for i in [x * 5 for x in [1,7,3,5,9,2,8]]:
|
2021-01-04 17:33:43 +03:00
|
|
|
print(i)
|
2020-12-30 15:56:02 +03:00
|
|
|
|
2021-01-04 17:33:43 +03:00
|
|
|
print("Now a sum...")
|
2021-01-02 13:41:51 +03:00
|
|
|
|
2020-12-30 16:30:09 +03:00
|
|
|
def sum(iterable):
|
|
|
|
let total = 0
|
|
|
|
for v in iterable:
|
|
|
|
total = total + v
|
|
|
|
return total
|
|
|
|
|
2021-01-04 17:33:43 +03:00
|
|
|
print("And now that sum applied to a complicated expression...")
|
2021-01-02 13:41:51 +03:00
|
|
|
|
2021-01-04 17:33:43 +03:00
|
|
|
print(sum([x * 3 for x in [y * 7 for y in [1,2,3,4,5]]]))
|