Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create 2 Python files: -Filename (functions): baseball.py -Filename (driver): sox18.py Use the W/L lists below to answer the following questions and print the answer to

Create 2 Python files:

-Filename (functions): baseball.py

-Filename (driver): sox18.py

Use the W/L lists below to answer the following questions and print the answer to the terminal:

  1. What was the Red Sox win/loss record in 2018? I.e., how many entries in the first list have a W, and how many have an L?

  2. What is the average number of runs scored per game?

  3. How many games did we win but scored exactly 1 run?

  4. How many games did we lose but scored at least 6 runs?

The program must:

  • Define any functions in baseball.py, and the driver with main only in sox18.py.

  • Answer all four questions above in order, in a clear, readable way. When I execute sox18.py, I see the answers to my questions right there on the terminal, and nothing else.

  • Calculate and report the average as a float, rounded to the nearest 100th, but everything else should be a whole number.

  • Use the for..range loop but no other loops, and no list functions besides len.

You may assume that both lists contain good data: There is nothing other than a W or L in the first, and nothing other than a non-negative whole number in the second, and they are both the same length. However, in your test suite, you should consider the case of an empty list, because its totally valid to run your code before the season starts. Make sure you dont divide by zero, which would cause an error. Instead, just return a reasonable value (like 0) if an input list is empty.

Copy-and-paste the lists below and use them as constants above your main function:

RECORD = ['L', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'L', 'W', 'W',

'W', 'W', 'W', 'W', 'W', 'W', 'L', 'L', 'L', 'W', 'W', 'L', 'L',

'W', 'W', 'L', 'W', 'L', 'W', 'W', 'W', 'L', 'L', 'W', 'L', 'W',

'W', 'L', 'L', 'W', 'W', 'L', 'W', 'W', 'W', 'W', 'L', 'W', 'W',

'L', 'W', 'W', 'W', 'L', 'L', 'W', 'W', 'W', 'W', 'L', 'L', 'W',

'L', 'W', 'W', 'W', 'W', 'L', 'L', 'W', 'L', 'L', 'W', 'W', 'L',

'W', 'W', 'W', 'W', 'L', 'W', 'L', 'W', 'W', 'W', 'W', 'W', 'W',

'W', 'W', 'W', 'W', 'L', 'W', 'W', 'W', 'L', 'W', 'W', 'L', 'L',

'W', 'W', 'W', 'W', 'L', 'W', 'W', 'W', 'W', 'W', 'W', 'L', 'W',

'W', 'W', 'W', 'W', 'L', 'W', 'W', 'L', 'L', 'L', 'W', 'W', 'L',

'L', 'L', 'W', 'W', 'W', 'L', 'W', 'L', 'W', 'W', 'W', 'L', 'L',

'W', 'W', 'W', 'W', 'L', 'W', 'W', 'L', 'L', 'W', 'W', 'L', 'L',

'W', 'W', 'L', 'L', 'L', 'W']

RUNS = [4, 1, 3, 2, 7, 4, 3, 10, 8, 14, 7, 6, 7, 10, 3, 10, 9, 8, 7, 0,

1, 3, 4, 5, 3, 6, 4, 10, 6, 5, 5, 5, 6, 6, 2, 6, 5, 3, 5, 5, 5,

3, 6, 6, 4, 6, 5, 4, 4, 3, 6, 8, 1, 8, 8, 6, 2, 3, 5, 9, 6, 7,

2, 0, 4, 2, 2, 6, 5, 2, 6, 0, 9, 2, 1, 9, 14, 2, 5, 9, 9, 4, 1,

11, 1, 4, 11, 3, 10, 15, 7, 5, 8, 4, 6, 7, 6, 5, 1, 0, 9, 5, 6,

1, 4, 10, 3, 2, 1, 15, 4, 4, 5, 10, 10, 5, 19, 5, 6, 4, 2, 4, 7,

5, 0, 4, 3, 10, 7, 3, 1, 1, 8, 14, 9, 1, 6, 0, 8, 5, 9, 3, 3, 6,

7, 1, 4, 0, 5, 4, 2, 1, 11, 7, 4, 3, 6, 19, 3, 6, 5, 10]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

2. Eve really enjoys the science center.

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago