Skip to content

Commit

Permalink
update slides
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Jul 6, 2024
1 parent bf9b11f commit 3bfe500
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions python/examples/functional/create_dict_using_zip.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
names = ['Jan', 'Feb', 'Mar', 'Apr']
days = [31, 28, 31, 30]

zipped = zip(names, days)
print(zipped)
print(list(zipped))

zipped = zip(names, days)
month = dict(zipped)
print(month)
7 changes: 5 additions & 2 deletions python/examples/functional/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ def double(n):

double_numbers = map(double, numbers)
print(double_numbers) # <map object at 0x7f8eb2d849e8>
for num in double_numbers:
print(num)
#for num in double_numbers:
# print(num)

dbl = list(double_numbers)
print(dbl)
21 changes: 21 additions & 0 deletions python/examples/functional/read_lines_without_newlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,26 @@
with open(filename) as fh:
rows = map(lambda s: s.rstrip("\n"), fh.readlines())

print("SIZE:", sys.getsizeof(rows))

for row in rows:
print(row)


with open(filename) as fh:
rows = map(lambda s: s.rstrip("\n"), fh)
print("SIZE:", sys.getsizeof(rows))

for row in rows:
print(row)



#with open(filename) as fh:
# #for row in fh:
# # ...
# #rows = map(lambda s: s.rstrip("\n"), fh.readlines())
# rows = map(lambda s: s.rstrip("\n"), fh)
#
# for row in rows:
# print(row)

0 comments on commit 3bfe500

Please sign in to comment.