Jenith is a student of CSE of Metropolitan University (MU). Recently her fifth term’s result has bee…
Click here to read the complete problem statement.
If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.
I am getting runtime error on Case no 21 , What might be problem in my code bellow?
def gpacalc(marks,credit):
gpc=0
if marks>=80 and marks<=100:
gp=4.00
gpc=float(gpc)
gpc=gp*credit
return gpc
if marks>=75 and marks<80:
gp=3.75
gpc=float(gpc)
gpc=gp*credit
return gpc
if marks>=70 and marks<75:
gp=3.50
gpc=float(gpc)
gpc=gp*credit
return gpc
if marks>=65 and marks<70:
gp=3.25
gpc=float(gpc)
gpc=gp*credit
return gpc
if marks>=60 and marks<65:
gp=3.00
gpc=float(gpc)
gpc=gp*credit
return gpc
if marks>=55 and marks<60:
gp=2.75
gpc=float(gpc)
gpc=gp*credit
return gpc
if marks>=50 and marks<55:
gp=2.50
gpc=float(gpc)
gpc=gp*credit
return gpc
if marks>=45 and marks<55:
gp=2.25
gpc=float(gpc)
gpc=gp*credit
return gpc
if marks>=40 and marks<45:
gp=2.00
gpc=float(gpc)
gpc=gp*credit
return gpc
t=int(input())
for i in range(t):
total_credit=0
count=0
sumation=0
gpc=0
course=int(input())
for j in range(1,course+1):
marks,credit=map(float,input().split())
total_credit+=credit
if marks>=40 and marks<=100:
sumation=(sumation+gpacalc(marks,credit))
gpa=sumation/total_credit
else:
count+=1
if count==0:
print("Case {0}: {1:.2f}".format(i+1,gpa))
elif count==1:
print("Case {}: Sorry, you have failed in 1 course!".format(i+1))
else:
print("Case {0}: Sorry, you have failed in {1} courses!".format(i+1,count))
The problem states what to print if you failed any courses. However, it doesn’t state that “course” needs to be pluralized (“course” if 1 fail, “courses” if > 1). Please update the problem statement.
def gpacalc(marks,credit):
if 80 <= marks <=100: gp = 4.00
elif 75 <= marks <80: gp = 3.75
elif 70 <= marks <75: gp = 3.50
elif 65 <= marks <70: gp = 3.25
elif 60 <= marks <65: gp = 3.00
elif 55 <= marks <60: gp = 2.75
elif 50 <= marks <55: gp = 2.50
elif 45 <= marks <55: gp = 2.25
elif 40 <= marks <45: gp = 2.00
gpc=gp*credit
return gpc
t=int(input())
results=[]
for i in range(t):
total_credit=0
count=0
sumation=0
course=int(input())
for j in range(course):
marks,credit=map(float,input().split())
total_credit+=credit
if 40 <= marks<=100:
sumation+=gpacalc(marks,credit)
gpa=sumation/total_credit
else:
count+=1
if count==0:
results.append("Case {0}: {1:.2f}".format(i+1,gpa))
elif count==1:
results.append("Case {0}: Sorry, you have failed in {1} course!".format(i+1,count))
else:
results.append("Case {0}: Sorry, you have failed in {1} courses!".format(i+1,count))
for result in results:
print(result)
It seems there was a bug in Toph that was causing your submission verdict to appear as Wrong Answer. The bug has been fixed. Your actual verdict is Runtime Error. Your submission has been rejudged.
@Fariha.Brotecs One issue that I can see in your code is that your second and third printfs do not have “\n” at the end. All your cases will end up appearing on the same line with no space in-between.