def calculate_next_board(self): """ calculate the next board based on conway's rules: +if a cell is alive -it survives if it has two or three neighbors -it dies if it has four or more neighbors +if a cell is dead -it becomes alive if it has three neighbors """ next_board_ls = [[0 for i in range(0, self.size)] for j in range(0, self.size)] for i in range(0, self.size): for j in range(0, self.size): neighbor_count = self.neighbor_count(i, j) if self.board[i][j].status == 1: if neighbor_count == 2 or neighbor_count == 3: next_board_ls[i][j] = square(1) else: next_board_ls[i][j] = square(0) else: if neighbor_count == 3: next_board_ls[i][j] = square(1) else: next_board_ls[i][j] = square(0) next_board = board(10) next_board.construct(next_board_ls) return next_board
def test_not_square(): for value in range(1,11): nose.tools.assert_not_equal(square(value),not_square[value]) for value in range(1,11): nose.tools.assert_not_equal(square(value+1),result[value]) for value in range(1,11): nose.tools.assert_not_equal(square(value+2),result[value])
def __init__(self,img,length,height,startx,starty,goalx,goaly): """ Loads the board, creates a square for each point on the board, and links those points together""" self.length = int(length) self.height = int(height) self.squares = [[square(x,y) for x in range(self.length)] for y in range(self.height)] for x in range(self.length): for y in range(self.height): self.squares[x][y] = square(x,y) for y in range(self.height): for x in range(self.length): self.squares[x][y].state = str(img[y][x]) self.link(self.squares[x][y]) self.start = self.squares[startx][starty] self.goal = self.squares[goalx][goaly]
def _generateSquares( self ): newSquares = {} for i in letterCoords: for j in numberCoords: newPos = (i,j) newSquares[newPos] = square.square(newPos) return newSquares
def setGame(self): pygame.mixer.music.load('.\\data\\game start.wav') pygame.mixer.music.play() self.hsLabel = self.myfont2.render('',1,[255,255,255]) self.hsLabelAnnounc = self.myfont2.render('',1,[25,75,0]) self.hsBG = pygame.Rect(0,0,0,0) self.username = '' self.level = 1 self.score = 0 self.lowestTime = self.size/2 self.milliseconds = 0 self.allowed = self.size self.seconds = self.allowed self.pathway = map([self.size,self.size]) self.player = playerSquare(self.playerColor,[0,0]) self.pathway.addPlayer(self.player.returnPos()) self.wallPos = [] self.walls = self.addWalls() self.pathway.addWalls(self.wallPos) self.label = self.myfont.render('%.1f' %self.seconds, 1, (255,255,255)) self.scoreLabel = self.myfont2.render(str(self.score),1,(255,255,255)) self.objective = square(self.objectiveColor) tempPos = self.pathway.addRandom('objective') self.objective.place(tempPos) self.key = [] self.drawAll() self.t = pygame.time.Clock()
def choice(): restart = True while restart: your_choice = input('Your choice >> ') if len(your_choice) == 0: print('Something went wrong, check your choice!') continue if your_choice.lower() == 'calculator': simple_calculator() elif your_choice.lower() == 'square': square() elif your_choice.lower() == 'exit': return else: print('Something went wrong, check your choice!') restart = True
def SetBoard(self, board): self.boardGrid = [] for x in range(0, 42): self.boardGrid.append([]) for y in range(0, 42): self.boardGrid[x].append(square(self, board[x][y], (x, y))) self.initialSquare = self.boardGrid[37][37] self.finalSquare = self.boardGrid[36][4]
def addWalls(self): walls = [] self.wallPos = [] walls.append(square(self.wallColor)) walls.append(square(self.wallColor)) walls.append(square(self.wallColor)) walls.append(square(self.wallColor)) walls[0].place([int(self.size*50/2-50),int(self.size*50/2-50)]) walls[1].place([int(self.size*50/2),int(self.size*50/2-50)]) walls[2].place([int(self.size*50/2-50),int(self.size*50/2)]) walls[3].place([int(self.size*50/2),int(self.size*50/2)]) self.wallPos.append([int(self.size*50/2-50),int(self.size*50/2-50)]) self.wallPos.append([int(self.size*50/2),int(self.size*50/2-50)]) self.wallPos.append([int(self.size*50/2-50),int(self.size*50/2)]) self.wallPos.append([int(self.size*50/2),int(self.size*50/2)]) self.pathway.addWalls(self.wallPos) return walls
def __init__(self, color, **kwargs): super(cubeface, self).__init__(**kwargs) self.cols = 3 self.squares = [] for counter, i in enumerate(color): s = square(i, counter) self.squares.append( s) #contains all squares of this particular face self.add_widget(s)
def get_camera_log(): cam0.update_frame() h, w = cam0.frame.shape[:2] newcameramtx, roi = cv2.getOptimalNewCameraMatrix(cam0.cameraMatrix, cam0.distCoeffs, (w, h), 1, (w, h)) cam0.frame = cv2.undistort(cam0.frame, cam0.cameraMatrix, cam0.distCoeffs, newcameramtx) aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250) parameters = aruco.DetectorParameters_create() corners, ids, rejectedImgPoints = aruco.detectMarkers( cam0.frame, aruco_dict, parameters=parameters) cam0.frame = aruco.drawDetectedMarkers(cam0.frame, corners, ids) if ids is not None: if len(ids) == 2: arucoList = [] for i in range(2): corner2Pix = corners[i][0] corner2metre = np.zeros((4, 2)) corners3D = np.zeros((4, 3)) kc = np.zeros((4, 2)) for row in range(0, 4): corner2metre[row][0] = (corner2Pix[row][0] * cameraConfig.sX) - cam0.cX2Meter corner2metre[row][1] = (corner2Pix[row][1] * cameraConfig.sY) - cam0.cY2Meter kc[row][0] = corner2metre[row][0] / cam0.fX2Meter kc[row][1] = corner2metre[row][1] / cam0.fY2Meter Q = [[kc[1][0], kc[3][0], -kc[0][0]], [kc[1][1], kc[3][1], -kc[0][1]], [1, 1, -1]] Qinv = np.linalg.inv(Q) L0 = [kc[2][0], kc[2][1], 1] L = np.zeros(3) for j in range(0, 3): for k in range(0, 3): L[j] += Qinv[j][k] * L0[k] M = math.pow( (kc[1][0] * L[0]) - (kc[0][0] * L[2]), 2) + math.pow( kc[1][1] * L[0] - kc[0][1] * L[2], 2) + math.pow( L[0] - L[2], 2) corners3D[2][2] = arucoLength / math.sqrt(M) corners3D[0][2] = L[2] * corners3D[2][2] corners3D[1][2] = L[0] * corners3D[2][2] corners3D[3][2] = L[1] * corners3D[2][2] for cornerNum in range(0, 4): corners3D[cornerNum][ 0] = kc[cornerNum][0] * corners3D[cornerNum][2] corners3D[cornerNum][ 1] = kc[cornerNum][1] * corners3D[cornerNum][2] arucoList.append( square(corner2metre, corners3D, arucoLength, kc, ids[i])) # print(corners3D) return arucoList return None else: return None
def main(): if square(50) != 50**2: print("Square function does not work") if cube(50) != 50**3: print("Cube function does not work") numbers = [1, 2, 3, 4, 5] if sum(numbers) != 15: print("Sum function does not work")
def test_build_square_successfully(self): """ Given 1. x,y coord representing the top left of a square. 2, Length of one edge. return ??? """ a_square = square.square((0,0), 2) expected_square = [(0,0), (0,2), (2,2), (2,0)] self.assertEquals(expected_square, a_square)
def side(color, x, y, width): # 3x3 2D array - inserting 9 squares into the sides square_tile = [] for i in range(0, 3): temp = [] for j in range(0, 3): temp.append( square(surface, color, (x + (width * j)), (y + (width * i)), width)) square_tile.append(temp) graphics_cube.append(square_tile)
def trajectory_interpolate_record(start_state ,end_state ,n_steps ,wait_time ,r_logs = None,l_logs = None): step_size = np.subtract(end_state , start_state) / n_steps if l_logs is None: for k in range(n_steps): start_state = np.add(start_state , step_size) ActuatorComm.set_command([(start_state[j] * math.pi / 180)for j in range(len(start_state))]) # time.sleep(wait_time) cam_log_squares = ArucoPosEstimation.get_camera_log() q = [(start_state[j] * math.pi / 180) for j in range(11,17,1)] r_leg_calculated_Pts = square(None,F_kine.calculate_r_Pts(q),ArucoPosEstimation.arucoLength,None,2) l_leg_calculated_Pts = square(None,F_kine.calculate_l_Pts(init_l_q),ArucoPosEstimation.arucoLength,None,1) ArucoPosEstimation.show_desired_in_image(r_leg_calculated_Pts,l_leg_calculated_Pts,CAMERA = ArucoPosEstimation.cam0) if cam_log_squares is not None: for i in range(len(cam_log_squares)): if cam_log_squares[i].id == 2: r_logs.append([q, cam_log_squares[i].get_leg_Pts_4_kinematics()]) with open('r_leg_data.txt', 'a') as filehandle: json.dump([q, cam_log_squares[i].get_leg_Pts_4_kinematics()], filehandle,indent=1) filehandle.write('\n') print("camera log squares :\n",cam_log_squares[i].get_leg_Pts_4_kinematics()) print("right leg from kinematics: :\n",F_kine.calculate_r_Pts(q)) elif r_logs is None: for k in range(n_steps): start_state = np.add(start_state , step_size) ActuatorComm.set_command([(start_state[i] * math.pi / 180)for i in range(len(start_state))]) time.sleep(wait_time) cam_log_squares = ArucoPosEstimation.get_camera_log() q = [(start_state[i] * math.pi / 180) for i in range(5,11,1)] l_leg_calculated_Pts = square(None,F_kine.calculate_l_Pts(q),ArucoPosEstimation.arucoLength,None,1) r_leg_calculated_Pts = square(None,F_kine.calculate_r_Pts(init_r_q),ArucoPosEstimation.arucoLength,None,2) ArucoPosEstimation.show_desired_in_image(r_leg_calculated_Pts,l_leg_calculated_Pts,CAMERA=ArucoPosEstimation.cam0) if cam_log_squares is not None: for i in range(len(cam_log_squares)): if cam_log_squares[i].id == 1: l_logs.append([q, cam_log_squares[i].get_leg_Pts_4_kinematics()]) with open('l_leg_data.txt', 'a') as filehandle: json.dump([q, cam_log_squares[i].get_leg_Pts_4_kinematics()], filehandle,indent=1) filehandle.write('\n') print("camera log squares :\n",cam_log_squares[i].get_leg_Pts_4_kinematics()) print("left leg from kinematics: :\n",F_kine.calculate_l_Pts(q))
def __init__(self,path,length,height): """ Loads the board, creates a square for each point on the board, and links those points together""" self.length = int(length) self.height = int(height) self.squares = [[square(x,y) for x in range(self.length)] for y in range(self.height)] for x in range(self.length): for y in range(self.height): self.squares[x][y] = square(x,y) with open(path) as input_data: x = 0 y = 0 for y in range(self.height): line = input_data.readline().strip() for x in range(self.length): self.squares[x][y].state = line[x] self.link(self.squares[x][y]) y = y + 1 self.start = self.squares[0][0] self.goal = self.squares[self.length-1][self.height-1]
def main(args): a = 1 b = 6 c = 9 x = args.x print("Lets compute the polynomial of %d*x^3 + %d*x^2 + %d*x" % (a, b, c)) result = sum([a * cube(x), b * square(x), c * x]) print("The result is %d" % result) true_result = a * x**3 + b * x**2 + c * x if true_result == result: print("Success class complete!") else: print("Woops. Try again")
def test_dict_square(): rows = [ { "time": "2010-01-01T00:00:00", "y": 1.90, }, { "time": "2010-01-01T00:00:01", "y": 1.94, }, { "time": "2010-01-01T00:00:02", "y": 1.88, }, { "time": "2010-01-01T00:00:03", "y": 1.90, }, ] exp_rows = [ { "time": "2010-01-01T00:00:00", "y": 1.90, }, { "time": "2010-01-01T00:00:01", "y": 1.90, }, { "time": "2010-01-01T00:00:01", "y": 1.94, }, { "time": "2010-01-01T00:00:02", "y": 1.94, }, { "time": "2010-01-01T00:00:02", "y": 1.88, }, { "time": "2010-01-01T00:00:03", "y": 1.88, }, { "time": "2010-01-01T00:00:03", "y": 1.90, }, ] result = list(square(iter(rows), "time", "y", False)) assert result == exp_rows, result
def test_list_square(): rows = [ [ "2010-01-01T00:00:00", 1.90, ], [ "2010-01-01T00:00:01", 1.94, ], [ "2010-01-01T00:00:02", 1.88, ], [ "2010-01-01T00:00:03", 1.90, ], ] exp_rows = [ [ "2010-01-01T00:00:00", 1.90, ], [ "2010-01-01T00:00:01", 1.90, ], [ "2010-01-01T00:00:01", 1.94, ], [ "2010-01-01T00:00:02", 1.94, ], [ "2010-01-01T00:00:02", 1.88, ], [ "2010-01-01T00:00:03", 1.88, ], [ "2010-01-01T00:00:03", 1.90, ], ] result = list(square(iter(rows), 0, 1, False)) assert result == exp_rows, result
def collect_dataSet(): right_logs = [] left_logs = [] time.sleep(wait_time_sec) cam_log_squares = ArucoPosEstimation.get_camera_log() if cam_log_squares is not None: for i in range(len(cam_log_squares)): if cam_log_squares[i].id == 2: r_logs.append([ trajectoryGenerator.init_r_q, cam_log_squares[i].get_leg_Pts_4_kinematics() ]) elif cam_log_squares[i].id == 1: l_logs.append([ trajectoryGenerator.init_l_q, cam_log_squares[i].get_leg_Pts_4_kinematics() ]) r_leg_calculated_Pts = square( None, F_kine.calculate_r_Pts(trajectoryGenerator.init_r_q), ArucoPosEstimation.arucoLength, None, 2) l_leg_calculated_Pts = square( None, F_kine.calculate_l_Pts(trajectoryGenerator.init_l_q), ArucoPosEstimation.arucoLength, None, 1) ArucoPosEstimation.show_desired_in_image( r_leg_calculated_Pts, l_leg_calculated_Pts, CAMERA=ArucoPosEstimation.cam0) for key, val in enumerate(trajectoryGenerator.r_leg_states): if key != len(trajectoryGenerator.r_leg_states) - 1: trajectoryGenerator.trajectory_interpolate_record( val, trajectoryGenerator.r_leg_states[key + 1], n_steps, wait_time_sec, right_logs, None) for key, val in enumerate(trajectoryGenerator.l_leg_states): if key != len(trajectoryGenerator.l_leg_states) - 1: trajectoryGenerator.trajectory_interpolate_record( val, trajectoryGenerator.l_leg_states[key + 1], n_steps, wait_time_sec, None, left_logs) return right_logs, left_logs
def __init__(self, path, length, height): """ Loads the board, creates a square for each point on the board, and links those points together""" self.length = int(length) self.height = int(height) self.squares = [[square(x, y) for x in range(self.length)] for y in range(self.height)] for x in range(self.length): for y in range(self.height): self.squares[x][y] = square(x, y) with open(path) as input_data: x = 0 y = 0 for y in range(self.height): line = input_data.readline().strip() for x in range(self.length): self.squares[x][y].state = line[x] self.link(self.squares[x][y]) y = y + 1 self.start = self.squares[0][0] self.goal = self.squares[self.length - 1][self.height - 1]
def initialBoard(self): """ Used for the initial generation of the sudokuBoard :return: None """ for i in range(9): row = [] for j in range(9): s = square(0, 0, 0, 0, (0, 0, 0), self.window) s.row = i s.column = j row.append(s) self.grid.append(row)
def BuildBoard(self): for x in range(0, 42): self.boardGrid.append([]) for y in range(0, 42): self.boardGrid[x].append( square(self, squareTypes.ROCKY, (x, y))) for index in range(0, 50): bucket = int(randint(0, 2)) if bucket == 0: self.boardGrid[int(randint(0, 41))][int(randint( 0, 41))].squareType = squareTypes.MOUNTAIN if bucket == 1: self.boardGrid[int(randint(0, 41))][int(randint( 0, 41))].squareType = squareTypes.PLANE if bucket == 2: self.boardGrid[int(randint(0, 41))][int(randint( 0, 41))].squareType = squareTypes.ROCKY
def createBoard(self, width, height, premade, completedBoard=None): """ Creates a sudoku game board and draws it to the window :param width: width of the window :param height: height of the window :param premade: a solved sudoku board stored in a 2d array :param completedBoard: a solved sudoku board :return: None """ x = 2 y = 20 width = (width - 2) // 9 height = (height - 20) // 9 print(width, height) # create grid of squares for i in range(9): row = [] for j in range(9): # draw square and set row and column s = square(x, y, width, height, (0, 0, 0), self.window) s.row = i s.column = j if int(premade[i][j].text) != 0: s.text = premade[i][j].text s.changeable = False else: s.changeable = True if completedBoard is not None: s.answer = completedBoard[i][j].text s.createRect() s.updateLabel() row.append(s) x += width x = 2 y += height self.grid.append(row)
def draw(): p1xy.move(p1aim) p1head = p1xy.copy() p2xy.move(p2aim) p2head = p2xy.copy() #condiciones de derrota y victoria if ((p1head in p2body) and (p2head in p1body)): print('EMPATE!') return if not inside(p1head) or p1head in p2body: print('Jugador Azul gana') return if not inside(p2head) or p2head in p1body: print('Jugador rojo gana') return if p1head in p1body: print('Jugador Azul gana') return if abs(p1head.x) > 200 or abs(p1head.y) > 200: print('Jugador Azul gana') return if p2head in p2body: print('Jugador rojo gana') return if abs(p2head.x) > 200 or abs(p2head.y) > 200: print('Jugador rojo gana') return if ((lugarObjetox - 5 <= p1head.x <= lugarObjetox + 5) and (lugarObjetoy - 5 <= p1head.y <= lugarObjetoy + 5)): p1aim.rotate(-90) if ((lugarObjetox - 5 <= p2head.x <= lugarObjetox + 5) and (lugarObjetoy - 5 <= p2head.y <= lugarObjetoy + 5)): p2aim.rotate(-90) p1body.add(p1head) p2body.add(p2head) square(lugarObjetox, lugarObjetoy, 5, 'green') square(p1xy.x, p1xy.y, 3, 'red') square(p2xy.x, p2xy.y, 3, 'blue') update() ontimer(draw, 50)
def test_one(self): assert (square(1) == [0])
def test_zero(self): assert (square(0) == [])
def test_type_error(self): with pytest.raises(TypeError): square('str')
def sum_of_squares(x, y): return square(x) + square(y)
def test_square(self): """Тестирует работу функции square модуля square.py""" self.assertEqual(4.5, square.square(3, 3, math.sqrt(18)), "Wrong answer")
import pygame import square pygame.init() screen = pygame.display.set_mode((800, 500)) square = square.square(screen) clock = pygame.time.Clock() isRunning = True shape = 's' while isRunning: for event in pygame.event.get(): square.clear() mousePressed = pygame.mouse.get_pressed() if event.type == pygame.QUIT: isRunning = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE: isRunning = False elif event.key == pygame.K_s: shape = 's' elif event.key == pygame.K_c: shape = 'c' elif event.key == pygame.K_t: shape = 't' if mousePressed[0]: (x, y) = pygame.mouse.get_pos() square.draw(x, y, shape) pygame.display.flip() clock.tick(60)
def graph_implementation(self, arg_objs): x = arg_objs[0] t = Variable(*self.size) obj, constraints = (x >= square(t)).canonical_form return (t, constraints)
def test_length(self, num): print(f'Running parametrized test for num={num}...') assert (len(square(num)) == num) print('Parametrized test finished')
def test_two(self): assert (square(2) == [0, 1])
import square print square.square(0.5) # Trying to call the C version will raise an error # print square._square(0.5)
from square import square a = square() a.move(7,2,0) print('a.move(7,2,0)') a.print_full_square() a.move(2,8,1) print('a.move(2,8,1)') a.print_full_square() a.move(8,2,0) print('a.move(8,2,0)') a.print_full_square() a.move(2,0,1) print('a.move(2,0,1)') a.print_full_square() a.move(0,0,0) print('a.move(0,0,0)') a.print_full_square() a.move(0,4,1) print('a.move(0,4,1)') a.print_full_square() a.move(4,6,0) print('a.move(4,6,0)') a.print_full_square() a.move(6,1,1) print('a.move(6,1,1)') a.print_full_square() a.move(1,1,0) print('a.move(1,1,0)') a.print_full_square() a.move(1,8,1) print('a.move(1,8,1)')
def test_ten(self): assert (square(10) == [0, 1, 4, 9, 16, 25, 36, 49, 64, 81])
def menu(): print("1-Addition \t\t 2-Subtration \t\t 3-Multiply \t\t 4-Division") print("5-Sin() \t\t 6-Cos() \t\t 7-Tan() \t\t 8-Sec()") print("9-Cosec() \t\t 10-Cot() \t\t 11-Square \t\t 12-Square Root \t\t") print("13-Power \t\t 14-Root \t\t 15-Expontial(e^x)") print("16-Factorial \t\t 17-log()\t\t 18-ln() \t\t 19-Quadratic Eq Solver") print( "20-Inverse(x^-1) \t 21-Sin inverse \t 22-Cos Inverse \t 23.Tan Inverse" ) print("24-Permutation \t\t 25-Combination \t 26-Percentage") print("27-Multiple Basic Operators At a time \t\t 28-Close") while True: try: choice = int(input("Enter your choice(press number):")) break except ValueError: print("Input must be a number!") if choice == 1: while True: Sum.Sum() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 2: while True: Sub.sub() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 3: while True: Mul.multiply() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 4: while True: divide.divide() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 5: while True: sin.sin() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 6: while True: cos.cos() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 7: while True: tan.tan() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 8: while True: sec.sec() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 9: while True: cosec.cosec() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 10: while True: cot.cot() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 11: while True: square.square() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 12: while True: sqrt.sqrt() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 13: while True: power.power() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 14: while True: root.root() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 15: while True: exponential.exponential() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 16: while True: factorial.factorial() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 17: while True: log.log() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 18: while True: ln.ln() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 19: while True: quadratic.quadratic() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 20: while True: inverse.inv() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 21: while True: asin.asin() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 22: while True: acos.acos() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 23: while True: atan.atan() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 24: while True: per.per() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 25: while True: com.com() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 26: while True: percentage.percentage() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 27: while True: combine() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 28: close() else: print("Invalid Input.Try Again") menu()
def fourthPower(x): ''' x: int or float. ''' return square(square(x))
# # File author(s): Eric Moscardi <*****@*****.**> # # Distributed under the Cecill-C License. # See accompanying file LICENSE.txt or copy at # http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html # # OpenAlea WebSite : http://openalea.gforge.inria.fr # """ Test point selection """ __license__= "Cecill-C" __revision__ = " $Id: $ " from openalea.vpltk.qt import QtGui from openalea.image.all import point_selection, SpatialImage from square import square from scipy.ndimage import rotate qapp = QtGui.QApplication.instance() if qapp: im1 = square() im2 = rotate(im1, 30) im2 = SpatialImage(im2,im1.resolution) w1 = point_selection (im1) w2 = point_selection (im2)