Question: Objective Practice if statements Practice with loops Practice with formatted output Assignment In this lab we will use Python to ask the user for information

Objective

Practice if statements

Practice with loops

Practice with formatted output

Assignment

In this lab we will use Python to ask the user for information about the classes they are taking this semester, and then determine their grade point average (GPA) for that semester. To determine a students GPA, you divide the number of honor points by the number of attempted credits. To determine honor points, multiple the number of credits by either 4 for an A, 3 for a B, 2 for a C, 1 for a D, or 0 for an F. This program will ignore grades of pass, fail, or incomplete.

The program will ask the user for a class. If a class has been entered (such as CS160), ask for the number of credits and the grade. Continue to ask for class, and then the credits and grade, until the user enters nothing for the class. Do not ask for the number of credits and grade if the user does not enter a class.

For example, if you received a 4 credit A and a 3 credit B in a semester, for honor points you will earn:

4 * 4(A) = 16

3 * 3(B) = 9

25 honor points / 7 attempted credits = 3.571429, which will be truncated in the output to 3.571.

You can safely assume that no grade other than A, B, C, D, or F will be entered.

You cannot assume that the grade will be entered as an upper case letter, if could be a lower case letter.

A students GPA defaults to 0.0 if their GPA cannot be calculated. This is consistent with student GPA s, as discussed in class.

Once the user is done entering their classes, print out the following:

Grade point average, with 3 places after the decimal point

Number of credits attempts

Number of credits passed (any grade other than an F)

Number of classes attempted

Number of classes passed (any grade other than an F)

Ensure that the output has neatly aligned columns, with the text left justified and all the numbers right justified.

Sample output (this is typed, not captured from a run)

An example of running the program might be:

Enter a class: CS160

Enter the number of credits: 4

Enter your grade: A

Enter the next class: Math 208

Enter the number of credits: 3

Enter your grade: B

Enter the next class:

GPA: 3.571

Credits attempts 7

Credits passed 7

Classes attempted 2

Classes passed 2

This is what I have been inputting and it is not coming out right (I am using python shell). Any idea of what I need to do from scratch?

Objective Practice if statements Practice with loops Practice with formatted output Assignment

>>> pas=0 >>> attempt=0 >>> honor=0 >>> c1=0;c2=0; c3=0; c4=0; C5-0 >>> g1=0;92-0;93-0; 94-8; 95-0 >>> cls=input("Enter a class: ") Enter a class: CS160 >>> while True: honor-honor+1 cred=int(input("Enter the number of credits: ") grad=input("Enter you grade: ") if grade-'A': c1-4 91-c1**2 if grad=='B': c2-3 92-c2** 2 if grad=='C': c3-2 g3-c3**2 if grad=='D': c4-1 94-c4** 2 else: c5-0 g5=c5**2 credit=c1+2+c3+04+05 attempt=91+g2+g3+34+95 grade-attempt/credit if grad!='F': pas+-1 cls1=input("Enter the next class: ") if cls1--"": break print('GPA:%.3f' % grade) print('Credits attempts', credit) print('Credits passed ', credit) print('Classes attempted ', honor) print('Classes passed ',pas) Enter the number of credits: 4 Enter you grade: A Enter the next class: 3 GPA: 4.000 Credits attempts 4 Credits passed 4 Classes attempted 6 Classes passed 2 Enter the number of credits: 3 Enter you grade: B Enter the next class: 2 GPA:3.571

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The image you uploaded seems to contain some Python code along with inputoutput examples If youre ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!