{"id":47327298,"url":"https://github.com/sourcebots/python-lab","last_synced_at":"2026-03-17T19:32:05.607Z","repository":{"id":176298746,"uuid":"652328755","full_name":"sourcebots/python-lab","owner":"sourcebots","description":"Lab activities for general Python programming workshop","archived":false,"fork":false,"pushed_at":"2024-07-14T08:07:22.000Z","size":29,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-07-14T09:25:28.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://sourcebots.github.io/python-lab/","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/sourcebots.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-11T19:57:26.000Z","updated_at":"2023-06-26T09:37:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"84da4d7e-9766-4dc6-877f-b3737706a3b5","html_url":"https://github.com/sourcebots/python-lab","commit_stats":null,"previous_names":["sourcebots/python-lab"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sourcebots/python-lab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcebots%2Fpython-lab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcebots%2Fpython-lab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcebots%2Fpython-lab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcebots%2Fpython-lab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcebots","download_url":"https://codeload.github.com/sourcebots/python-lab/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcebots%2Fpython-lab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30629474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-03-17T19:32:04.843Z","updated_at":"2026-03-17T19:32:05.588Z","avatar_url":"https://github.com/sourcebots.png","language":"Python","readme":"# Python Lab\n\nLab activities for general Python programming workshop.\n\nAttached is a [`calc.py`](./calc.py) script, which is a basic functional calculator program.\n\n## Tasks\n\nWhilst you can complete the tasks in any order, they start easier and get harder, so we'd recommend completing them in order. Each new feature must not break functionality introduced in a previous.\n\nEach task is presented with an example output. This is merely an example - feel free to write it however you wish.\n\n### Show a message when the user enters an invalid operation\n\n```\nSelect operation.\n1.Add\n2.Subtract\n3.Multiply\n4.Divide\nEnter choice(1/2/3/4): 5\nInvalid choice - try again\nEnter choice(1/2/3/4): 5\n```\n\n### Rather than entering numbers for each of the operations, use the mathematical symbol (\"+\" for addition etc)\n\n```\nSelect operation:\n- Add (+)\n- Subtract (-)\n- Multiply (*)\n- Divide (/)\nEnter choice: +\n```\n\n### Add support for operating on decimal values\n\n```\nSelect operation:\n- Add (+)\n- Subtract (-)\n- Multiply (*)\n- Divide (/)\nEnter choice: +\nEnter first number: 2.5\nEnter second number: 3.5\n2.5 + 3.5 = 6\n```\n\n### When prompted for a number, if someone enters something which isn't a number, show an error message and ask for the value again\n\n```\nSelect operation:\n- Add (+)\n- Subtract (-)\n- Multiply (*)\n- Divide (/)\nEnter choice: +\nEnter first number: no\n\"no\" is not a number. Try again.\nEnter first number: no\n```\n\nExtension: If someone gives an invalid value for the second number, don't ask for the first number again.\n\n### Add a \"Power of\" choice, which raises the first number to the power of the second.\n\n```\nSelect operation:\n- Add (+)\n- Subtract (-)\n- Multiply (*)\n- Divide (/)\n- Exponent (**)\nEnter choice: **\nEnter first number: 2\nEnter second number: 3\n2 ** 3 = 8\n```\n\nIn Python, the \"power of\" operator is `**`.\n\n### Implement square root, where only a single number is prompted\n\n```\nSelect operation:\n- Add (+)\n- Subtract (-)\n- Multiply (*)\n- Divide (/)\n- Exponent (**)\n- Square Root (sqrt)\nEnter choice: sqrt\nEnter first number: 9\nsqrt 9 = 3\n```\n\n### If the calculation fails, show a sensible message\n\n```\nSelect operation:\n- Add (+)\n- Subtract (-)\n- Multiply (*)\n- Divide (/)\n- Exponent (**)\n- Square Root (sqrt)\nEnter choice: /\nEnter first number: 3\nEnter second number: 0\n3 / 0 failed: ZeroDivisionError: float division by zero\nEnter choice:\n```\n\n### Let the user enter the entire equation at once\n\n```\nAvailable operations:\n- Add (+)\n- Subtract (-)\n- Multiply (*)\n- Divide (/)\n- Exponent (**)\n- Square (sqrt)\n\n\u003e 2 + 3\n= 5\n```\n\n### Support \"[Reverse Polish](https://www-stone.ch.cam.ac.uk/documentation/rrf/rpn.html)\" notation, where the operator comes after the numbers\n\n```\nAvailable operations:\n- Add (+)\n- Subtract (-)\n- Multiply (*)\n- Divide (/)\n- Exponent (**)\n- Square (sqrt)\n\n\u003e 2 3 +\n= 5\n```\n\nThis should work in addition to normal (infix) notation.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcebots%2Fpython-lab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcebots%2Fpython-lab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcebots%2Fpython-lab/lists"}