Backstory (if you need one)You're in charge of keeping track of the results of a foot race, but you didn't write down the finishers in any particular order, and your notes might also contain a few...


Backstory (if you need one)


You're in charge of keeping track of the results of a foot race, but you didn't write down the finishers in any particular order, and your notes might also contain a few corrections. Write a program where you can enter your records, that will then print out the full results in order.


User interaction:



  • Ask the user how many runners were in the race

  • Based on how many runners there were, create a list that is exactly the right size to hold that many names


  • Repeatedly ask the user



    • Which place they would like to edit

    • What the name of the runner who finished in that place is

    • If they enter "-1" for the place to edit, they are done editing

    • If the user wishes to edit a place they have already edited, just replace the previous name with the new name. No need to do anything special about this situation.



  • Once they are finished editing, print out the results of the race


    • See sample runs below for the required format

    • If they never stated who finished in one of the places, state that this name is missing


      • See section on "None" below




  • You must write and use at least one function:


    • This extra function should handle printing the race results at the end. You'll need to pass in your list of runner names as a parameter. No return value is needed for this function.


      • You are certainly encouraged to decompose into more functions as you see opportunities, but that one is a requirement.



      • You should include a comment above each function explaining


        • What this function is used for

        • What information the user is expected to supply as parameters to the function

        • What the return value (if there is one) will mean to whoever called the function

        • You should include type hints for all function parameters and return types









"None"



  • We showed a few examples of creating lists with the right capacity but no actual data stored yet. There's a special value built into Python named None (with no quotation marks) that we use to mark these blank spots.


    • You can compare list positions to the value None using the is operator, like



      • if myList[i] is None:



    • If this is giving you trouble, contact the professor or a Tutor Lab TA ASAP rather than trying to go it alone and getting frustrated.




Things you are not required to deal with:



  • Assume that the user will not try to edit any non-existent places (so if they say there are 4 runners, they will not try to edit the 7th place runner)


  • Things you are required to handle

  • Your list must be sized exactly right. If you just block off a list of size 1000 when there are only 5 runners, you'll lose points.

  • For no extra credit but also no penalty, you can just put a "th" after each place number


  • For up to 2 points extra credit, you must get number suffixes correct based on:


    • Numbers ending in a '1' except numbers ending in '11' must have a suffix of "st", such as "1st"

    • Numbers ending in a '2' except numbers ending in '12' must have a suffix of "nd", such as "2nd"

    • Numbers ending in a '3' except numbers ending in '13' must have a suffix of "rd", such as "3rd"

    • All other numbers will have a suffix of "th", such as "5th"




  • Plan this out before you start coding.

    • When you do start coding this up, tackle it one little piece at a time, and test as you go.


      • Perhaps just start by asking the user what place to edit and what the name is until they enter -1 (not bothering to actually store anything yet).

      • Once you have that part working properly, add in actually storing the names and repeating the runner names back to the user at the end.

      • Once you have that working, add in getting the number suffixes correct, detecting missing runners, etc.









  • Basic Point Breakdown:





    • 4pts: Collecting number of runners and allocating a blank list of correct size
      5pts: Correctly looping during input and storing names using correct index
      2pt: Stop editing when user enters "-1"
      5pts: Output race results in order as a separate method
      2pt: State that a racer is missing (rather than just printing "None")
      2pt: formatting, coding style, comments
      2pt extra credit: Number suffixes






Sample Runs:


How many people ran in the race? 3
What place would you like to edit? (-1 to finish) 3
Who finished in 3rd place? Shawn
What place would you like to edit? (-1 to finish) 1
Who finished in 1st place? Burton
What place would you like to edit? (-1 to finish) 2
Who finished in 2nd place? Juliet
What place would you like to edit? (-1 to finish) -1
The results of the race are:
Burton finished in 1st place.
Juliet finished in 2nd place.
Shawn finished in 3rd place.
Sample run 2:
How many people ran in the race? 6
What place would you like to edit? (-1 to finish) 4
Who finished in 4th place? Jay
What place would you like to edit? (-1 to finish) 3
Who finished in 3rd place? Jesse
What place would you like to edit? (-1 to finish) 4
Who finished in 4th place? Hunter
What place would you like to edit? (-1 to finish) 5
Who finished in 5th place? Jay
What place would you like to edit? (-1 to finish) 1
Who finished in 1st place? Barry
What place would you like to edit? (-1 to finish) -1
The results of the race are:
Barry finished in 1st place.
You didn't say who finished in 2nd place.
Jesse finished in 3rd place.
Hunter finished in 4th place.
Jay finished in 5th place.
You didn't say who finished in 6th place.


Sample run 3:
How many people ran in the race? 25
What place would you like to edit? (-1 to finish) 14
Who finished in 14th place? Todd
What place would you like to edit? (-1 to finish) 17
Who finished in 17th place? Rodd
What place would you like to edit? (-1 to finish) 25
Who finished in 25th place? Martin
What place would you like to edit? (-1 to finish) 6
Who finished in 6th place? Sheri
What place would you like to edit? (-1 to finish) 9
Who finished in 9th place? Edna
What place would you like to edit? (-1 to finish) 2
Who finished in 2nd place? Patty
What place would you like to edit? (-1 to finish) 18
Who finished in 18th place? Hans
What place would you like to edit? (-1 to finish) -1
The results of the race are:
You didn't say who finished in 1st place.
Patty finished in 2nd place.
You didn't say who finished in 3rd place.
You didn't say who finished in 4th place.
You didn't say who finished in 5th place.
Sheri finished in 6th place.
You didn't say who finished in 7th place.
You didn't say who finished in 8th place.
Edna finished in 9th place.
You didn't say who finished in 10th place.
You didn't say who finished in 11th place.
You didn't say who finished in 12th place.
You didn't say who finished in 13th place.
Todd finished in 14th place.
You didn't say who finished in 15th place.
You didn't say who finished in 16th place.
Rodd finished in 17th place.
Hans finished in 18th place.
You didn't say who finished in 19th place.
You didn't say who finished in 20th place.
You didn't say who finished in 21st place.
You didn't say who finished in 22nd place.
You didn't say who finished in 23rd place.
You didn't say who finished in 24th place.
Martin finished in 25th place.
Nov 15, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here