Python Forum
Final exam calculator - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Final exam calculator (/thread-1504.html)



Final exam calculator - iliketocode - Jan-08-2017

Hi guys, I am trying to create a program that tells you what you need to get on an assignment to get a certain grade. However, if you need to get a negative percentage on the assignment, I want to have a message displayed saying something. That doesn't seem to be working. I have also just started python. The same is true for when he person needs to get a little above 100% on the assignment.

name = input("What is your name? ")
print("So " + name + ", I heard you want to find out what you need to get on a project/test/quiz/classwork/homework to get a certain grade.")  
print("What is the type of assignment? (project/test/quiz/classwork/homework)")
assignment_type = input()
assignment_weight = int(input("How much are " + assignment_type + "s worth of your overall grade? %"))
current_grade = int(input("What is your current grade in the subject? %"))
desire_grade = int(input("What grade do you want to get? %"))
grade_you_need_to_get = (desire_grade / 100 - (1 - assignment_weight / 100) * current_grade / 100) / assignment_weight / 100
print("You need to get " + str(grade_you_need_to_get * 1000000) + "% to get " + str(desire_grade) + "% on your " + assignment_type + " grade.")
if int(grade_you_need_to_get) < 0:
   print("Just draw a flower on the test or something.")

elif grade_you_need_to_get > 100 and grade_you_need_to_get < 110:
   print ("I hope there's extra credit...")



RE: Final exam calculator - ichabod801 - Jan-08-2017

Because of the odd way you've calculated things, you need to multiply it by 10000000 to get it in the 1-100 range. You do that for the output, but you don't do that when testing it for the printing. I would do it once to the variable before the output. Then you don't have to do it for the output or the test.

One thing to learn is the format method of strings. That will make your output easier.