answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Wittaler [7]
2 years ago
4

IN python The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you to write two program

s: 1. A program that will read each player’s name and golf score as keyboard input, and then save these as records in a file named golf.txt. (Each record will have a field for the player’s name and afield for the player’s score.) 2. A program that reads the records from the golf.txt file and displays them.
Computers and Technology
1 answer:
Aliun [14]2 years ago
8 0

Answer:

Check the explanation

Explanation:

<em>We can use a while loop to keep getting names end scores from the user. We just need to start with a single name as a priming read. Assuming it, not a 'q' (for quit), the while loop is entered where the score is obtained from the user and both the name and score are written to the file. Then we read another name and check if the user has decided to quit yet. </em>

<em>Note: because this exercise doesn't ask us to modify records of already existing players, we can assume that we should open the file in write mode instead of append mode (or else we'd potentially end up with multiple records for the same golfer). But in a real scenario you'd need to be very explicit with the customer that this program will delete any data that’s already in the file when it is run</em>

#creat and open the file in write mode

File_obj = open(‘golf.text’, ‘w’)

#obtain the first player’s name

Name = input(’enter the name of a golfer or q if you/’re done: ‘)

while name != 'q' and name !=’Q’:

#Obtain the player' e score

score + int (input ('Enter the golf score if player ' + name + ':’ ))

#Write a record if the player's name and score to the file

File_obj.write (name +’/n’)

File_obj.write (str(score) +’/n’)

Obtain the next player’s name or quit  

Name=inPut (' /nEnter the name of a golfer or q if you/’re done:’)

#close the file

File_obj.close()

<em>In this part, we’ll want to do a priming read consisting of the name of the first record in the file. Then we’ll get the associated score and print both separate columns. A while loop will continue getting names and scores until we run out of records and file_obj.readline() returns the empty string. </em>

<em>note that we’ll need to strip the extra new line escape sequence character from the names in the records. We don't need to for the scores because the int () function drops that character. </em>

<em>As in my previous solutions, I like to underline the header of my tables. That line should run on your system regardless of your OS, but if not, then just remove the strings ' /033[4m' and '/033[0m' and the header will print without being underlined.</em>

<em />

#Open the file in read mode

file_obj = open(’golf.txt', 'r')

#Read name of first record and remove trailing new line escape sequence

name file_obj.readline().rstrip(’/n’)

#Print header far table

print(' \ n'+’ \003[4m’+’name   Scare' ’\033[0m’)

#keep retrieving and printing names and scores from the file until the EOF while name !=":

Score=int(file_obj.readline())

print(format(name, '12s’), format(score, '>10d’))  #align +alumna

name = file_obj.readline().rstrip(’\n’)

# Close the file

file_obj.close()

You might be interested in
15 points. Please give an actual answer and not some random thing. this is not just free points. Correct answer will receive bra
trapecia [35]

Answer:

i think its b

Explanation:

i did the test and got it right

7 0
2 years ago
Read 2 more answers
Give the Linux bash pipelined command that would take the output of the "cat /etc/passwd" command (that lists the contents of th
exis [7]

Answer:

See attached solution

Explanation:

6 0
2 years ago
The basic job of a ________ is to enforce an access control policy at the border of a network.
Elza [17]

Answer:

A. Firewall

Explanation:

 

A firewall is a network security device that monitors incoming and outgoing network traffic and decides whether to allow or block specific traffic based on a defined set of security rules.

Firewalls have been a first line of defense in network security for over 25 years. They establish a barrier between secured and controlled internal networks that can be trusted and untrusted outside networks, such as the Internet.  

A firewall can be hardware, software, or both.

-Cisco

7 0
2 years ago
If the input is negative, make numItemsPointer be null. Otherwise, make numItemsPointer point to numItems and multiply the value
Brilliant_brown [7]

Answer:

The code for the given statements are described below.

Explanation:

// Place code below in line 9

if(numItems < 0)  // starting of a loop

{

numItemsPointer = NULL;

}

else  

{

numItemsPointer = &numItems;

numItems = numItems * 10;   // items multiplied by 10

}   // ending of a loop

6 0
2 years ago
Suppose a computer has 16-bit instructions. The instruction set consists of 32 different operations. All instructions have an op
Kazeer [188]

Answer:

2^7= 128

Explanation:

An instruction format characterizes the diverse part of a guidance. The fundamental segments of an instruction are opcode and operands. Here are the various terms identified with guidance design:  Instruction set size tells the absolute number of guidelines characterized in the processor.  Opcode size is the quantity of bits involved by the opcode which is determined by taking log of guidance set size.  Operand size is the quantity of bits involved by the operand.  Guidance size is determined as total of bits involved by opcode and operands.

6 0
2 years ago
Other questions:
  • Danilo is planning the art to include in a business proposal his team is preparing. For which of the following items should Dani
    7·2 answers
  • The _______________ domain refers to any endpoint device used by end users, which includes but is not limited to mean any smart
    14·1 answer
  • Jesse would like to modify the table that he has inserted into a Word document by making the first row a single header cell.
    15·2 answers
  • One form of competition-based pricing is going-rate pricing, inwhich a firm bases its price largely on competitors' prices, with
    10·1 answer
  • The UML models operations by listing the operation name preceded by an access modifier. A(n) ________ indicates a public operati
    7·2 answers
  • 3.A customer has a system with a Gigabyte B450 Aorus Pro motherboard. He wants to upgrade the processor from the AMD Athlon X4 9
    11·1 answer
  • 1. What are the first tasks the Team Leader (TL) must perform after arriving at the staging area?
    15·1 answer
  • Given num_rows and num_cols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print
    7·1 answer
  • Which bus slot provides highest video performance​
    10·1 answer
  • Describe the ways in which a computer-aided design (CAD) drawing makes the details of an image easier to understand.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!