Nov-16-2019, 04:47 AM
Hello. I'm working on a problem where I ask a user for input on 3 test scores in the format "score/max" and then I am to find the average. I am running into trouble with the code though. I attempted to break the code down to find the error. Here is what I have so far:
*** Note this is python 2.7. I know it's obsolete but the assignment requires it to be done in 2.7***
When I run this block of code, though, it only prints 0. What am I missing here?
*** Note this is python 2.7. I know it's obsolete but the assignment requires it to be done in 2.7***
#!/usr/bin/python import math import string from string import split first = raw_input("Please Enter your First exam score in the form score/max: ") first_numerator = eval(first.split("/")[0]) first_denom = eval(first.split("/")[1]) first_score = ((first_denom / first_numerator)) print(first_score)I checked the first_denom and first_numerator to make sure it is splitting up the scores correctly and they are.
Quote:Please Enter your First exam score in the form score/max: 96/100
96 #first_numerator
100 #first_denom
When I run this block of code, though, it only prints 0. What am I missing here?