コード例 #1
0
ファイル: mark_calculator_gui.py プロジェクト: z0k/CSC108
    def calc_term(self):
        # call the functions in mark_functions to calculate term work
        ass = mf.assignments_contribution(self.raw['a1'].get(), 
                                                      self.raw['a2'].get()) 
        ex = mf.exercises_contribution(self.raw['e1'].get(), 
               self.raw['e2'].get(), self.raw['e3'].get(), self.raw['e4'].get())
        labs = self.raw['labs'].get()
        prep = self.raw['prep'].get()
        test = mf.test_contribution(self.raw['midterm'].get())
        self.term_work = mf.term_work_mark(ass, ex, labs, prep, test)

        # in case the user hasn't hit enter or tab on the entries for term work,
        # do the recalculations here
        self.recalculate_percentages(None)

        # update the label
        if self.term_work_total == None:
          self.term_work_total = Label(self, 
             text="Term work total is %.2f out of 56."%(self.term_work))
          self.term_work_total.pack({"side": "top"})
        else:
          self.term_work_total["text"] = "Term work total is %.2f out of 56."%(self.term_work)
コード例 #2
0
ファイル: test_mark_functions.py プロジェクト: z0k/CSC108
import mark_functions as mf

print ('Calling mark_functions.percentage(15, 20)')
print ('Expected 75.0, returned', mf.percentage(15, 20), '\n')

print ('Calling mark_functions.percentage(4.5, 4.5)')
print ('Expected 100.0, returned', mf.percentage(4.5, 4.5), '\n')

print ('Calling mark_functions.contribution(100, 7)')
print ('Expected 7.0, returned', mf.contribution(100, 7), '\n')

print ('Calling mark_functions.raw_contribution(13.5, 15, 10)')
print ('Expected 9.0, returned', mf.raw_contribution(13.5, 15, 10), '\n')

print ('Calling mark_functions.assignments_contribution(32, 30)')
print ('Expected 15.5, returned', mf.assignments_contribution(32, 30), '\n')
    
print ('Calling mark_functions.exercises_contribution(10, 10, 5, 10)')
print ('Expected 10.5, returned',
       mf.exercises_contribution(10, 10, 5, 10), '\n')

print ('Calling mark_functions.test_contribution(21)')
print ('Expected 11.76, returned', mf.test_contribution(21), '\n')

print ('Calling mark_functions.term_work_mark(16, 10.5, 4, 5, 12)')
print ('Expected 47.5, returned', mf.term_work_mark(16, 10.5, 4, 5, 12), '\n')

print ('Calling mark_functions.exam_required(47, 80)')
print ('Expected 75.0, returned', mf.exam_required(47, 80), '\n')