def _test_utility_isFloat(self): ''' Tests if detecting a float works (int is also considered float) ''' assert Utility.isFloat(7.5) == True assert Utility.isFloat(7) == True assert Utility.isFloat("7") == False assert Utility.isFloat(True) == True assert Utility.isFloat(None) == False
def setGrade(self, new_gr): ''' Checks if the grade is an integer from 0 to 10 and sets it, otherwise it does nothing Parameters: new_gr - the grade received ''' if (Utility.isInt(new_gr) or Utility.isFloat(new_gr)) and new_gr >= 0 and new_gr <= 10.0: self._grade = new_gr elif Utility.isConvertableToFloat(new_gr) and float(new_gr) >= 0 and float(new_gr) <= 10.0: self._grade = float(new_gr) else: return False