Question

IN PYTHON PLEASE...... Process bowlers and their 3 bowling scores. Use my data file below: bowlers2.txt...

IN PYTHON PLEASE......

Process bowlers and their 3 bowling scores.

Use my data file below:

bowlers2.txt ( Showed below)

And you can also use a while loop to read your file if you prefer. How to average down an array, which you don’t have to do. In this case that would be the game 1 average for all bowlers for example.

Find the low average and high average.

Start with read the data into arrays/lists and printed out the arrays/lists to just make sure your program was working

You need to add one more array/list capable to holding decimal values. This array/list can be declared at the top of your code with the other arrays or below the previous code. You also need to add decimal variables for highscore and lowscore and string variables for highname and lowname.

Make a loop to go through your arrays one row at a time. Each time through the loop add up the 3 scores of each bowler and divide that total by 3.0 to get the average. Put the average in the new array for that bowler. When you are finished with the loop, each bowler will have an average.

Now find the highest and lowest average. You can use a sequential search. You can’t just sort the average array, because then the averages would not match up with the correct names in the names array and you have to print out the lowest average with that person’s name, and same thing for highest average.

To find ″keith hallmark’s″ average you would have to input ″keith hallmark″ from the keyboard first.(You are assuming you want this to work for any bowler.)

And since the names in the names array are in a variety of cases, I would covert the name entered from the keyboard (keith hallmark) to upper case.

Then I would loop through the name array one row at a time, comparing the name entered from the keyboard to the names in the names array, but you would also have to convert the name in the names array to uppercase before making the comparison. Don’t permanently change the name in the names array, just convert it to uppercase for comparison. Don’t forget that in Java you have to use a function for comparison.

Once you find a match on the keith hallmark, print out his name and average. At that point you could use the break function to exit the loop. If keith hallmark is in row 7 of the names array, his average would be in row 7 of the average array.

You are only printing to the screen, not to a file of any kind.

bowlers2.txt

Linus too good

100

23

210

Charlie brown

1

2

12

Snoopy

300

300

100

Peperment Patty

223

300

221

Pig Pen

234

123

212

Red Headed Girl

123

222

111

Marcey

1

2

3

keith hallmark

222

300

180

anna hallmark

222

111

211

roxie hallmark

100

100

2

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source Code in Python:

fin=open('bowlers2.txt','r') #opening file in read mode
names=[] #empty list to store names
averages=[] #empty list to store averages
name=' '
while name!='':
name=fin.readline() #reading a name
if name!='': #if name is not blank
average=(int(fin.readline())+int(fin.readline())+int(fin.readline()))/3 #calculating average for the player
names.append(name[:len(name)-1]) #indexing to remove the \n
averages.append(average)
#calculating minimum and maximum average
max=0
min=0
for i in range(1,len(averages)):
if averages[i]>averages[max]:
max=i
if averages[i]<averages[min]:
min=i
print(names[min],averages[min]) #output
print(names[max],averages[max]) #output

1 fin open(bowlers2 . txt,r) #opening file in read mode 2 names [ #empty List to store names 3 averages-[] #empty List to

Output:

