I am doing my homework and am having trouble on a certain problem.
4) A certain CS professor gives 100-point exams that are graded on the scale 90-100:A, 80-89:B, 70-79:C, 60-69:'D, <60:F. Write a program that accepts an exam score as input and prints out the corresponding grade.
We have not learned any kind of an "if" statement in my class yet. I did a problem before this one that was similar:
3) A certain CS professor gives 5-point quizzes that are graded on the scale 5-A, 4-B, 3-C, 2-D, 1-F, 0-F. Write a program that accepts a quiz score as an input and prints out the corresponding grade.
I know I could do simultaneous assignment for each number through 100, but I know there is a better / easier way. I think I need to use a loop (we know the for loop) somehow or go back to the list. Also, I believe I would need to incorporate range(). I am drawing a blank. How can I go about solving my problem without using any kind of if statements?
I think you can use pretty much the same list that you used for the simpler problem. All you need to come up with is a formula to calculate the index for each grade.
The above needs another element at the end of the list so it will handle a perfect score of 100%. I modified the program to test all possible values. It's still not elegant.
omg are you in prof rivera's class??? I'm currently a student with him and we have the exact same problem (hmwk 2) it's sooo hard and i was searching for some help as well...if you're not in the class your question really helped me out. so thanks
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Previous Thread in Python Forum Timeline:python help