[Solved] 2011 07 02 Red Sox 7astros 5minute Maid Park 2011 07 03 Red Sox2astros1minute Maid Park 20 Q37159416
2011-07-02 Red Sox 7Astros 5Minute Maid Park 2011-07-03 Red Sox2Astros1Minute Maid Park 2011-07-04 Red Sox7Blue Jays9Fenway Park2011-07-05 Red Sox3Blue Jays2Fenway Park2011-07-06 Red Sox6Blue Jays4Fenway Park 2011-07-07 Red Sox10Orioles4Fenway Park2011-07-08 Red Sox 10Orioles3Fenway Park2011-07-09 Red Sox 4Orioles0Fenway Park2011-07-10 Red Sox 8Orioles6Fenway Park2011-07-15 Red Sox 6Rays9Tropicana Field2011-07-16 Red Sox 9Rays5Tropicana Field2011-07-17 Red Sox 1Rays0Tropicana Field2011-07-18 Red Sox 15Orioles10Camden Yards2011-07-19 Red Sox2Orioles6Camden Yards2011-07-20 Red Sox 4Orioles0Camden Yards2011-07-22 Red Sox 7Mariners4Fenway Park2011-07-23 Red Sox 3Mariners1Fenway Park2011-07-24 Red Sox12Mariners8Fenway Park2011-07-25 Red Sox 1Royals3Fenway Park2011-07-26 Red Sox 13Royals9Fenway Park2011-07-27 Red Sox 12Royals5Fenway Park2011-07-28 Red Sox 3Royals4Fenway Park2011-07-29 Red Sox 1White Sox3U.S. Cellular Field2011-07-30 Red Sox 10White Sox 2U.S. Cellular Field2011-07-31 Red Sox 5White Sox 3U.S. Cellular Field

