{"id":20041704,"url":"https://github.com/ajithvcoder/session12_iterables_and_iterators_ii","last_synced_at":"2025-10-28T14:05:46.973Z","repository":{"id":111987514,"uuid":"391163540","full_name":"ajithvcoder/Session12_Iterables_and_Iterators_II","owner":"ajithvcoder","description":"EPAi Session 12 Assignment","archived":false,"fork":false,"pushed_at":"2021-07-30T18:56:21.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T19:30:22.300Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajithvcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-07-30T18:54:28.000Z","updated_at":"2021-07-30T18:56:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b5f3bbc-cdb0-471e-b579-428c0165f37e","html_url":"https://github.com/ajithvcoder/Session12_Iterables_and_Iterators_II","commit_stats":null,"previous_names":["ajithvcoder/session12_iterables_and_iterators_ii"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2FSession12_Iterables_and_Iterators_II","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2FSession12_Iterables_and_Iterators_II/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2FSession12_Iterables_and_Iterators_II/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2FSession12_Iterables_and_Iterators_II/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajithvcoder","download_url":"https://codeload.github.com/ajithvcoder/Session12_Iterables_and_Iterators_II/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241470401,"owners_count":19968041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T10:47:36.201Z","updated_at":"2025-10-28T14:05:41.933Z","avatar_url":"https://github.com/ajithvcoder.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Session 12 - Iterables and Iterators - II\n\nGoogle Colab implementation - [here](https://colab.research.google.com/drive/10Ou_lKkizRuKMmykHUsgkmjPh-ERqfgm?usp=sharing)\n\n**Polygon**\n\nA polygon class is formed with a input of edges and circum radius. \n\n```\n@property\ndef edges(self) -\u003e 'int':    \n    return self._edges\n\n@edges.setter\ndef edges(self, n) -\u003e None:    \n    self._edges = n\n\n```\nEdges are set using property decorator and setter. it helps us to call edges like a variable\n\n```\n@property\ndef area(self) -\u003e 'int':\n    \"\"\"\n    Calculates area lazyly\n    :return int\n    \"\"\"\n    if self._area is None:\n        self._area = self._edges / 2 * self.side_length * self.apothem\n    return self._area\n```\nWe are calculating area with lazy properties once its calculated there is no need to caculate again for that instance and it can be used like a variable \"object.area\"\n\nSame way we are calculating for polygon.interior_angle, polygon.side_length, polygon.apothem, polygon.perimeter\n\n\n**Polygons**\n\nImplemented iterables and lazy calculation without using list as storage\n\n\n```\ndef __iter__(self) -\u003e 'object':\n    \n    return self.PolygonIterator(self._m, self._R)\n\nclass PolygonIterator:\n    def __next__(self) -\u003e 'object':               \n        if self.curr_poly \u003e self.ed:\n            raise StopIteration\n        else:\n            if self.reverse:\n                index = self.length - self.i\n                self.i += 1                    \n            else:\n                index = self.curr_poly\n            item = Polygon(index, self.Radi)\n            curr_efficiency = item.area/item.perimeter\n            if curr_efficiency \u003e self.max_efficient:\n                self.max_efficient = curr_efficiency\n                self.max_eff_poly_id = self.curr_poly\n            Polygons.eff = self.max_eff_poly_id\n            self.curr_poly += 1              \n            return Poly(item)\n\n```\n\nWe are passing maxedges and circumradi to PolygonIterator. In polygon iterator __next__() we are using stop iteration if curr_poly is greater then length\nfor normaliteration we are using the curr_poly number and initalizing a object. Efficiency is also calculated. A polygon named tuple is returned. it is caculated with lazy properties\n\n*reversed()*\nFor reversed iteration we are calculating in reverse manner with self.length-self.i as index and feeding to Polygon class. A polygon named tuple is returned.\nit is done without list as a storage structure\n\n```\n@property\n    def eff(self, n) -\u003e 'int':\n        \"\"\"\n        Setting efficiency property from PolygonIterator\n        \"\"\"\n        self._max_eff = n \n        return self._max_eff\n\n```\n\nWe are using eff as a variable and self._max_eff is set from PolygonIterator class\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajithvcoder%2Fsession12_iterables_and_iterators_ii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajithvcoder%2Fsession12_iterables_and_iterators_ii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajithvcoder%2Fsession12_iterables_and_iterators_ii/lists"}