def test_Division_add_athlete_whenCalledWithNewAthlete_addsToCorrectDivision(self): division = Division('tbotr') division.add_athlete('123456') self.assertTrue('123456' in redisclient.smembers('tbotr_members')) division.remove_athlete_from_division('tbotr', '123456')
def add_athlete(athlete_id, division): if Division(division).add_athlete(athlete_id): athlete = Athlete(athlete_id) return json.dumps(athlete.get()) else: return 'Incorrect gender for Division'
def test_Division_get_all_whenCalledWithoutGetAthletesFlag_returnsAllDivisionsAndAthletesListFromRedis(self): divs = Division.get_all(False) self.assertTrue('tdiv1' in divs, 'Division tdiv1 not found in returned dict') self.assertTrue('tbotr' in divs, 'Division tdiv1 not found in returned dict') self.assertTrue('10000004' in divs['tdiv1']['members']) self.assertFalse('firstname' in divs['tdiv1']['members']['10000004'])
def test_Division_get_all_whenCalledWithoutGetAthletesFlag_returnsAllDivisionsAndAthletesListFromRedis( self): divs = Division.get_all(False) self.assertTrue('tdiv1' in divs, 'Division tdiv1 not found in returned dict') self.assertTrue('tbotr' in divs, 'Division tdiv1 not found in returned dict') self.assertTrue('10000004' in divs['tdiv1']['members']) self.assertFalse('firstname' in divs['tdiv1']['members']['10000004'])
def test_Division_add_athlete_whenCalledWithNewAthlete_addsToCorrectDivision( self): division = Division('tbotr') division.add_athlete('123456') self.assertTrue('123456' in redisclient.smembers('tbotr_members')) division.remove_athlete_from_division('tbotr', '123456')
from suma import Suma from resta import Resta from division import Division from multiplicacion import Multiplicacion operando_uno = int(input("Ingrese el primer operando: ")) operando_dos = int(input("Ingrese el segundo operando: ")) suma = Suma(operando_uno, operando_dos) resta = Resta(operando_uno, operando_dos) division = Division(operando_uno, operando_dos) multiplicacion = Multiplicacion(operando_uno, operando_dos) print("El resultado de la suma es: ", suma.sumar()) print("El resultado de la resta es: ", resta.restar()) print("El resultado de la multiplicacion es: ", multiplicacion.multiplicar()) print("El resultado de la division es: ", division.dividir())
def remove_athlete(athlete_id): Division.remove_athlete_from_all_divisions(athlete_id) return "OK"
def add_athlete_page(): divisions = Division.get_all(True) return render_template('admin.html', divisions=divisions)
def division(self): self.withdraw() Division(self, self.main_root)
print("Multiplication --> 2") print("Division --> 3") print("Integer Division-> 4") print("Modulo --> 5") print("Exit --> 6") choice = int(input("Choice please :--> ")) if(choice == 1): result = Addition.add(num1,num2) elif(choice == 2): result = Multiplication.multiply(num1,num2) elif(choice == 3): result = Division.division(num1,num2) elif(choice == 4): result = IntegerDivision.integerdivision(num1,num2) elif(choice == 5): result = Modulo.mod(num1, num2) break elif(choice == 6): break else:
while True: try: letter = input( "Would you like to make another calculation (Y,N): ") if letter != 'Y' and letter != 'y' and letter != 'N' and letter != 'n': raise ValueError break except ValueError: print("Oops! That was no valid symbol. Try again...") return letter while True: symbol = operant() if symbol == '+': print("Result: " + str(afronden(Addition(num_input(), num_input())))) elif symbol == '-': print("Result: " + str(afronden(Subtraction(num_input(), num_input())))) elif symbol == '*': print("Result: " + str(afronden(Multiplication(num_input(), num_input())))) elif symbol == '/': print("Result: " + str(afronden(Division(num_input(), num_input())))) antwoord = yes_no() if antwoord == 'N' or antwoord == 'n': break
temperature = initial_temperature current_division = initial_division current_distance = current_division.count_distance() best_division = current_division best_distance = current_distance temperature_change = 1 - temperature_change_factor while time() < end_time: new_division = get_neighbour(current_division) new_distance = new_division.count_distance() temperature *= temperature_change if (new_distance < current_distance or (new_distance >= current_distance and random.random() < probability_for_worse_solution())): current_division = new_division current_distance = current_division.count_distance() if current_distance < best_distance: best_division = current_division best_distance = current_distance return best_division if __name__ == '__main__': t, n, m, k = input().split() t, n, m, k = float(t), int(n), int(m), int(k) matrix = np.array([input().split() for i in range(n)], np.uint8(1)) Division.data = matrix result = simulated_annealing(t, Division(k)) print(result.count_distance()) print(result, file=sys.stderr)
def read_info(): """Reads in all of the files apart from matches and returns: void""" matchFileTour = os.path.join(my_path, ".."+data_paths+"TOURNAMENT INFO.csv") DivInfo = os.path.join(my_path, ".."+data_paths+"DIVISION INFO.csv") ranking_points = os.path.join(my_path, ".."+data_paths+"RANKING POINTS.csv") ranking_list = [] with open(ranking_points, 'r') as csvFile: reader = csv.DictReader(csvFile) for row in reader: temp = int(row["Tournament Ranking Points"]) if temp is not None: ranking_list.sort() if (ex.binary_search(ranking_list, temp) == None): ranking_list.append(temp) ranking_list.sort() # Find out the number of columns in the tournament info csv number_columns = 0 with open(matchFileTour, 'r') as f1: csvlines = csv.reader(f1, delimiter=',') for lineNum, line in enumerate(csvlines): if lineNum == 0: number_columns = (len(line)) break break # Find all of the seasons in the file and load them into seasons season_list = [] with open(matchFileTour, 'r') as csvFile: reader = csv.DictReader(csvFile) for row in reader: temp = row["Season"] if temp is not None: if(ex.binary_search(season_list,temp) == None): season_list.append(temp) for i in season_list: seasons.append(Season(i,ranking_list)) # Load in all tournaments to their respective seasons # Also finds which places get prize money for i in seasons: with open(matchFileTour, 'r') as csvFile: reader = csv.DictReader(csvFile) for row in reader: if(row["Season"] == i.get_name()): temp = [] row_name = "Place " number_places = (number_columns - 3) for x in range(0,number_places): temp.append(float(row[row_name+str(x+1)].replace(',',''))) new_list = list(set(temp)) # Find unique elements in list i.add_tournament(Tournament(row["Tournament"],row["Difficulty"],new_list)) # Load in divisions for each tournament for x in seasons: for j in x.get_tournaments(): with open(DivInfo, 'r') as csvFile: reader = csv.DictReader(csvFile) for row in reader: if (row["Season"] == x.get_name()) and (row["Tournament"] == j.get_name()): j.add_division(Division(row["Division"],row["Best Of"],row["Players"])) # Add players to seasons list_all_divisions = [] for x in seasons: for j in x.get_tournaments(): for k in j.get_divisions(): if list_all_divisions is not None: # Find all of the divisions in the season list_all_divisions.sort() if(ex.binary_search(list_all_divisions,k.get_player_type()) == None): list_all_divisions.append(str(k.get_player_type())) for i in list_all_divisions: with open(os.path.join(my_path, ".."+data_paths+"PLAYERS "+i+".csv"), 'r') as csvFile: reader = csv.DictReader(csvFile) temp = [] for row in reader: player = Player(row["Player"],i) player.set_number_tournaments(x.number_tournaments()) temp.append(player) x.add_participants(temp)
def __init__(self): logging.debug("In NFL constructor") self.__standings = dict() self.__postseason = dict() League.__init__(self, 'NFL') afc = Conference('AFC') nfc = Conference('NFC') self.addChild(afc) self.addChild(nfc) afce = Division('East') afce.setColors('black', 'red') afcn = Division('North') afcn.setColors('yellow', 'blue') afcs = Division('South') afcs.setColors('black', 'white') afcw = Division('West') afcw.setColors('black', 'orange') afc.addChild(afce) afc.addChild(afcn) afc.addChild(afcs) afc.addChild(afcw) afce.addChild(Team('Buffalo Bills', 'BUF')) afce.addChild(Team('Miami Dolphins', 'MIA')) afce.addChild(Team('New England Patriots', 'NE')) afce.addChild(Team('New York Jets', 'NYJ')) afcn.addChild(Team('Baltimore Ravens', 'BAL')) afcn.addChild(Team('Cincinnati Bengals', 'CIN')) afcn.addChild(Team('Cleveland Browns', 'CLE')) afcn.addChild(Team('Pittsburgh Steelers', 'PIT')) afcs.addChild(Team('Houston Texans', 'HOU')) afcs.addChild(Team('Indianapolis Colts', 'IND')) afcs.addChild(Team('Jacksonville Jaguars', 'JAC')) afcs.addChild(Team('Tennessee Titans', 'TEN')) afcw.addChild(Team('Denver Broncos', 'DEN')) afcw.addChild(Team('Kansas City Chiefs', 'KC')) afcw.addChild(Team('Oakland Raiders', 'OAK')) afcw.addChild(Team('San Diego Chargers', 'SD')) nfce = Division('East') nfce.setColors('black', 'darkgreen') nfcc = Division('Central') nfcc.setColors('orange', 'black') nfcs = Division('South') nfcs.setColors('black', 'lightblue') nfcw = Division('West') nfcw.setColors('black', 'yellow') nfc.addChild(nfce) nfc.addChild(nfcc) nfc.addChild(nfcs) nfc.addChild(nfcw) nfce.addChild(Team('Dallas Cowboys', 'DAL')) nfce.addChild(Team('New York Giants', 'NYG')) nfce.addChild(Team('Philadelphia Eagles', 'PHI')) nfce.addChild(Team('Washington Redskins', 'WAS')) nfcc.addChild(Team('Chicago Bears', 'CHI')) nfcc.addChild(Team('Detroit Lions', 'DET')) nfcc.addChild(Team('Green Bay Packers', 'GB')) nfcc.addChild(Team('Minnesota Vikings', 'MIN')) nfcs.addChild(Team('Atlanta Falcons', 'ATL')) nfcs.addChild(Team('Carolina Panthers', 'CAR')) nfcs.addChild(Team('New Orleans Saints', 'NO')) nfcs.addChild(Team('Tampa Bay Buccaneers', 'TB')) nfcw.addChild(Team('Arizona Cardnials', 'ARI')) nfcw.addChild(Team('San Francisco 49ers', 'SF')) nfcw.addChild(Team('Seattle Seahawks', 'SEA')) nfcw.addChild(Team('St. Louis Rams', 'STL'))