Ryerson letter grade
Tags: Algorithms Math Parsing
Credit: Ilkka Kokkarinen
Difficulty: Easy
Type: Text
Category: Practice
Time Allowed: 15 s
Description:
Before the name change in the year 2022, Toronto Metropolitan University was known as Ryerson University. Given the percentage grade, calculate and return the letter grade that would appear in the Ryerson grades transcript. This letter grade should be returned as a string that consists of the uppercase letter followed by the modifier '+' or '-', if there is one. This function should work correctly for all values of pct from 0 to 150.
Same as all other programming problems that follow this problem, this can be solved in various different ways. The simplest way to solve this problem would probably be to use an if-else ladder. The file labs109.py
given in the repository ikokkari/PythonProblems
already contains an implementation of this function for you to run the tester script tester109.py
to verify that everything is hunky dory.
As you learn more Python and techniques to make it dance for you, you may think up other ways to solve this problem. Some of these would be appropriate for actual productive tasks done in a professional coding environment, whereas others are intended to be taken in jest as a kind of conceptual performance art. A popular genre of recreational puzzles in all programming languages is to solve some straightforward problem with an algorithmic equivalent of a needlessly complicated Rube Goldberg machine
, to demonstrate the universality and unity of all computation.
Test Case | Input | Expected Output |
---|---|---|
1 | 3 | 'F' |
2 | 50 | 'D-' |
3 | 60 | 'C-' |
4 | 70 | 'B-' |
5 | 80 | 'A-' |
6 | 90 | 'A+' |
Leave a Comment
Please login to leave a comment.