Program code to copy:-
#Open the file for reading
fin = open("golf.txt", "r")
#printing Heading
print("First-Name\tLast-Name\tHandicap\tScore\tResult")
#Loop read the content of input file line by line and
#store each line into variable 'line' till end of input file
for line in fin:
#split the line read from the file
playerInfo = line.split()
#get the first name
fname = playerInfo[0]
#get the last name
lname = playerInfo[1]
#get the Handicap
handicap = playerInfo[2]
#get the score converted into int
score = int(playerInfo[3])
#Checking for the result
if score == 80:
result = 'Made Par'
elif score < 80:
result = 'Under Par'
else:
result = 'Over Par'
#Displaying the player information
print(fname+"\t\t"+lname+"\t\t"+handicap+"\t\t"+str(score)+"\t"+result)
#Closing both input file
fin.close()
Screenshot of Program Code:-
Screenshot of output:-
You need to create 'golf.txt" file before executing the above program code and store it into current working folder.
Content of "golf.txt" :-
Andrew Marks 11.2 72
Betty Franks 12.8 89
Connie William 14.6 92
Donny Ventura 9.9 78
Ernie Turner 10.1 81
Fred Smythe 8.1 75
Greg Tucker 7.2 72
Henry Zebulon 8.3 83
Ian fleming 4.2 72
Jan Holden 7.7 84
Kit Possum 7.9 79
Landy Bern 10.3 93
mona docker 11.3 98
Kevin Niles 7.1 80
Pam stiles 10.9 87
Russ Hunt 5.6 73
The the results or the golf tournament played at the end of March. The Club president...
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...
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...
Write the C program, to achieve as shown in the sample code execution, using the given struct and using the comments in the given main program below: typedef struct{ char first[20]; char last[20]; float gpa; int score; } student; int main(void){ student *ptr; //first name //last name //student gpa //student score } //ask a user to enter the number of students, num //dynamically allocate memory for an array of students of the appropriate size (i.e. //num that the user just...