I’m here not with a question of specific coding, but more of a query on how to generate specific variable outputs without using if statements.
To make it clearer here is an example: Mr. Smith is giving out 5 point quizzes that are graded on a scale of 5-A, 4-B, 3-C, 2-D, 1-E, 0-F. Create a program which accepts a the quiz score (1-5) as an input and prints out the corresponding grade without using if statements.
So hopefully that makes my dilemma much clearer. I’m looking for a way to associate the grade (A-F) with the corresponding quiz score (1-5) without using an if statement. I’m still fairly new to python and you could call me a slow learner but any help is appreciated!
You could use:
This works by taking the character at position
scorein the string'FEDCBA':Fis at position0,Eis at position1and so on.For example: