addSuffix(21) -> '21st'
addSuffix(2) -> '2nd'
addSuffix(111) -> '111th'
Project 3 asks you to apply the correct suffixes for integers >= 1. The input to addSuffix function should be returned as a string followed by one of these four choices: 'th' 'st' 'nd' 'rd'
What would these function calls return?
addSuffix(1) -> '1st'
addSuffix(121) -> '121st'
addSuffix(12) -> '12th'
The following rules can help us understand what we are supposed to do (From Wikipedia):
If the tens digit of a number is 1, then write "th" after the number.
For example: 13th, 19th, 112th, 9,311th.
If the tens digit is not equal to 1, use the table:
For example: 2nd, 7th, 20th, 23rd, 52nd, 135th, 301st.
Fill in the values that should be returned from def addSuffix(num):
addSuffix(1) -> ___1st______
addSuffix(2) ® ___2nd_________
addSuffix(3) ® ___3rd_________
addSuffix(4) ® ___4th_________
addSuffix(10) ® ____________
addSuffix(11) ® ____________
addSuffix(14) ® ____________
addSuffix(20) ® ___________
addSuffix(101) ® ____101st___
addSuffix(102) ® ___102nd__
addSuffix(103) ® ___103rd____
addSuffix(104) ® ___104th___
addSuffix(111) ® _111th___
addSuffix(121) ® _121st___
addSuffix(113) ® _113th___
addSuffix(123) ® ____________
Hint: Before coding this program, consider how to get the "tens digit" from a number. You could write a method
The following should return 1 And these should not
tensDigit(10) tensDigit(1)
tensDigit(19) tensDigit(9)
tensDigit(919) tensDigit(21)
tensDigit(9812) tensDigit(131)