Question: Hi I need help with this program I have no cue on what they want me to do can some please help me out thank
Hi I need help with this program I have no cue on what they want me to do can some please help me out thank you.
Consider the following program that allows a user to print the age of the Nth oldest known person to have ever lived:
Modify the program to print "1st", "2nd", "3rd", "4th" and "5th" rather than "1th", "2th", etc., without introducing redundant statements (Hint: Precede the below if statement with a separate elif statement that determines the appropriate ending based on the number).
oldest_people = [122, 119, 117, 117, 116] # Source: Wikipedia.org
nth_person = int(input('Enter N (1-5): '))
if (nth_person >= 0) and (nth_person <= 5): print('The %dth oldest person lived %d years' % \ (nth_person, oldest_people[nth_person-1])) elif (nth_person >= -1) and (nth_person <= 5): print('The %dth oldest person lived %d years' % \ (nth_person, oldest_people[nth_person-1]))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
