{"id":18020705,"url":"https://github.com/inforkgodara/python-calculator","last_synced_at":"2025-04-04T17:16:43.598Z","repository":{"id":110250066,"uuid":"277166172","full_name":"inforkgodara/python-calculator","owner":"inforkgodara","description":"It is a basic python calculator.","archived":false,"fork":false,"pushed_at":"2020-08-16T10:45:04.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T02:38:47.766Z","etag":null,"topics":["calculator","inforkgodara","multiplication","python","python-calculator","subtraction"],"latest_commit_sha":null,"homepage":"","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/inforkgodara.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-04T18:38:16.000Z","updated_at":"2020-08-16T11:32:15.000Z","dependencies_parsed_at":"2023-04-07T18:07:48.612Z","dependency_job_id":null,"html_url":"https://github.com/inforkgodara/python-calculator","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/inforkgodara%2Fpython-calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fpython-calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fpython-calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforkgodara%2Fpython-calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inforkgodara","download_url":"https://codeload.github.com/inforkgodara/python-calculator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217220,"owners_count":20903009,"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":["calculator","inforkgodara","multiplication","python","python-calculator","subtraction"],"created_at":"2024-10-30T06:07:23.002Z","updated_at":"2025-04-04T17:16:43.576Z","avatar_url":"https://github.com/inforkgodara.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python Calculator\n\nIt is a basic python calculator which can perform basic arithmetic operations like addition, subtraction, multiplication. Python 3.8 is used for the implementation.\n\n## Approach\n\n* User enter number (single digit or n character) to perform a specific operation like 1, 2, 3, 4 and n (n is to cancel calculation operation) are valid.\n* Taking two numbers as inputs and used branching if elif else to perform a particular section.\n* Using functions add(), subtract(), multiply() to perform specific task after given data to the system.\n\n## Code\n```\n# Program make a basic calculator\n# Author @inforkgodara\n\n# Function adds two numbers\ndef add(first_number, second_number):\n    return first_number + second_number\n\n\n# Function subtracts two numbers\ndef subtract(first_number, second_number):\n    return first_number - second_number\n\n\n# Function multiplies two numbers\ndef multiply(first_number, second_number):\n    return first_number * second_number\n\n\n# Function divides two numbers\ndef divide(first_number, second_number):\n    return first_number / second_number\n\n\nprint('Select options.')\nprint('1. Add')\nprint('2. Subtract')\nprint('3. Multiply')\nprint('4. Divide')\n\nwhile True:\n    # Take input from the console\n    choice = input('Enter choice(1/2/3/4 or n to cancel): ')\n    # Check if choice is one of the five options\n    if choice in ('1', '2', '3', '4'):\n        first_number = float(input('Enter first number: '))\n        second_number = float(input('Enter second number: '))\n\n        if choice == '1':\n            print(first_number, '+', second_number, '=', add(first_number, second_number))\n\n        elif choice == '2':\n            print(first_number, '-', second_number, '=', subtract(first_number, second_number))\n\n        elif choice == '3':\n            print(first_number, '*', second_number, '=', multiply(first_number, second_number))\n\n        elif choice == '4':\n            print(first_number, '/', second_number, '=', divide(first_number, second_number))\n    elif choice == 'n':\n        print('Your are successfully logged out!')\n        break\n    else:\n        print('Please enter correct input among these 1/2/3/4/n')\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finforkgodara%2Fpython-calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finforkgodara%2Fpython-calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finforkgodara%2Fpython-calculator/lists"}