Question

PYTHON ONLY!! PLEASE PUT COMMENTS EXPLAINING THE CODE. Write a program that keeps reading an exam...

PYTHON ONLY!!

PLEASE PUT COMMENTS EXPLAINING THE CODE.

Write a program that keeps reading an exam score until a -1 is entered. The program will output the letter grade according to the table below:

Score    Grade
90-100     A
80-89       B
70-79       C
60-69       D
< 60         F

For example:
Enter a Score (-1 to Exit): 92
The Letter grade for that score is A.

Enter a Score (-1 to Exit): -1

0 0
Add a comment Improve this question Transcribed image text
Answer #1
# Method to get letter grade from score
def letterGrade(score):
    if score < 60:
        letter = 'F'
    elif score < 70:
        letter = 'D'
    elif score < 80:
        letter = 'C'
    elif score < 90:
        letter = 'B'
    else:
        letter = 'A'
    return letter

def main():
    # Reading input
    score = int(input("Enter a Score (-1 to Exit): "))
    # Checking sentinel value
    while score!=-1:
        # Printing result
        print("The Letter grade for that score is",letterGrade(score)+str("."))
        # Reading input
        score = int(input("Enter a Score (-1 to Exit): "))

main()

Add a comment
Know the answer?
Add Answer to:
PYTHON ONLY!! PLEASE PUT COMMENTS EXPLAINING THE CODE. Write a program that keeps reading an exam...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT