| Filename | Description | 
|---|---|
| load_list_of_lists.py | Definition of load_list_of_lists method | 
| framescore.py | Definition of frame_score method | 
| testframescore.py | Unit test file for frame_score method | 
| bowling.py | Main source code file that calls other methods and implements the pseudocode | 
| game1.txt, game2.txt, game3.txt | Input files that contain game scores | 
Frame Number      1       2       3       4       5       6       7       8       9      10     Bonus       
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
Ball Scores   | 8 | 0 | 7 | 2 | 6 | 0 | 6 | 2 | 0 | 8 | 6 | 1 | 9 | 0 | 8 | 0 | 8 | 1 | 5 | 2 |   |   |
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
Frame Scores  |   8   |   9   |   6   |   8   |   8   |   7   |   9   |   8   |   9   |   7   |       |
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
Running Total |   8   |  17   |  23   |  31   |  39   |  46   |  55   |  63   |  72   |  79   |       |
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
The total score for Game 1 is 79.
Frame Number      1       2       3       4       5       6       7       8       9      10     Bonus       
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
Ball Scores   | 8 | 1 | 7 | / | 5 | 3 | 0 | / | 7 | / | 9 | / | 9 | 0 | 8 | / | 8 | 1 | 5 | / | 1 |   |
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
Frame Scores  |   9   |  15   |   8   |  17   |  19   |  19   |   9   |  18   |   9   |  11   |       |
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
Running Total |   9   |  24   |  32   |  39   |  68   |  87   |  96   | 114   | 123   | 134   |       |
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
In Game 2, Frame 2, the score is 10 for the spare plus the bonus ball 5, which is 
the first ball in Frame 3: 10 + 5 = 15.  
Frame Number      1       2       3       4       5       6       7       8       9      10     Bonus       
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
Ball Scores   | 8 | 1 | X |   | 6 | / | 8 | 1 | 9 | / | X |   | X |   | X |   | 9 | / | X |   | X | 8 |
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
Frame Scores  |   9   |  20   |  18   |   9   |  20   |  30   |  29   |  20   |  20   |  28   |       |
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
Running Total |   9   |  29   |  47   |  56   |  76   | 106   | 135   | 155   | 175   | 203   |       |
              +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
In Game 3, Frame 2, the score is 10 for the strike plus the next two balls, which are 6 and 4: 10 + 6 + 4 = 20.| Game Number | File Name | List of Lists | 
|---|---|---|
| Game 1 | game1.txt | ["Frame0", [8,0],[7,2],[6,0],[6,2], [0,8],[6,1],[9,0],[8,0],[8,1],[5,2]] | 
| Game 2 | game2.txt | ["Frame0", [8,1],[7,3],[5,3],[0,10], [7,3],[9,1],[9,0],[8,2],[8,1], [5,5],[8]] | 
| Game 3 | game3.txt | ["Frame0", [8,1],[10],[6,4],[8,1], [9,1], [10],[10],[10], [9,1], [10],[10],[8]] | 
def frame_score(the_frame, next_ball_1, next_ball_2):
# Case where frame is a strike
If the_frame[0] is equal to 10
    Return 10 plus next_ball_1 plus next_ball_2.
    
# Case where frame is a spare
Else if the_frame[0] plus the_frame[1] is equal to 10
    Return 10 plus next_ball_1.
    
# Case where frame is an open frame
Else
    Return the_frame[0] plus the_frame[1].
End if
 
# Filename: testframescore.py
import unittest
from framescore import frame_score
class TestFrameScore(unittest.TestCase):
    def test_1(self):
        self.assertEqual(frame_score([10], 10, 7), 27)
    def test_2(self):
        self.assertEqual(frame_score([7, 3], 9, 0), 19)
    def test_3(self):
        self.assertEqual(frame_score([7, 1], 0, 0), 8)
if __name__ == '__main__':
    unittest.main()
Import the frame_score method from 
the file framescore.py
Import the load_list_of_lists method from 
   the load_list_of_lists.py file.
   
read inputfile from keyboard, promping user. 
Call the load_list_of_lists method to create
   a list of lists of the data in an input file like
   game1.txt, game2.txt, or game3.txt.
Assign the list of lists to the variable frames.
Initialize score to 0.
For i in the range from 1 to 10 (use range(1, 11))
   if frames[i][0] equals 10 and frames[i+1][0] equals 10
      assign 10 to next_ball_1.
      assign frames[i+2][0] to next_ball_2. 
   elsif frames[i][0] equals 10 and frames[i+1][0] < 10
      assign frames[i+1][0] to next_ball_1.
      assign frames[i+1][1] to next_ball_2.
   elsif frames[i][0] + frames[i][1] equals 10
      assign frames[i+1][0] to next_ball_1.
      assign zero to next_ball_2.
   else
      assign zero to next_ball_1.
      assign zero to next_ball_2.
   end if
   # Next line is actual Python statement.   
   score += frame_score(frames[i], next_ball_1, next_ball_2)
End loop.
Print score.