Write a Python program that processes a file called fifa.txt whose structure is described previously, to produce output with the following structure (however, your program is allowed to print these lines in any order). For each football club that its name ends with FC, give the sum total of the weight from footbal players whose height is lower than 180 cm. If all the football players in the club are at least 180 cm tall, show 0 as the number. You may assume that FC in the club name will always be uppercase. So on the file from previous page, the output should be: Sydney FC 0 Toronto FC 61 Atlanta United FC 132 This is because the only club names that ends with FC are Sydney FC, Toronto FC and Atlanta United FC. full_name, club, birth_date, height_cm, weight_kg, nationality Bruno Fornaroli, Melbourne City, 9/7/1987,175,68,Uruguay Diego Castro Giménez, Perth Glory, 7/2/1982,174,71, Spain Alvaro Cejudo Carmona, Western Sydney Wanderers, 1/29/1984,180,78, Spain Miloš Ninković, Sydney FC, 12/25/1984,180,76, Serbia Massimo Maccarone, Brisbane Roar, 9/6/1979, 180,73, Italy Besart Berisha, Melbourne Victory, 7/29/1985,183,80, Kosovo Mark Milligan, Melbourne Victory,8/4/1985,178,78, Australia James Troisi, Melbourne Victory, 7/3/1988,176,75, Australia Deivson Rogério Da Silva, Sydney FC, 1/9/1985,186,85, Brazil Ersan Gülüm, Adelaide United,5/17/1987,185,85, Turkey Sebastian Giovinco, Toronto FC, 1/26/1987,163,61, Italy David Villa Sánchez, New York City Football Club, 12/3/1981, 175, 69, Spain Bastian Schweinsteiger, Chicago Fire Soccer Club, 8/1/1984,183,79, Germany Ignacio Piatti, Montreal Impact, 2/4/1985, 180,76, Argentina Jonathan dos Santos, LA Galaxy, 4/26/1990, 172,74, Mexico Ricardo Izecson dos Santos Leite, Orlando City Soccer Club, 4/22/1982, 186, 83, Brazil Miguel Almirón, Atlanta United FC, 2/10/1994, 175,63, Paraguay Diego Valeri, Portland Timbers, 5/1/1986,178,75, Argentina Pedro Miguel Martins Santos, Columbus Crew SC, 4/22/1988,173,65, Portugal Josef Martínez, Atlanta United FC, 5/19/1993,170,69, Venezuela

Answers

Answer 1

In Python, a program to process a fifa.txt file to generate output with the given structure is as follows. We'll create a dictionary to keep track of the weight for each club with a name ending in FC.

We'll utilize a for loop to go over each line in the file and then apply split () to separate each line into its individual components. We'll get the club name by removing everything except the last three characters from the club's name component if the last three characters are FC. If the player's height is less than 180, we'll add their weight to the club's total weight.

Finally, we'll utilize another for loop to iterate through our dictionary and print out the results. Here's the complete Python program:

# initialize dictionary to store weight totals per club with name ending in "FC"

weight_totals = {}#

open filefifa_file = open("fifa.txt")#

read lines one by onefor line in fifa_file:#

split line into its individual componentslst = line.split(",")#

get club name if last three characters are "FC"club_name = lst[1].strip()[-3:]

if club_name == "FC":#

extract height and weightheight = int(lst[3].strip())weight = int(lst[4].strip())# add weight to club total if height is less than 180if height < 180:

if club_name in weight_totals:weight_totals[club_name] += weightelse:weight_totals[club_name] = weight#

close filefifa_file.close()#

iterate through dictionary and print resultsfor club, weight_total in weight_totals.items():

print(club + " " + str(weight_total))

if len(weight_totals) == 0:

print("No clubs found with name ending in 'FC'")

For each football club whose name ends with FC, the program utilizes the fifa.txt file to produce output showing the total weight of football players whose height is less than 180 cm. It prints "0" if all of the football players in the club are at least 180 cm tall.

To know more about Python program:

brainly.com/question/32674011

#SPJ11


Related Questions

Printing gridlines makes data easier to read. True or False?

Answers

The statement "Printing gridlines makes data easier to read" is true. Gridlines are the horizontal and vertical lines that form a grid in a table, chart, or a spreadsheet.

It separates columns and rows, and creates a border around them, allowing you to define and manage your data clearly and uniformly. Printing gridlines makes data easier to read and easier to analyze. By printing gridlines, you provide a visible structure for your data.

This makes it easy to locate, read, and analyze the information because it provides a clear distinction between rows and columns. Printing gridlines makes it easier to see each cell's value and make sense of it,  particularly in tables with many cells.Therefore, the statement is true.

To know more about data visit:

https://brainly.com/question/28285882

#SPJ11

