import libxml2 import sys import quiz_library """ purpose Accept 1 or more log file names on the command line. For each log file write to standard output the course mark for the log file, in CSV format preconditions Each command-line argument is the name of a legal, readable quiz log file. All of the log files have the same number of questions. """ # handle command line arguments if len(sys.argv) < 2: print "Syntax:", sys.argv[0], "quiz_log_file ..." sys.exit() else: # loop the list according to the input for i in range(len(sys.argv) - 1): mark = 0 for j in quiz_library.compute_mark_list(quiz_library.load_quiz_log(sys.argv[i + 1])): # calculate mark according to the result in the list mark = mark + int(j) courseMark = sys.argv[i + 1] + "," + str(mark) print courseMark
import quiz_library ''' purpose Accept 1 or more log file names on the command line. For each log file write to standard output the course mark for the log file, in CSV format preconditions Each command-line argument is the name of a legal, readable quiz log file. All of the log files have the same number of questions. ''' # handle command line arguments if len(sys.argv) < 2: print 'Syntax:', sys.argv[0], 'quiz_log_file ...' sys.exit() # iterate through all command line arguments counting the number of correct answers for i in range(1,len(sys.argv)): quiz_mark = 0 log_list = quiz_library.load_quiz_log(sys.argv[i]) mark_list = quiz_library.compute_mark_list(log_list) # count the correct results for mark in mark_list: if mark == 1: quiz_mark += 1 print sys.argv[i] + "," + str(quiz_mark)
The pass ratio for a question is the number of passes divided by the number of passes + fails. preconditions Each command-line argument is the name of a readable and legal quiz log file. All the log_files have the same number of questions. ''' # check number of command line arguments if len(sys.argv) < 2: print 'Syntax:', sys.argv[0], 'quiz_log_file ...' sys.exit() ls=[] lspass=[] for f in sys.argv[1:]: marks=quiz_library.compute_mark_list(quiz_library.load_quiz_log(f)) if not ls: ls=[0]*len(marks) lspass=[0]*len(marks) for i,j in enumerate(marks): if j: lspass[i]+=1 ls[i]+=1 ls=[str(i/float(j)) for i,j in zip(lspass,ls)] print ','.join(ls)
import libxml2 import sys import quiz_library ''' purpose Accept 1 or more log file names on the command line. For each log file write to standard output the course mark for the log file, in CSV format preconditions Each command-line argument is the name of a legal, readable quiz log file. All of the log files have the same number of questions. ''' # handle command line arguments if len(sys.argv) < 2: print 'Syntax:', sys.argv[0], 'quiz_log_file ...' sys.exit() l = 1 while (l < len(sys.argv)): k = 0 log_list = quiz_library.load_quiz_log(sys.argv[l]) marker = quiz_library.compute_mark_list(log_list) for x in range(0, len(marker)): if (marker[x] == 1): k = k + 1 print sys.argv[l] + "," + str(k) l = l + 1
import libxml2 import sys import quiz_library ''' purpose Accept 1 or more log file names on the command line. For each log file write to standard output the course mark for the log file, in CSV format preconditions Each command-line argument is the name of a legal, readable quiz log file. All of the log files have the same number of questions. ''' # handle command line arguments if len(sys.argv) < 2: print 'Syntax:', sys.argv[0], 'quiz_log_file ...' sys.exit() for n in sys.argv[1:]: # Simply summate the number of marks obtained from each question. print n+","+str(sum(quiz_library.compute_mark_list(quiz_library.load_quiz_log(n))))
All the log_files have the same number of questions. ''' # check number of command line arguments if len(sys.argv) < 2: print 'Syntax:', sys.argv[0], 'quiz_log_file ...' sys.exit() passes = [] fails = [] for n in sys.argv[1:]: index_ = 0 # Determine whether the question was passed or failed by the current student # And increment the corresponding pass/fail counter for x in quiz_library.compute_mark_list(quiz_library.load_quiz_log(n)): if (index_+1>len(passes)): passes.append(0) fails.append(0) if (x!=0 and x!=None): passes[index_]+=1.0 else: fails[index_]+=1.0 index_+=1 output = "" index_ = 0 for n in passes: # Calculate the average pass ratio for each question. output += str((passes[index_])/(passes[index_]+fails[index_])) if (index_!=len(passes)-1):
readable and legal quiz log file. All the log_files have the same number of questions. ''' # check number of command line arguments if len(sys.argv) < 2: print 'Syntax:', sys.argv[0], 'quiz_log_file ...' sys.exit() else: marks = 0 ratio = '' # loop the list according to the input for i in range(len(quiz_library.compute_mark_list(quiz_library.load_quiz_log(sys.argv[1])))): for j in range(len(sys.argv) - 1): marks = marks + int(quiz_library.compute_mark_list(quiz_library.load_quiz_log(sys.argv[j + 1]))[i]) # calculate the ratio and store the result to string ratio ratio = ratio + ',' + str(float(marks) / (len(sys.argv) - 1)) # initialize marks marks = 0 # print the ratio i = 1 finalRatio = '' while i in range(len(ratio)): finalRatio = finalRatio + ratio[i] i = i + 1
import libxml2 import sys import quiz_library ''' purpose Accept 1 or more log file names on the command line. For each log file write to standard output the course mark for the log file, in CSV format preconditions Each command-line argument is the name of a legal, readable quiz log file. All of the log files have the same number of questions. ''' # handle command line arguments if len(sys.argv) < 2: print 'Syntax:', sys.argv[0], 'quiz_log_file ...' sys.exit() else: # loop the list according to the input for i in range(len(sys.argv) - 1): mark = 0 for j in quiz_library.compute_mark_list( quiz_library.load_quiz_log(sys.argv[i + 1])): # calculate mark according to the result in the list mark = mark + int(j) courseMark = sys.argv[i + 1] + "," + str(mark) print courseMark
import libxml2 import sys import quiz_library ''' purpose Accept 1 or more log file names on the command line. For each log file write to standard output the course mark for the log file, in CSV format preconditions Each command-line argument is the name of a legal, readable quiz log file. All of the log files have the same number of questions. ''' # handle command line arguments if len(sys.argv) < 2: print 'Syntax:', sys.argv[0], 'quiz_log_file ...' sys.exit() for f in sys.argv[1:]: print f + ',' + str( quiz_library.compute_mark_list(quiz_library.load_quiz_log(f)).count(1))