-2
Program containing a function that takes the names of two files as arguments. The first file contains student names and the second file contains student grades. In the first file, each line corresponds to a student’s name and in the second file, each line corresponds to the students' grades (one or more). Assume that the notes were stored as string, and are separated from each other by whitespace. Read both files and generate a third file that contains the student’s name followed by the average of their grades.
I started out like this:
lista= []
with open('arquivo1linha.txt', 'a') as file:
novo = "\n"+input("ALUNO 1: ")
novo += "\n"+input("ALUNO 2: ")
novo += "\n"+input("ALUNO 3: ")
file.write(novo)
with open('arquivo2linha.txt', 'a') as arquivo:
novo = "\n"+input("NOTA 1: ")
novo += "\n"+input("NOTA 2: ")
novo += "\n"+input("NOTA 3: ")
arquivo.write(novo)
file = open('arquivo1linha.txt', 'r')
file.readlines()
['primeira linha\n', 'segunda linha\n', 'terceira linha\n',]
file.readlines()
file.close()
arquivo = open('arquivo2linha.txt', 'r')
arquivo.readlines()
['primeira linha\n', 'segunda linha\n', 'terceira linha\n',]
arquivo.readlines()
arquivo.close()
linha_arquivo_3 = arquivo1linha[]+ " " + arquivo2linha[]
print (linha_arquivo_3)
print("Número de linhas: ", len(file.read))
print("Número de linhas: ", len(arquivo.read))
I can’t go on
Help?
Thank you very much. Thanks
– Silvana Silva