Skip to content

Instantly share code, notes, and snippets.

@anuragregmi
Created June 12, 2021 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anuragregmi/c48f1e3c8bcba6335a86ed6e21ed8e48 to your computer and use it in GitHub Desktop.
Save anuragregmi/c48f1e3c8bcba6335a86ed6e21ed8e48 to your computer and use it in GitHub Desktop.
Name--Maths--English--Science
Raju--60--50--70
Shyam--80--45--65
Baburao--40--40--40
marks = open("marks.txt", "r")
result_file = open("result.txt", "w")
line_number = 1
output = []
result_file.write("Name Percentage \n")
for line in marks.readlines():
line = line.replace("\n", "")
if line_number != 1:
result = line.split("--")
name = result[0]
math = float(result[1])
english = float(result[2])
science = float(result[2])
percentage = ((math + english + science) / 300) * 100
result_file.write(name + ' ' + str(percentage) + '\n')
line_number += 1
marks.close()
result_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment