Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Final exam calculator
#1
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...")
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  final web password form robertkwild 1 363 Aug-07-2024, 09:12 AM
Last Post: wewer
  Python institute associate sample exam question CrusaderT 2 2,122 Aug-30-2020, 07:20 AM
Last Post: CrusaderT
  Blending calculator from final product xerxes106 0 1,873 Dec-05-2019, 10:32 AM
Last Post: xerxes106
  How to Stop Sentinel Value from Entering Final Output ZQ12 3 3,924 Nov-11-2019, 07:25 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020