# Day 013 - Project 13 : Grade Generator

If you have any questions, comments or issues with this project please post them here!

Built a grade calculator today! Definitely giving myself an A+ on this !

Day 13 of #Replit100DaysOfCode #100DaysOfCode.

2 Likes

Hiya!
I cannot assign grade to the last line:

Maybe def function I wrote wrong?

``````def grade(grade_in_percentage):

import time
print("This program will generate grade according percentage of exam.")
time.sleep(1)

print("")
name_of_exam= input("Please, type the name of exam subject: ")
time.sleep(1)

print("")
max_possible_score = int(input("Input the maximum possible score of the exam: "))
time.sleep(1)

print("")
your_score = int(input("Write your score of the exam: "))
time.sleep(1)

print("")

return "A+"
return "A"
return "B"
return "C"
return "D"
else:
return "U"

time.sleep(1)
print("Name of the exam subject: " + name_of_exam)
time.sleep
print("Max. Possible score " + str(max_possible_score))
time.sleep(1)
print("Your score is: " + str(your_score))
time.sleep(1)
``````

Good luck to all coders!

I got it right. But I’m gonna try to write it the same with function return and bisect.

``````import time
print("This program will generate grade according percentage of exam.")
time.sleep(1)

print("")
name_of_exam= input("Please, type the name of exam subject: ")
time.sleep(1)

print("")
max_possible_score = int(input("Input the maximum possible score of the exam: "))
time.sleep(1)

print("")
your_score = int(input("Write your score of the exam: "))
time.sleep(1)

print("")

time.sleep(1)
print("Name of the exam subject: " + name_of_exam)
time.sleep (1)
print("Max. Possible score " + str(max_possible_score))
time.sleep(1)
print("Your score is: " + str(your_score))
time.sleep(1)

print("A")
print("A-")
print ("B")
print ("C")
print ("D")
else:
print ("U")
``````

Hi @interpio thanks for your posts. Functions (`def`) need the code underneath it to be indented e.g.

``````import time

print("This program will generate grade according percentage of exam.")
time.sleep(1)
``````

I’d also recommend putting all the `import` lines at the top of your code.

Hope this helps!

Thanks. I’ve just started to learn how to create functions.

1 Like

I find it annoying, that I can not go back to previous days lessons to view the tutorial, when I am stuck. Is that somehow possible?
When doing the day 13 challenge, I am getting a syntax error in line 9 - the < sign, but I don´t know why? (I have never coded before, so sorry for the newbie question!) Can you help?

My code:

``````test=input("Name a test you recently did? ")
maxScore=int(input("What was the maximum score in the test? "))
score=int(input("What was your score in the test? "))
percentage=float(score/maxScore)*100
percentage=(round(percentage, 2))
print("Your score in percentage was: ", percentage, "%")
if percentage <50:
elif percentage >=50 and <=59:
elif percentage =>60 and <=69:
elif percentage =>70 and <=79:
elif percentage =>80 and <=89:
elif percentage =>90:
else:
print("That seems wrong")
``````

By the way, I have tried finding previous lessons via URL, but the URL for day 8 and 9 doesn´t follow logic??

All my prints are indented - don’t know why that doesn´t show up here, so that is not the mistake

It doesn’t show up here because you need to format your code. Put three backticks then `py` (```py) then start a new line and paste your code. Then do another three backticks. It should look something like this:

` ```py`
`# your code here`
`````

The line after else needs to be properly indented btw

Thank you - i will do that going forward

Yes, you are right - I have fixed it, but it still says invalid syntax with a red arrow pointed at the < in line 9?

Of course, you cannot do this

elif percentage >=50 and <=59:

But need this

elif percentage >=50 and percentage<=59:

You can use : `elif 50 <= percentage <= 59:` syntax if you don’t like repeating yourself :))

Also pay attention to identation. Python is very sensitive about that! Almoust as sensitive as my wife to my snoring …

1 Like

or
`elif percentage in range(50, 60):`

Ahhh… thank you! Ha, I feel your poor wife Question:

``````print("Exam Grade Calculator")
nameOfExam = input("What is the name of your exam?")
print("The maximum possible score for this exam was 50.")
score = input("What score did you recieve in your", nameOfExam, "?")
percentage = (score/50)*100
if percentage => float("90"), round
print("Fab, you got an A+!")
else:
print("Boo sucks to you:(")
``````

There is an error in the if percentage part, but I forgot how to construct this part of the code. Can someone help me?

Hey @anannaislam, welcome to the community!

I’m not sure what happened on your if statement there. Maybe just replace `, round` with `:`?

And also you can just check `if percentage >= 90`, don’t need to cast that from a string to a float.

Feel free to message me and I can fix formative on posts like this 1 Like