Infinite Squares (imperative) >>> from itertools import count >>> >>> squares = ( ... Rectangle(x, x) for x in count(1)) >>> squares at 0x11233ca40> >>> next(squares) <__main__.Rectangle at 0x1123a8400>
Infinite Squares (imperative) >>> sum_area(squares) KeyboardInterrupt Traceback (most recent call last) in () ----> 1 sum_area(squares) in sum_area(rects) 3 4 for r in rects: ----> 5 area += r.area
Exercise #1 (Problem) z = √(x2 + y2 ) x y z x ₒ factor y h ratio = function1(x, y, factor) hyp = function2(rectangle) >>> get_ratio(1, 2, 2) 0.7905694150420948
Exercise #2 (Problem) • create a list of dicts with keys "factor", "length", "width", and "ratio" (for factors 1 - 20) • group the records by quartiles of the "ratio" value, and aggregate each group by the median "ratio"
Exercise #2 (Problem) • create a list of dicts with keys "factor", "length", "width", and "ratio" (for factors 1 - 20) • group the records by quartiles of the "ratio" value, and aggregate each group by the median "ratio" • write the records out to a csv file (1 row per group)
Exercise #3 (Problem) • fetch the Python jobs rss feed • tokenize the "summary" field by newlines ("\n") • use "subelement" to extract the location (the first "token") • filter for jobs located in the U.S.
Exercise #3 (Problem) from riko.collections import SyncPipe url = 'https://www.python.org/jobs/feed/rss' # use the 'fetch', 'tokenizer', 'subelement', # and 'filter' pipes