{"id":17603034,"url":"https://github.com/yjg30737/pymeg","last_synced_at":"2025-12-14T03:30:16.063Z","repository":{"id":62591566,"uuid":"429005926","full_name":"yjg30737/pymeg","owner":"yjg30737","description":"Python mathematical expression generator","archived":false,"fork":false,"pushed_at":"2022-05-08T10:13:19.000Z","size":2889,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T05:35:19.885Z","etag":null,"topics":["expression","math-problem-generator","mathematical-expressions","python","python-math","python3","random-math-problem-generator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yjg30737.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-17T10:44:49.000Z","updated_at":"2023-02-14T22:04:29.000Z","dependencies_parsed_at":"2022-11-04T02:51:13.830Z","dependency_job_id":null,"html_url":"https://github.com/yjg30737/pymeg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpymeg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpymeg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpymeg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yjg30737%2Fpymeg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yjg30737","download_url":"https://codeload.github.com/yjg30737/pymeg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239680985,"owners_count":19679509,"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":["expression","math-problem-generator","mathematical-expressions","python","python-math","python3","random-math-problem-generator"],"created_at":"2024-10-22T13:37:51.146Z","updated_at":"2025-12-14T03:30:16.015Z","avatar_url":"https://github.com/yjg30737.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pymeg\n\n## Table of Contents\n* [General Info](#general-info)\n* [Class Overview](#class-overview)\n* [Setup](#setup)\n* [Example](#example)\n\n## General Info\nPython mathematical expression generator\n\n## Class Overview\n* AbstractExpStruct\n\nAbstract class of ExpStruct. \n\nThis class has four constants.\n```python\nAbstractExpStruct.PLUS = 0\nAbstractExpStruct.MINUS = 1\nAbstractExpStruct.MULTIPLY = 2\nAbstractExpStruct.DIVIDE = 3\n```\n\n* ExpStruct\n\nClass which can store the rules of expression. inherits the AbstractExpStruct.\n\nExpStruct has methods like below.\n```python\nset_op(lst) # set the operators to be used to expression to generate as AbstractExpStruct's constant. \n# For example, if you want to use only plus and minus then write like this\n# expStruct.set_op([AbstractExpStruct.PLUS, AbstractExpStruct.Minus])\n\nget_op() -\u003e self.__op_lst # get the operators to be used as list of AbstractExpStruct's constant.\n\nset_oper_cnt(cnt) # set the number of operands of expression to be generated.\n\nset_range(min_, max_, types: list) # set min, max number to use of types(plus, minus ...).\n\n```\n\n* ExpGenerator\n\nClass which generate the randomized expression with given ExpStruct instance\nUsing `get_problem` static method to generate the expression. Argument is `ExpStruct`.\nResult is string-typed mathematical expression.\n```\nproblem = ExpStruct()\nExpGenerator.get_problem(problem)\n```\n\n## Setup\n`python -m pip install pymeg`\n\n## Example\n### Code Sample\n```python\n\nfrom pymeg.expGenerator import ExpGenerator\nfrom pymeg.expStruct import ExpStruct\n\nproblem = ExpStruct()\nproblem.set_oper_cnt(4)\nproblem.set_range(20, 100, [ExpStruct.PLUS, ExpStruct.MINUS])\nproblem.set_range(2, 10, [ExpStruct.MULTIPLY])\nproblem.set_range(2, 4, [ExpStruct.DIVIDE])\nprint(ExpGenerator.get_problem(problem))\nprint(ExpGenerator.get_problem(problem))\nprint(ExpGenerator.get_problem(problem))\next = ExpGenerator.get_problem(problem)\nprint(ext)\nprint(eval(ext))\n```\n\n### Result\nNote: Problem will be generated randomly depending on operand count set by user.\n```python\n54+25-54*9\n6*6-31/3\n2/4*8/3\n9*3*6/2\n81.0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjg30737%2Fpymeg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyjg30737%2Fpymeg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyjg30737%2Fpymeg/lists"}