In [12]: runfile (C:/Users/Debjit G/Documents/bowle rs .py, wdir=C:/ Users/Debjit G/Documents Marcey 2.0 Peperment Patty 2

Add a comment
Know the answer?
Add Answer to:
IN PYTHON PLEASE...... Process bowlers and their 3 bowling scores. Use my data file below: bowlers2.txt...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am having trouble trying to output my file Lab13.txt. It will say that everything is...

    I am having trouble trying to output my file Lab13.txt. It will say that everything is correct but won't output what is in the file. Please Help Write a program that will input data from the file Lab13.txt(downloadable file); a name, telephone number, and email address. Store the data in a simple local array to the main module, then sort the array by the names. You should have several functions that pass data by reference. Hint: make your array large...

  • Posted this a few hours ago. Can anyone help with this? IN C++ Perform the following:...

    Posted this a few hours ago. Can anyone help with this? IN C++ Perform the following: Read 10 bowlers with 3 scores each into 1 string array and 1 numeric array(2 dimension double array) Sort the data by individual bowlers averages, Don't forget to sort their names also. Calculate the average across and store in your existing array. Calculate the average down and store in your existing array. Print out the contents of both arrays. This will print the averages...

  • (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that...

    (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that you have been provided on Canvas. That file has a name and 3 grades on each line. You are to ask the user for the name of the file and how many grades there are per line. In this case, it is 3 but your program should work if the files was changed to have more or fewer grades per line. The name and...

  • python, please!!! comma separated values to store the data. The hame_count.csv file has one header row,...

    python, please!!! comma separated values to store the data. The hame_count.csv file has one header row, of the form: name, count Each successive row then has a name and a count for how many times that name appears in a database of names that the lab made up. For this first part of the lab, you must calculate the average name count. The steps to do so are as follows: Open the file, name_count.csv • Read all the lines from...

  • IN C++ PLEASE -------Add code to sort the bowlers. You have to sort their parallel data...

    IN C++ PLEASE -------Add code to sort the bowlers. You have to sort their parallel data also. Print the sorted bowlers and all their info . You can use a bubble sort or a shell sort. Make sure to adjust your code depending on whether or not you put data starting in row zero or row one. Sort by Average across, lowest to highest. The highest average should then be on the last row.. When you sort the average, you...

  • In C++ First create the two text file given below. Then complete the main that is given. There ar...

    In C++ First create the two text file given below. Then complete the main that is given. There are comments to help you. An output is also given You can assume that the file has numbers in it Create this text file: data.txt (remember blank line at end) Mickey 90 Minnie 85 Goofy 70 Pluto 75 Daisy 63 Donald 80 Create this text file: data0.txt (remember blank line at end) PeterPan 18 Wendy 32 Michael 28 John 21 Nana 12...

  • Game Of life 1. Change the size of the arrays: const int MAX_ROW = 40; const...

    Game Of life 1. Change the size of the arrays: const int MAX_ROW = 40; const int MAX_COL = 80; ***Make sure that only global variables you have in your program are Max_ROW and MAX_COL. Move any global variables you declared to a function or functions. ***Make sure to update setNextGenArray(). Use the variable names, not 40 or 80. ***For testing, I will be changing the array size. Your program should work by only modifying the array size. 2. Use...

  • ****PLEASE CODE IN C++ and line doc explaining what is happening!***** **HERE IS THE INPUT FILE(.txt)*****...

    ****PLEASE CODE IN C++ and line doc explaining what is happening!***** **HERE IS THE INPUT FILE(.txt)***** Ottawa Senators New York Rangers Boston Bruins Montreal Canadiens Montreal Canadiens Toronto Maple Leafs New York Rangers Chicago Blackhawks Montreal Maroons Detroit Red Wings Detroit Red Wings Chicago Blackhawks Boston Bruins New York Rangers Boston Bruins Toronto Maple Leafs Detroit Red Wings Montreal Canadiens Toronto Maple Leafs Montreal Canadiens Toronto Maple Leafs Toronto Maple Leafs Toronto Maple Leafs Detroit Red Wings Toronto Maple Leafs...

  • First create the two text file given below. Then complete the main that is given. There...

    First create the two text file given below. Then complete the main that is given. There are comments to help you. An output is also given You can assume that the file has numbers in it Create this text file: data.txt (remember blank line at end) Mickey 90 Minnie 85 Goofy 70 Pluto 75 Daisy 63 Donald 80 Create this text file: data0.txt (remember blank line at end) PeterPan 18 Wendy 32 Michael 28 John 21 Nana 12 Main #include...

  • AWK Programming - Please show new working code with screenshot please. Save the following data in...

    AWK Programming - Please show new working code with screenshot please. Save the following data in a file named teamlist.txt: Name,Team,First Test, Second Test, Third Test Tom,Red,5,17,22 Joe,Green,3,14,22 Maria,Blue,6,18,21 Fred,Blue,2,15,23 Carlos,Red,-1,15,24 Phuong,Green,7,19,21 Enrique,Green,3,16,20 Nancy,Red,9,12,24 Write an AWK script that will compute the average score for every person in the list, the average score for each test, and the average score for each team. If a score is negative, that means the person missed the test, and the score must not...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT