While using this python program on cengage mindtap for programming exercise 4.12 it is not taking the hours worked and multiplying it by the Total Pay of the person that is listed in a txt file.
Enter the file name: test.txt
Name Hours Total Pay
Lennon 12 3.33
McCartney 57 7.00
Harrison 11 9.10
Starr 3 4.13
filename = input("Enter the file name: ") # input the filename from the user
# declare lists for storing names, hours worked and total pays
names = []
hours = []
totalPay = []
# open the file
with open(filename, "r") as file:
lines = file.readlines() # read lines
# iterate over everyline
for line in lines:
line = line.split() # split the line by space to get a list of words
names.append(line[0]) # add the name from the line to the list
hours.append(int(line[1])) # append the integer(hours) from the line to the hours list
totalPay.append(float(line[2]))# append the float value of the total pay from the line to the totalPay list
print()
# print the header in the format
print(f'{"Name":14s}{"Hours":9s}{"Total Pay":13s}')
# iterate over the created lists and print the details in formatted manner
for name, hour, pay in zip(names, hours, totalPay):
print(f"{name:15s}{hour:4d}{pay:13.2f}")
Python –Gaussian Naive Bayes classifier How can I resolve this…
Python –Gaussian Naive Bayes classifier How can I resolve this Error “TypeError: np.matrix is not supported. Please convert to a numpy array with np.asarray. For more information “ CODE: from sklearn.datasets import load_svmlight_filefrom sklearn.model_selection import train_test_splitfrom sklearn.pipeline import make_pipelinefrom sklearn.preprocessing import StandardScalerfrom sklearn.naive_bayes import GaussianNB # Load the data