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.

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


This is my blueprint:

Input:

Please enter your details:
Subject: XXX
Units:3
Grade:A-


Output:
Grade points = Units "times" points of Grade

Example: Grade points = 3 x 3.70 = 11.10

My problem is my source code there,

if grade==A-:
grade_points=Units * A-

[ 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-"


Please solve my problems.
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!

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 = {}
gradepoints["A"] = 4.00
gradepoints["A-"] = 3.70
# 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.

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


This is my blueprint:

Input:

Please enter your details:
Subject: XXX
Units:3
Grade:A-


Output:
Grade points = Units "times" points of Grade

Example: Grade points = 3 x 3.70 = 11.10

My problem is my source code there,

if grade==A-:
grade_points=Units * A-

[ 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-"


Please solve my problems.
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.
My problem is already solved.

Thanks for giving me the guidance.^^
Thanks a lot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.