201107_sox_games_2.txtSuggestions Write this script in stages, testing your script at each step 1. Create the script and add the hashbang line Open the file 2011-07_sox_games_2.txt for reading Make the script executable Run the script It should produce no output Fix any errors you find 2. Write a for loop that prints each line in the file Run the script and fix any errors 3. Outside the for loop set a line count variable to 0 Inside the loop, before the print statement, increment the line count variable Change the print statement so it prints the line number as well as the line Run the script and fix any errors you find 4. Comment out the print statement Write an if statement with a boolean expression which will be true if the remainder, when the line number is divided by 6, is 1 The body of this if statement should simply print t Run the script All you should see is the date of each game Fix any errors you find he line 5. Remove the print statement In its place set the variable date equal to the line with the newline character removed Print the variable date inside the if statement Run the script and fix any errors you find 6. Add an elif clause to the if statement in the for loop The boolean expression should be true if the remainder, when the line number is divided by 6, is 2 The body of this clause should set the value of the variable home_team to the line with the linefeed character removed Print this variable inside this elif clause Run the script and fix any errors you find 7. Add another elif clause where the boolean expression will be true if the remainder, when the line number is divided by 6, is 3 Set the value of home_score to the integer value of the line Print home score Run the script and fix any errors you find 8. Add another elif clause where the boolean expression will be true if the remainder, when the line number is divided by 6, is 4 Set the value of the variable opponent to the value of the line with the linefeed removed Print opponent. Run the script and fix any errors you find 9. Add another elif clause where the boolean expression will be true if the remainder, when the line number is divided by 6, is 5 Set the value of opponent score to the integer value of the line Print opponent score Run the script and fix any errors you find 10. Comment out all previous print statements Add an else clause that sets the value of the variable ballpark to the line with the newline character removed Print ballpark. Run the script and fix any errors you find 11. Comment out all previous print statements Change the code for the else clause so it prints the vales of date, home team, home_acore, opponent,opponent score and ballpark Run the script and fix any errors you find 12. Create the function home_away This function must be written at the top of the page, before any of the code you have already written Replace the variable ballpark in the print statement with a call to home_away Run the script and fix any errors you find 13. Create the function win loss Write this function directly under the definition for home away Add a call to this function inside the print statement Run the script and fix any errors you find 14. Rearrange the print statement so it’s output looks like the format specified above. Run the script and fix any errors you find Testing Your output should look like this 2011-07-02 Red Sox Away Astros Win 7 – !5 2011-07-03 Red Sox Away Astros Win 2 – 1 2011-07-04 Red Sox Home Blue Jays Loss 79 2011-07-05 Red Sox Home Blue Jays Win 3 – ‘2 2011-07-06 Red Sox Home Blue Jays Win 64 2011-07-07 Red Sox Home Orioles Win 10 4 2011-07-08 Red Sox Home Orioles Win 103 2011-07-09 Red Sox Home Orioles Win 4 -0 2011-07-10 Red Sox Home Orioles Win 8 – 6 2011-07-15 Red Sox Away 2011-07-16 Red Sox Away Rays Win 95 2011-07-17 Red Sox Away Rays Win 1 0 2011-07-18 Red Sox Away Orioles Win 15 10 2011-07-19 Red Sox Away Orioles Loss 2 6 2011-07-20 Red Sox Away Orioles Win 4 – 0 2011-07-22 Red Sox Home Mariners Win 7 – 4 2011-07-23 Red Sox Home Mariners Win 3 – 1 2011-07-24 Red Sox Home Mariners Win 12 – 8 2011-07-25 Red Sox Home Royals Loss 1 – 3 2011-07-26 Red Sox Home Royals Win 139 2011-07-27 Red Sox Home Royals Win 12 – 5 2011-07-28 Red Sox Home Royals Loss 3 – 4 2011-07-29 Red Sox Away White Sox Loss 1 – 3 2011-07-30 Red Sox Away White Sox Win 10 – 2 2011-07-31 Red Sox Away White Sox Win 5 – ;3 Rays Loss 69 Show transcribed image text Suggestions Write this script in stages, testing your script at each step 1. Create the script and add the hashbang line Open the file 2011-07_sox_games_2.txt for reading Make the script executable Run the script It should produce no output Fix any errors you find 2. Write a for loop that prints each line in the file Run the script and fix any errors 3. Outside the for loop set a line count variable to 0 Inside the loop, before the print statement, increment the line count variable Change the print statement so it prints the line number as well as the line Run the script and fix any errors you find 4. Comment out the print statement Write an if statement with a boolean expression which will be true if the remainder, when the line number is divided by 6, is 1 The body of this if statement should simply print t Run the script All you should see is the date of each game Fix any errors you find he line 5. Remove the print statement In its place set the variable date equal to the line with the newline character removed Print the variable date inside the if statement Run the script and fix any errors you find 6. Add an elif clause to the if statement in the for loop The boolean expression should be true if the remainder, when the line number is divided by 6, is 2 The body of this clause should set the value of the variable home_team to the line with the linefeed character removed Print this variable inside this elif clause Run the script and fix any errors you find
7. Add another elif clause where the boolean expression will be true if the remainder, when the line number is divided by 6, is 3 Set the value of home_score to the integer value of the line Print home score Run the script and fix any errors you find 8. Add another elif clause where the boolean expression will be true if the remainder, when the line number is divided by 6, is 4 Set the value of the variable opponent to the value of the line with the linefeed removed Print opponent. Run the script and fix any errors you find 9. Add another elif clause where the boolean expression will be true if the remainder, when the line number is divided by 6, is 5 Set the value of opponent score to the integer value of the line Print opponent score Run the script and fix any errors you find 10. Comment out all previous print statements Add an else clause that sets the value of the variable ballpark to the line with the newline character removed Print ballpark. Run the script and fix any errors you find 11. Comment out all previous print statements Change the code for the else clause so it prints the vales of date, home team, home_acore, opponent,opponent score and ballpark Run the script and fix any errors you find 12. Create the function home_away This function must be written at the top of the page, before any of the code you have already written Replace the variable ballpark in the print statement with a call to home_away Run the script and fix any errors you find 13. Create the function win loss Write this function directly under the definition for home away Add a call to this function inside the print statement Run the script and fix any errors you find 14. Rearrange the print statement so it’s output looks like the format specified above. Run the script and fix any errors you find
Testing Your output should look like this 2011-07-02 Red Sox Away Astros Win 7 – !5 2011-07-03 Red Sox Away Astros Win 2 – 1 2011-07-04 Red Sox Home Blue Jays Loss 79 2011-07-05 Red Sox Home Blue Jays Win 3 – ‘2 2011-07-06 Red Sox Home Blue Jays Win 64 2011-07-07 Red Sox Home Orioles Win 10 4 2011-07-08 Red Sox Home Orioles Win 103 2011-07-09 Red Sox Home Orioles Win 4 -0 2011-07-10 Red Sox Home Orioles Win 8 – 6 2011-07-15 Red Sox Away 2011-07-16 Red Sox Away Rays Win 95 2011-07-17 Red Sox Away Rays Win 1 0 2011-07-18 Red Sox Away Orioles Win 15 10 2011-07-19 Red Sox Away Orioles Loss 2 6 2011-07-20 Red Sox Away Orioles Win 4 – 0 2011-07-22 Red Sox Home Mariners Win 7 – 4 2011-07-23 Red Sox Home Mariners Win 3 – 1 2011-07-24 Red Sox Home Mariners Win 12 – 8 2011-07-25 Red Sox Home Royals Loss 1 – 3 2011-07-26 Red Sox Home Royals Win 139 2011-07-27 Red Sox Home Royals Win 12 – 5 2011-07-28 Red Sox Home Royals Loss 3 – 4 2011-07-29 Red Sox Away White Sox Loss 1 – 3 2011-07-30 Red Sox Away White Sox Win 10 – 2 2011-07-31 Red Sox Away White Sox Win 5 – ;3 Rays Loss 69
Expert Answer
Answer to 2011-07-02 Red Sox 7 Astros 5 Minute Maid Park 2011-07-03 Red Sox 2 Astros 1 Minute Maid Park 2011-07-04 Red Sox 7 Blue … . . .
OR

