From 09a1577733b35e280e1d9ed7808a6af7b71aa698 Mon Sep 17 00:00:00 2001 From: SUSHMITA YADAV Date: Sun, 14 Oct 2018 19:48:11 +0530 Subject: [PATCH] Remove blank lines --- classmodify.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/classmodify.py b/classmodify.py index d3e20ab..96a9144 100644 --- a/classmodify.py +++ b/classmodify.py @@ -1,9 +1,7 @@ - import sys import pickle def computeModeratedMarks(file1, file2, addPercent): - ''' Objective: To compute moderated marks of students Input Parameters: file1, file2: file names - string values @@ -11,16 +9,13 @@ def computeModeratedMarks(file1, file2, addPercent): Return Value: None Final outcome: A new file – file2 of moderated marks is produced ''' - try: fIn = open(file1, 'r') fOut = open(file2,'wb') except IOError: print("Problem in opening the file") - sys.exit() - + sys.exit() line = fIn.readline() - while(line != ''): sList = line.split(',') try: @@ -33,7 +28,6 @@ def computeModeratedMarks(file1, file2, addPercent): except (ValueError, TypeError): print("Unsuccessful conversion to int") sys.exit() - maxMarks= 100 moderatedMarks = int(marks) + ((addPercent * maxMarks)/100) if moderatedMarks > 100: @@ -41,14 +35,10 @@ def computeModeratedMarks(file1, file2, addPercent): lst = [rollNo, name, moderatedMarks] pickle.dump(lst, fOut) - line = fIn.readline() - + line = fIn.readline() fIn.close() fOut.close() - - fOut = open(file2, 'rb') - while True: try: print(pickle.load(fOut)) @@ -56,25 +46,17 @@ def computeModeratedMarks(file1, file2, addPercent): break def main(): - ''' Objective: To compute moderated marks based on user input Input Parameter: None Return Value: None ''' - import sys sys.path.append("/home/administrator") - file1 = input('Enter name of file containing marks:') - file2 = input('Enter output file for moderated marks:') - addPercent = int(input('Enter moderation percentage:')) - computeModeratedMarks(file1, file2, addPercent) - - if __name__=='__main__': main()