Entry of type "float" to a python file?

Recently started to learn python...
My task is:
spoiler
There is a file with data on progress of students. It is a set of lines, where each line contains the following information:

Name;Otsenkami;Ozankoy;Otsenkami

Fields within the line separated by a semicolon, scores are integers.

Write a program that reads a file with similar structure and for each applicant brings his average score on these three items on a line corresponding to this applicant.

In response to a task attach the resulting file with average ratings.

If brief then print the average GPA for each student, but when writing to a file float integer zero after the decimal point there.
here is the code
#!/bin/python3
with open('1.txt') as txt, open('2.txt','w') as out:
s=txt.read().strip()
 for p in range(s.count('\n')+1):
s=txt.readline().strip().split(';')
 print ((float(s[1])+float(s[2])+float(s[3]))/3)#how should be the file
 out.write((float(float(s[1])+float(s[2])+float(s[3]))/3))#writing to a file
out.write('\n')
with open('2.txt','r') as out:
g=out.read().strip()
 print(g)#print to file

Why is this happening? How to fix?
Sample Input: read from file

Petrov;85;92;78
Sidorov;100;88;94
Ivanov;58;72;85

Sample Output:
85.0
94.0
71.666666667
April 4th 20 at 13:22
2 answers
April 4th 20 at 13:24
Solution
What a strange mess you have
for line in open('1.txt', 'r', encoding='utf-8'):
 data = line.strip().split(';')
 name, grades = data[0], [int(x) for x in data[1:]]
 avg = sum(grades)/len(grades)
 if avg == int(avg):
 avg = int(avg)
 open('2.txt', 'a').write(f,'{avg}\n')
Thanks, you explanation of what it means towrite(f'{avg}\n') - Madisen86 commented on April 4th 20 at 13:27
@Madisen86, one of the methods of string formatting - faustino_Koepp55 commented on April 4th 20 at 13:30
@Madisen86, I just don't quite understand the zeros in the fractional numbers in the output, or not. If needed, then just delete the line
if avg == int(avg):
 avg = int(avg)
- faustino_Koepp55 commented on April 4th 20 at 13:33
Don't need) OK, thanks. - Madisen86 commented on April 4th 20 at 13:36
April 4th 20 at 13:26
#!/bin/python3
with open('1.txt') as txt, open('2.txt','w') as out:
s=txt.read().strip()
 for p in range(s.count('\n')+1):
s=txt.readline().strip().split(';')
out.write(str((float(float(s[1])+float(s[2])+float(s[3]))/3)))
out.write('\n')
with open('2.txt','r') as out:
g=out.read().strip()
 print(g)

As if that was not, paradoxically, found the answer @Sergey Gornostaev to other resources. Thank you)

Find more questions by tags Python