Program 1: GPA Calculator
Logistics
- Due Date: Sunday, May 21st no later at 11:59 p.m.
- Partner Information:You may complete this assignment individually or with exactly one partner.
- Submission Instructions (working alone): Upload your solution (.py file), entitled YourFirstName-YourLastName-Program1.py to the BrightSpace(D2L) Program 1 Dropbox.
- Submission Instructions (working with a partner): Upload your solution (.py file), entitled YourFirstName-YourLastName-PartnerFirstName-PartnerLastName-Program1.py to the BrightSpace(D2L) Program 1
- Deadline Reminder: Late passes can be used on this assingment. However, if you do not use a late pass and submit it past the deadline, you submission will lose some points (see late assingment policy). After 48 hours,
the dropbox will close and you will no longer be able to submit
In order to complete this lab, you will need to understand
- Iteration
- If statements
- Functions
- Variables and data types
- User input
Background Information
- At Montana State University, the following grades have
the following values:
A (4.0), A- (3.7), B+ (3.3), B (3.0), B- (2.7), C+ (2.3),
C (2.0), C- (1.7), D+ (1.3), D (1.0) and F (0.0).
- Example GPA Calculation: If a student earns an A in a 3 credit course
and a B- in a 2 credit course, that student's GPA can be
calculated as (4.0 * 3 + 2.7 * 2) / (3 + 2).
Assignment
- Write a Python program that prompts the user for the
number of classes taken and then for each class, the letter grade
received (e.g. B+) and the number of credits (e.g. 3). Once this
information is known, the program should calculate
and display the overall GPA (rounded to two digits).
You will have a main function that asks for the number of classes, and the letter grade/credit for each of those classes. It will then calculate the final GPA and print it out to the screen (see sample output).
You will also have a translate function, which will be called from main(). The translate function will take in a letter grade as input parameter (e.g. b+ or B+) and return the correct decimal value (e.g. 3.3). Note that the user can input a letter grade
in uppercase (A-) or in lowercase (a-) and your translate function should still work.
Assumptions
- The user will take at least one and no more than seven courses.
- Each course is either 1, 2, 3, 4 or 5 credits.
- A grade can be entered in uppercase or lowercase.
For example, either A- or a-.
- All user inputs will be valid.
Required Output
When your program is run, it should look exactly like this example output
Helpful Examples
Required Python Comment
Place a Python comment at the top of your Python solution that is formatted as follows
# -----------------------------------------+
# Your name | <-- e.g. Reese Pearsall
# CSCI 127, Program 1 |
# Last Updated: Month Day, Year | <-- e.g. May 5, 2021
# -----------------------------------------|
# A brief description of the assignment. | <-- can be more than 1 line
# -----------------------------------------+
Grading - 100 points
- 35 points - The GPA calculation is correct.
- 15 points - The user is prompted to enter the number of courses
(5 points), the letter grade for each course (5 points) and
the credits for each course (5 points).
- 10 points - With the exception of the GPA, the output
format matches the output format of the example output provided
(2 points for each type of difference up to 10 points).
- 5 points - The GPA is displayed with two digits to the
right of the decimal.
- 10 points - A function named translate is defined that
takes a letter grade (e.g. b- or B-) and correctly returns its value
(e.g. 2.7).
- 10 points - A function named main is defined (5 points).
The only python statement that does not appear in this function
or the translate function is the call to the main function,
e.g. main() (5 points).
- 10 points - The Python solution is easy to understand and does
not contain unnecessary code (2 points for each
type of improvement up to 10 points).
- 5 points - An appropriate Python comment appears at the top of
the submission. See below for the type of information that
should appear.