This is for Python - COP 1000, I have to use def main. I have attached the program I need help with (2), along with the program one instructions and code that I have below. Thank you! program6_2.py This program reads the text file created in the program above and displays its data. Use f-strings to create a table of rows and columns with column headings as follows: PLAYER COLUMN: 10 characters wide and left-aligned. GOALS COLUMN: 6 characters wide and centered. ASSISTS COLUMN: 8 characters wide and centered. TOTAL COLUMN: 6 characters wide and centered. After printing the stats for each player, the program should report the name of the top scorer and his total points (goals + assists).program6_1.py Write a program that uses a while loop to store goals and assists for Lightning players in a text file. The program should prompt the user for player names, goals, and assists as shown below. Enter data for at least five players. You can make up the names and data. Each datum should be stored on its own line in the file. Sample Output def main(): i = 0 with open("test.txt", 'w') as f: f.writelines("{:<10s}{:<10s}{:<10s}\n".format("Name", "Goals", "Assist")) while i < 5: name = input("\nEnter Player Name: ") goals = int(input("Enter goals: ")) assist = int(input("Enter Assist: ")) f.writelines("{:<10s}{:<10d}{:<10d}\n".format(name, goals, assist)) i += 1 main() The larger attached image is for the first program, the second is what the second program should look like.
This is for Python - COP 1000, I have to use def main. I have attached the program I need help with (2), along with the program one instructions and code that I have below. Thank you!
program6_2.py
This program reads the text file created in the program above and displays its data. Use f-strings to create a table of rows and columns with column headings as follows:
- PLAYER COLUMN: 10 characters wide and left-aligned.
- GOALS COLUMN: 6 characters wide and centered.
- ASSISTS COLUMN: 8 characters wide and centered.
- TOTAL COLUMN: 6 characters wide and centered.
After printing the stats for each player, the program should report the name of the top scorer and his total points (goals + assists).program6_1.py
Write a program that uses a while loop to store goals and assists for Lightning players in a text file. The program should prompt the user for player names, goals, and assists as shown below. Enter data for at least five players. You can make up the names and data. Each datum should be stored on its own line in the file.
Sample Output
def main():
i = 0
with open("test.txt", 'w') as f:
f.writelines("{:<10s}{:<10s}{:<10s}\n".format("Name", "Goals", "Assist"))
while i < 5:
name = input("\nEnter Player Name: ")
goals = int(input("Enter goals: "))
assist = int(input("Enter Assist: "))
f.writelines("{:<10s}{:<10d}{:<10d}\n".format(name, goals, assist))
i += 1
main()
The larger attached image is for the first program, the second is what the second program should look like.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images