Python pre-defined functions such as min, max, sum, etc. As you know, Python allows for regular arrays that do not have any functions associated with them and lists that have pre-defined functions. We will use regular arrays for this assignment. Do not use functions such as append that adds data to a list.
1. Use Python: Based on the material covered in chapter 7 (arrays). Write a program that has the following functionality. Format any decimal values with 2 digits after the decimal point.
i. Write a function that has no parameters that asks for and returns the number of players. Make sure that the user enters an integer of 1 or more for the number of players. So, 1.8, 0, -1, or a20 will be invalid numbers.
ii. Write a function that has the number of players as its parameter along with the name of arrays you want to pass to other functions. The function will have code to store the data for player names, number of home runs, and number of strike outs in respective arrays. You have a total of 3 arrays, one for each item.
iii. Write a function that has parameters for what it needs to calculate and display the total number of home runs and the total number of strike outs for all players.
iv. Write a function that has parameters for what it needs to write the data stored
in the arrays for all players in a tabular format to a file. The file name is a
parameter for this function. Note that the file name will be asked for in the
main function and passed to this function. All this means is that, you display
the data in one loop, all data one per player on one line. Display the header “R
E P O R T” before displaying the contents of the arrays. Note that all data will
be written to this file. Write the name, number of home runs and number of
strike outs from left to right separated by tabs.
Get Free Quote!
401 Experts Online