Other Questions
A rectangular loop of wire is situated so that one end (herght h ) is between the plates of a parallel-Plate capacitor (fig. 7.9), oriented paraliel to the fied E. The other end is way outside, where the field is essentrally zero. What is the emf in this loop? if the dotal resistance is R, What corrent flows? Explain. Which of the following statements describes situations in which markdowns would NOT be appropriate?A pair of pillows that had been part of a display and were showing light wearWinter parkas that are still in stock in MarchLicensed merchandise supporting a movie that was not as popular as predictedNational brand merchandise that were priced 15 percent lower in a neighbouring storeThe newest version of the iPhone If the depth of a swimming pool is 3 m and the density of water in the swimming pool is 10^3kg/m^3, the gage pressure measured at the bottom of the swimming pool is: Multiple Choice a) 29.4kPa b) 23.5kPa c) 14.4kPa d) 3.0kPa JAVA, Given a hashmap, group them by value into a 2d array( int[][] ). for (HashMap.Entry mmap :map.entrySet()){ System.out.println(mmap .getKey() +" "+mmap .getValue()); } Hashmap : key value 0 3.0 1 4.0 2 2.5 3 2.5 4 3.0 The output should be [ [0, 4], [1], [2,3] ] [0, 4]: key 0 and 4 have the same value 3.0. [1]: key 1 has a unqiue value 4.0. [2,3]: key 2 and 3 have the same value 2.5. note: [ [0, 4], [2,3], [1]] won't work because it is the wrong order input: hashmap ouput: int[][] While standing in line for the roller coaster that turns riders upside down. Maureen eats a breakfast burrito. After going on the ride, Maureenfeels sick from being turned upside down and going so fast. A week later, when Maurecn tries to eat a breakfast burrito again, she feels sick and ean't bring herself to eat it. What has likely happened to Maureen? reflexive learning operant conditsonirg observational learning classical conditioning How do you know if an object is receiving more heat than it is passing on, receiving less heat than it is passing on, or receiving and passing on the same amount? Show Attempt History Current Attempt in Progress 67. Your answer is partially correct. Kirk Minerals processes materials extracted from mines. The most common raw material that it processes results in three joint products: Spock, Uhura, and Sulu. Each of these products can be sold as is, or each can be processed further and sold for a higher price. The company incurs joint costs of $179,700 to process one batch of the raw material that produces the three joint products. The following cost and sales information is available for one batch of each product. Determine the incremental profit or loss that each of the three joint products, (Enter negative amounts using either a negative s(ym preceding the number e.s. 45 or parentheses es. (45).) Veronica Mars, a recent graduate of Bell's accounting program, evaluated the operating performance of Dunn Company's six divisions. Veronica made the following presentation to Dunn's board of directors and suggested the Percy Division be eliminated. "If the Percy Division is eliminated," she said, "our total profits would increase by $26.300. . In the Percy Division, cost of goods sold is $60,400 variable and $16,500 fixed, and operating expenses are $29,000 variable and $21,400 fixed. None of the Percy Division's fixed costs will be eliminated if the division is discontinued. Is Veronica right about eliminating the Percy Division? Prepare a schedule to support your answer. (Enter negative amounts using either a negative sign preceding the number eg. 45 or parentheses es. (45).) Continue Sales Eliminate Variable costs Net income Increase (Decrease) Cost of goods sold Contribution margin Fixed costs Cost of goods sold Operating expenses I need help with this Health informatics question. After reviewingInformation Hierarchy in the textbook , come up with an example ofdata, information and knowledge. Make it interesting! The company uses a periodic inventory system. A physical count of merchandise inventory on November 30 reveals that there are 108 units on hand. Assuming that the specific identification method is used and that ending inventory consists of 32 units fromeach of the. three purchases and 12 units from the November 1 inventory, the cost of goods sold, rounded to the nearest dollar, is $1497 $1492. $851. $1465.The company uses a periodic inventory system. A physical count of merchandise inventory on November 30 reveals that there are 108 units on hand. Assuming that the specific identification method is used and that ending inventory consists of 32 units fromeach of the. three purchases and 12 units from the November 1 inventory, the cost of goods sold, rounded to the nearest dollar, is $1497 $1492. $851. $1465. Use hex to show the two machine code instructions that the assembler should generate for the assembly language statement: lw $4, X where the address of X is 0x400A0008 Penelope, who has survived breast cancer, now enjoys every day with her husband, her children, and her friends. Her behavior best illustratesa.posttraumatic growth. b.resistance. c.tardive dyskinesia. d.long-term potentiation.Reddy's teacher just entered the classroom and has begun her lecture on the history of psychology. After only a few seconds, Reddy has gained an impression of the teacher's expressive style that will hold true over an entire semester. This best illustrates the importance ofa.self-esteem. b.traits. c.projective tests. d.self-transcendence. what evolutionary characteristics are typical of coevolving species A survey found that women's heights are normally distributed with mean 63.2 in and standard deviation 3.2 in. The survey also found that men's heights are normally distributed with mean 68.5 in. and standard deviation 32 in. Most of the live characters employed at an amusement park have height requirements of a minimum of 56 in and a maximum of 63 in. Complete parts (a) and (b) below.a. Find the percentage of men meeting the height requirement. What does the result suggest about the genders of the people who are employed as characters at the amusement park?The percentage of men who meet the height requirement is % (Round to two decimal places as needed) If you put a dialysis sac that is filled with 300 g/L of glucose into a beaker of water filled with 400 g/L of glucose, which direction will water move? What will happen to the cells? How does food storage and digestion take place in an amoeba? the unit of measure to express resolution in an imaging system is: Talk about the Thermal Requests in Machining Processes contemplating in your answer: (1) definition; (2) causes (associate with the chip root regions); (3) heat dissipation pathways; (4) consequences of high heat; (5) the factors that can influence the amount of heat generated and how they influence it. A nonconducting sphere (radius =5.0 cm ) which has a charge of +9nC distributed uniformly throughout its volume. What is the magnitude of the electric field (in N/C) at a point that is 3 cm from the center of the sphere? Your Answer: Answer The answer should be in integer form (No decimals). With reference to examples, explain three (3) ways how imperfections in the market for capital can affect the land and real property markets Two long straight wires are parallel and 7.8 cm apart. They are to carry equal currents such that the magnetic field at a point halfway between them has magnitude 230T. (a) Should the currents be in the same or opposite directions? (b) How much current is needed?