I am beginner...
I already install numpy,scipy and also Matplotlib....
Can anyone helps me?

I wanna to do a calculator program about how to calculate CGPA.

I still don't know how to write Python script for the grade as below.

A=4.00
A-=3.70
B+=3.30
B=3
B-=2.70
....

This is my blueprint:

Input:

Subject: XXX
Units:3

Output:

Example: Grade points = 3 x 3.70 = 11.10

My problem is my source code there,

[ My problem is there is an error at "if grade==A-:" and so on.]

Could anyone write a script for my blueprint of CGPA calculator?
I want to refer how to write it.

I am encountering problems that grade points store in variable:
A- = 3.70
But output is decreasing due to minus sign.
However, I wanna store number 4 into variable of "A-".
I know it is impossible to do that because of the sign.
In fact I don't want to use A_minus instead of A-,
If not, it will make the user key in difficulties due to typing A_minus, and it is not key in as "A-"

Thanks.
Thanks.

Note the rules of the "Starting Python" Thread:
Again, please do not clutter this thread with questions and homework problems!

The idea of this thread is to help the beginning Python programmer with hints and helpful code. Please feel free to contribute! If you have any questions start your own thread!

## All 3 Replies

The problem with using "A-" as a variable name is that it is illegal.

You can create a variable A_minus without any problem, but you don't want the user to be inputting your variable names anyway.

You will want to take their input as a string "A-" and use that to find the appropriate point multiplier.

This seems custom aligned for a dictionary.

``````gradepoints = {}
# put the rest of the relationships here
# There is an easier way to initialize dictionaries,
# feel free to find it and use it``````

Then you can use the user input to 'index' into the dictionary to get the point multiplier.

Try to use the idea in more of your own code and post any problems you find.

commented: Nice approach to help +6

I am beginner...
I already install numpy,scipy and also Matplotlib....
Can anyone helps me?

I wanna to do a calculator program about how to calculate CGPA.

I still don't know how to write Python script for the grade as below.

A=4.00
A-=3.70
B+=3.30
B=3
B-=2.70
....

This is my blueprint:

Input:

Subject: XXX
Units:3

Output:

Example: Grade points = 3 x 3.70 = 11.10

My problem is my source code there,

[ My problem is there is an error at "if grade==A-:" and so on.]

Could anyone write a script for my blueprint of CGPA calculator?
I want to refer how to write it.

I am encountering problems that grade points store in variable:
A- = 3.70
But output is decreasing due to minus sign.
However, I wanna store number 4 into variable of "A-".
I know it is impossible to do that because of the sign.
In fact I don't want to use A_minus instead of A-,
If not, it will make the user key in difficulties due to typing A_minus, and it is not key in as "A-"

Thanks.
Thanks.

Note the rules of the "Starting Python" Thread:
Again, please do not clutter this thread with questions and homework problems!

The idea of this thread is to help the beginning Python programmer with hints and helpful code. Please feel free to contribute! If you have any questions start your own thread!

Sorry and forgive me because I didn't read the rules.