{"id":18743885,"url":"https://github.com/devmarkson/cgpa-calculator-with-python","last_synced_at":"2025-11-21T23:30:14.868Z","repository":{"id":177742042,"uuid":"660837495","full_name":"DevMarkson/CGPA-Calculator-with-Python","owner":"DevMarkson","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-01T02:14:50.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-28T19:46:51.070Z","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/DevMarkson.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":"2023-07-01T01:44:35.000Z","updated_at":"2023-07-01T01:44:49.000Z","dependencies_parsed_at":"2023-07-19T00:46:27.594Z","dependency_job_id":null,"html_url":"https://github.com/DevMarkson/CGPA-Calculator-with-Python","commit_stats":null,"previous_names":["markson17/cgpa-calculator-with-python","devmarkson/cgpa-calculator-with-python"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FCGPA-Calculator-with-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FCGPA-Calculator-with-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FCGPA-Calculator-with-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FCGPA-Calculator-with-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevMarkson","download_url":"https://codeload.github.com/DevMarkson/CGPA-Calculator-with-Python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239627300,"owners_count":19670844,"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-07T16:12:55.164Z","updated_at":"2025-11-21T23:30:14.819Z","avatar_url":"https://github.com/DevMarkson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CGPA Calculator\n\nThis Python script calculates the Cumulative Grade Point Average (CGPA) based on course details provided in a CSV file named \"courses.csv\" located in the same directory as the script. It uses the `csv` module to read the CSV file and the `tabulate` library to display the course details in a tabular format.\n\n## Requirements\n- Python 3.x\n- `csv` module (comes pre-installed with Python)\n- `tabulate` library (install using `pip install tabulate`)\n\n## How to Use\n1. Ensure you have Python 3.x installed on your system.\n2. Install the required `tabulate` library by running `pip install tabulate` in your terminal or command prompt.\n3. Create a CSV file named \"courses.csv\" with the following format:\n\n   ```\n   Course Code, Course Unit, Grade\n   CSC101, 3, A\n   MAT201, 4, B\n   PHY301, 3, C\n   ...\n   ```\n\n   Replace the sample course codes, units, and grades with your actual course details. The grade should be one of the following: \"A\", \"B\", \"C\", \"D\", or \"F\". If any other grade is entered, it will be treated as invalid.\n\n4. Save the \"courses.csv\" file in the same directory as this script.\n\n5. Run the script using the following command:\n\n   ```\n   python cgpa_calculator.py\n   ```\n\n\n6. The script will process the course details from the \"courses.csv\" file and display them in a tabular format. It will also calculate the total unit, total score, and CGPA. The result will be printed in the terminal or command prompt.\n\n## Function Explanation\n\nThe script contains the following functions:\n\n### `get_grade_points(grade)`\nThis function takes a single argument `grade`, which represents the letter grade obtained in a course. It returns the corresponding grade points for the grade, and if the grade is invalid, it returns the string \"Invalid grade\".\n\n### `cgpa_calculator(csv_file)`\nThis is the main function that calculates the CGPA based on the course details provided in the CSV file. It takes the `csv_file` as an argument, which is the name of the CSV file containing course details.\n\nThe function does the following:\n- Initializes variables to store course information and cumulative values.\n- Reads course details from the CSV file.\n- Calculates the total score and grade points for each course.\n- Creates a table from the course details and displays it using the `tabulate` library.\n- Calculates the total unit, total score, and CGPA.\n- Returns the calculated CGPA as a formatted string.\n\nNote: If no courses are entered in the CSV file or if all grades are invalid, the function will return an appropriate message.\n\n## Example Output\n\nThe output of running the script will look like this:\n\n```\n╒═════════════╤═════════════╤═════════════╤═══════════════════╕\n│ Course Code │ Course Unit │ Grade Point │ Total Grade Point │\n╞═════════════╪═════════════╪═════════════╪═══════════════════╡\n│ CSC101      │ 3           │ 4           │ 12                │\n├─────────────┼─────────────┼─────────────┼───────────────────┤\n│ MAT201      │ 4           │ 3           │ 12                │\n├─────────────┼─────────────┼─────────────┼───────────────────┤\n| PHY301      | 3           | 2           | 6                 |\n├─────────────┼─────────────┼─────────────┼───────────────────┤\n│ Total       │ 10          │             │ 30                │\n╘═════════════╧═════════════╧═════════════╧═══════════════════╛\nTotal unit: 10\nTotal score: 30\nTotal CGPA is: 30.00/10.00\nYour CGPA is: 3.00/4.00\n```\n\nThe table displays the course code, course unit, grade point, and total grade point for each course. The total unit, total score, and CGPA are also shown.\n\nIf there are no courses entered or if all grades are invalid, the script will display an appropriate message.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmarkson%2Fcgpa-calculator-with-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevmarkson%2Fcgpa-calculator-with-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmarkson%2Fcgpa-calculator-with-python/lists"}