Question

The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you...

The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you to write a program that will read each player's name and score as keyboard input, and then save these as records in a file named golf.txt.

First, have the program ask the user how many players they want to add to their record. Then, ask the user for each name and score individually.

golf.txt should be structured so that there is a line with the player's name, followed by their score on the next line.

Emily
30
Mike
20
Jonathan
23

Write code with proper indent and screenshot of output result.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
if __name__ == '__main__':
    f = open('golf.txt', 'w')
    n = int(input("Enter number of players: "))
    for i in range(n):
        name = input("Enter name of player " + str(i + 1) + ": ")
        score = int(input("Enter score of player " + str(i + 1) + ": "))
        f.write(name + "\n" + str(score) + "\n")
    print("players data is written to golf.txt")
    f.close()

Add a comment
Know the answer?
Add Answer to:
The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you...
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
  • CHAPTER 6 Question 10 (Programming Exercises) The Springfork Amateur Golf Club has a tournament every weekend....

    CHAPTER 6 Question 10 (Programming Exercises) The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you to write two programs. 1. A program that will read each player’s name and golf score as keyboard input, then save these as records in a file name golf.txt (Each record will have a field for the player’s name and a field for the player’s score.) 2. A program that reads the records from the golf.txt file and...

  • The the results or the golf tournament played at the end of March. The Club president...

    The the results or the golf tournament played at the end of March. The Club president Mr. Martin has asked you to write two programs. Country Club has asked you to write a program to gather, then display The first program will input each player's first name, last name, handicap and golf score and then save these records in a file named golf.txt (each record will have field for the first name, last name, handicap and golf score). The second...

  • PLEASE UPLOAD or Write a simple pesudo code and java code for this program with comments...

    PLEASE UPLOAD or Write a simple pesudo code and java code for this program with comments in both describe what things do. Problem Statement A golf club has a small tournament consisting of five golfers every weekend. The club president has asked you to design a program that does the following: Reads player’s names and their scores from the keyboard for each of the five golfers and simulates writing them to a file called "golf.dat" Entering "Z" for the player...

  • PLEASE UPLOAD or Write a simple PSEUDO CODE AND JAVA CODE for this program WITH COMMENTS...

    PLEASE UPLOAD or Write a simple PSEUDO CODE AND JAVA CODE for this program WITH COMMENTS IN BOTH TELLING WHAT EACH PART DOES. (I NEED BOTH CODES NOT JUST ONE OR THE OTHER) Problem Statement A golf club has a small tournament consisting of five golfers every weekend. The club president has asked you to design a program that does the following: Reads player’s names and their scores from the keyboard for each of the five golfers and simulates writing...

  • Write a Java program that displays the following menu to the user (and allows the user to make a valid selection): 1- Tournament Selection 2- Magic Squares 3 -Arrival Time 4- Quit Once a valid select...

    Write a Java program that displays the following menu to the user (and allows the user to make a valid selection): 1- Tournament Selection 2- Magic Squares 3 -Arrival Time 4- Quit Once a valid selection is made, your program will run the appropriate code for each program. The description for each program is as follows: In a tournament, each player plays six games and then they are 1 - Tournament Selection: placed in a specific group based on their...

  • (C++) The CSIT Racing Club is a group that runs amateur car racing events throughout the...

    (C++) The CSIT Racing Club is a group that runs amateur car racing events throughout the US. In This project, write a program that will help the club determine the winner of their Fall Rally Race. You will need to determine each racer’s average time and identify the first place finisher. An input file with race information contains records of all the laps run by each driver. The record for each driver includes the number of the car the driver...

  • C or C++ Project Overview Wild, Wild, West! Dice Game The Wild, Wild, West! is an...

    C or C++ Project Overview Wild, Wild, West! Dice Game The Wild, Wild, West! is an elimination dice game. It can be played by any number of players, but it is ideal to have three or more players. Wild, Wild, West! Requires the use of two dice. At the start of the game, each player receives a paper that will track the number of lives that player has. Each player starts the game with 6 lives. In the first round,...

  • I need help with this assignment in C++, please! *** The instructions and programming style detai...

    I need help with this assignment in C++, please! *** The instructions and programming style details are crucial for this assignment! Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...

  • Please to indent and follow structure!!!!! Assignment 3 - The card game: War Due Date: June...

    Please to indent and follow structure!!!!! Assignment 3 - The card game: War Due Date: June 9th, 2018 @ 23:55 Percentage overall grade: 5% Penalties: No late assignments allowed Maximum Marks: 10 Pedagogical Goal: Refresher of Python and hands-on experience with algorithm coding, input validation, exceptions, file reading, Queues, and data structures with encapsulation. The card game War is a card game that is played with a deck of 52 cards. The goal is to be the first player to...

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