Created
June 12, 2021 08:31
-
-
Save anuragregmi/c48f1e3c8bcba6335a86ed6e21ed8e48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name--Maths--English--Science | |
Raju--60--50--70 | |
Shyam--80--45--65 | |
Baburao--40--40--40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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