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 nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images
- In python don't import librariesarrow_forward1c) Average sentence length We will create a function ( avg_sentence_len ) to calculate the average sentence length across a piece of text. This function should take text as an input parameter. Within this function: 1. sentences : Use the split() string method to split the input text at every '.'. This will split the text into a list of sentences. Store this in the variable sentences . To keep things simple, we will consider every "." as a sentence separator. (This decision could lead to misleading answers. For example, "Hello Dr. Jacob." is actually a single sentence, but our function will consider this 2 separate sentences). 2. words : Use the split() method to split the input text into a list of separate words, storing this in words . Again, to limit complexity, we will assume that all words are separated by a single space (" "). (So, while "I am going.to see you later" actually has 7 words, since there is no space after the ".", so we will assume the this to contain 6 separate…arrow_forwardIn python pleasearrow_forward
- LAB ASSIGNMENTS IMPORTANT: you should complete the PDP thinking process for each program. Turn in items: 1) fullname_regex.py - Ask the user to enter the source text to search, such as the name_source variable here: name_source = input('Enter full name in this format - first middle last'). Then, you can adapt the first two code lines from lesson slide 13, to search this new source. Edit the code to match the new situation and change the regex pattern to identify text that could be a full name. Hints: Initially write your regex pattern to check if the user enters three words separated by a space. Then, strive to make the regex adaptable if the person's full name has more than or less than 3 words. Then, think about allowing (not requiring) common characters like a period, hyphen or '. Slides 11-13 should be helpful. 08 For printing, end with a conditional block that provides an appropriate message if there is a match or not. Match Enter your full name: first middle last Betty Lou Who…arrow_forwardC++ Nested loops: Print seats. Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat, including after the last. Ex: numRows = 2 and numColumns = 3 prints:1A 1B 1C 2A 2B 2C #include <iostream>using namespace std; int main() { int numRows; int numColumns; int currentRow; int currentColumn; char currentColumnLetter; cin >> numRows; cin >> numColumns; /* Your solution goes here */ cout << endl; return 0;}arrow_forwardappropriate r code?arrow_forward
- In C languagearrow_forwardThis is the questions and answers for the first parts Questions: Using Python Create a list with building names 'Richard Weeks Hall’, ’Busch Student Center’, ‘Environmental & Natural Resource Sciences Building’ Replace the list to 'Richard Weeks’, ’Busch Student Center’, ‘Environmental & Natural Resource Sciences Bldg’ Code for the total points of each name by setting• The base points as the length of the building name.• The bonus points: as ‘Bldg’ being equal to 10 points Meaning, 'Academic Building' which would be 'Academic Bldg' would have a base point of 13 and a bonus point of 10 for a total of 23. #1 Create a list of buildings Buildings=[ 'Richard Weeks Hall', 'Busch Student Center', 'Environmental & Natural Resource Sciences Building' ] print("The Building names in the list are: ") print(Buildings) #2 Process the name of each building res = [sub.replace(' Hall', '').replace('Building', 'Bldg') for sub in Buildings] print("The names have been replaced to :…arrow_forward1c) Average sentence length We will create a function (avg_sentence_len) to calculate the average sentence length across a piece of text. This function should take text as an input parameter. Within this function: sentences: Use the split() string method to split the input text at every '.'. This will split the text into a list of sentences. Store this in the variable sentences. To keep things simple, we will consider every "." as a sentence separator. (This decision could lead to misleading answers. For example, "Hello Dr. Jacob." is actually a single sentence, but our function will consider this 2 separate sentences). words: Use the split() method to split the input text into a list of separate words, storing this in words. Again, to limit complexity, we will assume that all words are separated by a single space (" "). (So, while "I am going.to see you later" actually has 7 words, since there is no space after the ".", so we will assume the this to contain 6 separate words in our…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY