TEST NUMPY IA
![]() |
![]() |
![]() |
Título del Test:![]() TEST NUMPY IA Descripción: Tipo test IA (Numpy) |




Comentarios |
---|
NO HAY REGISTROS |
(SALIDA CÓDIGO) import numpy as np a = np.array([1, 2, 3]) b = np.array([4, 5, 6]) print(a + b). [1, 2, 3, 4, 5, 6]. [5, 7, 9]. [1, 2, 3]. Error. (SALIDA CÓDIGO) import numpy as np a = np.array([[1, 2], [3, 4]]) print(a.shape). (2,2). (4,). (2,). (1,4). (SALIDA CÓDIGO) import numpy as np a = np.zeros((3, 3)) print(a). [[1 1 1] [1 1 1] [1 1 1]]. [[0 0 0] [0 0 0] [0 0 0]]. [[3 3 3] [3 3 3] [3 3 3]]. Error. (SALIDA CÓDIGO) import numpy as np a = np.array([1, 2, 3, 4, 5]) print(a[1:4]). [1,2,3]. [2,3,4]. [1, 2, 3, 4]. [2, 3, 4, 5]. (SALIDA CÓDIGO) import numpy as np a = np.array([1, 2, 3]) b = np.array([4, 5, 6]) print(np.dot(a, b)). 32. [4, 10, 18]. 21. Error. (SALIDA CÓDIGO) import numpy as np a = np.array([1, 2, 3]) print(a * 2). [1, 2, 3, 1, 2, 3]. [2, 4, 6]. [1, 4, 9]. Error. (SALIDA CÓDIGO) import numpy as np a = np.array([[1, 2], [3, 4]]) print(a.T). [[1, 3], [2, 4]]. [[1, 2], [3, 4]]. [[4, 3], [2, 1]]. Error. (SALIDA CÓDIGO) import numpy as np a = np.array([1, 2, 3]) b = np.array([4, 5, 6]) print(np.concatenate((a, b))). [1, 2, 3, 4, 5, 6]. [5, 7, 9]. [1, 4, 2, 5, 3, 6]. Error. (SALIDA CÓDIGO) import numpy as np a = np.array([1, 2, 3]) print(a.sum()). 6. [1,2,3]. 3. Error. (SALIDA CÓDIGO) import numpy as np a = np.array([1, 2, 3]) print(a.mean()). 1. 2. 3. Error. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3]) print(arr + 1). [1, 2, 3]. [2, 3, 4]. [0, 1, 2]. [1, 3, 4]. (SALIDA CÓDIGO) import numpy as np arr = np.array([[1, 2], [3, 4]]) print(arr[1, 1]). 1. 2. 3. 4. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3]) arr[0] = 10 print(arr). [1,2,3]. [10,2,3]. [1,2,10]. [1,10,3]. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3]) print(arr * 2). [1,2,3]. [2,4,6]. [3,6,9]. [1,2,6]. (SALIDA CÓDIGO) import numpy as np arr = np.array([[1, 2], [3, 4]]) print(arr[0, :]). [1,2]. [1,3]. [2,3]. [[1,2],[3,4]]. (SALIDA CÓDIGO) import numpy as np arr = np.array([[1, 2], [3, 4]]) print(arr[:, 1]). [1,2]. [2,4]. [3,4]. [1,3]. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3, 4, 5]) print(arr[arr > 3]). [4,5]. [1,2,3]. [1,2,3,4]. [1,2,3,4,5]. (SALIDA CÓDIGO) import numpy as np arr = np.array([10, 20, 30, 40]) arr[arr < 30] = 0 print(arr). [10, 20, 30, 40]. [0, 0, 30, 40]. [10, 20, 0, 40]. [0, 0, 0, 40]. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3]) print(np.sqrt(arr)). [1,2,3]. [1,2,3,4]. [1,1.41,1.73]. [1,1,1]. (SALIDA CÓDIGO) import numpy as np arr = np.linspace(0, 1, 5) print(arr). [0, 0.25, 0.5, 0.75, 1]. [0, 1, 2, 3, 4]. [0, 0.2, 0.4, 0.6, 0.8]. [0, 1]. (SALIDA CÓDIGO) import numpy as np arr = np.array([2, 4, 6]) print(arr ** 2). [4, 8, 12]. [4, 16, 36]. [2, 4, 6]. [8, 16, 24]. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3]) print(np.sum(arr)). 6. 3. 1. 0. (SALIDA CÓDIGO) import numpy as np arr = np.array([[1, 2], [3, 4]]) print(np.sum(arr, axis=0)). [4,6]. [1,2]. [1,3]. [10,10]. (SALIDA CÓDIGO) import numpy as np arr = np.array([[1, 2], [3, 4]]) print(np.sum(arr, axis=1)). [3,7]. [1,2]. [4,6]. [10,10]. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3]) print(np.mean(arr)). 1,5. 2. 1. 3. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3, 4, 5]) print(np.reshape(arr, (5, 1))). [[1], [2], [3], [4], [5]]. [1, 2, 3, 4, 5]. [1, 1, 1, 1]. [[1, 2, 3], [4, 5]]. (SALIDA CÓDIGO) import numpy as np arr = np.array([10, 20, 30, 40]) print(np.delete(arr, 2)). [10, 20, 40]. [20, 30, 40]. [10, 30, 40]. [10, 20, 30]. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3, 4]) arr[1:3] = [7, 8] print(arr). [1, 7, 8, 4]. [1, 2, 7, 8]. [7, 8, 3, 4]. [1, 2, 3, 7]. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3, 4, 5]) print(np.delete(arr, np.where(arr > 3))). [1, 2, 3]. [1, 2]. [3, 4, 5]. [2, 3, 4, 5]. (SALIDA CÓDIGO) import numpy as np arr = np.array([[1, 2, 3], [4, 5, 6]]) print(np.transpose(arr)). [[1, 4], [2, 5], [3, 6]]. [[1, 2, 3], [4, 5, 6]]. [[4, 5, 6], [1, 2, 3]]. [[1, 2], [3, 4], [5, 6]]. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3, 4]) print(np.dot(arr, arr)). 10. 30. 20. 40. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3]) print(np.argmax(arr)). 0. 1. 2. 3. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3, 4]) print(np.sort(arr)). [1, 2, 3, 4]. [4, 3, 2, 1]. [4, 3, 1, 2]. [1, 3, 2, 4]. (SALIDA CÓDIGO) import numpy as np arr = np.array([10, 20, 30]) print(np.mean(arr, axis=0)). 20. 10. 30. 25. (SALIDA CÓDIGO) import numpy as np arr = np.array([[1, 2], [3, 4]]) print(np.prod(arr)). 24. 10. 5. 15. (SALIDA CÓDIGO) import numpy as np arr = np.random.rand(3, 3) print(np.any(arr > 0.5)). True. False. 0. 1. (SALIDA CÓDIGO) import numpy as np arr = np.array([1, 2, 3, 4]) print(np.cumsum(arr)). [1, 3, 6, 10]. [1, 2, 3, 4]. [10, 6, 3, 1]. [1, 3, 6, 9]. (SALIDA CÓDIGO) arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) print(arr[1:3, 0:2]). [[4, 5], [8,9]]. [[1, 2], [4, 5]]. [[4, 5], [8, 9]]. [[4, 5], [7, 8]]. (SALIDA CÓDIGO) arr = np.array([1, 2, 3, 4, 5]) arr = np.delete(arr, [1:3]) print(arr). [1, 3, 5]. [1, 4, 5]. [2, 3, 4, 5]. [1, 2, 3, 5]. (SALIDA CÓDIGO) arr = np.array([[1, 2], [3, 4], [5, 6]]) arr[1:3, 0] = 10 print(arr). [[1, 2], [10, 4], [10, 6]]. [[1, 2], [3, 4], [10, 6]]. [[1, 10], [3, 4], [5, 6]]. [[10, 2], [3, 4], [5, 6]]. (SALIDA CÓDIGO) arr = np.array([1, 2, 3, 4, 5]) arr = np.insert(arr, 3, [6, 7]) print(arr). [1, 2, 3, 6, 7, 4, 5]. [1, 2, 3, 6, 7, 5]. [1, 2, 3, 7, 6, 4, 5]. [1, 2, 3, 6, 4, 5]. (SALIDA CÓDIGO) arr = np.array([1, 2, 3]) arr = np.append(arr, np.array([4, 5])) arr[1:3] = [6, 7] print(arr). [1, 6, 7, 4, 5]. [6, 7, 3, 4, 5]. [1, 6, 7, 4, 5]. [1, 2, 6, 7, 4, 5]. (SALIDA CÓDIGO) arr = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) print(arr[0, 1, :]). [1, 2]. [3, 4]. [7, 8]. [5, 6]. (SALIDA CÓDIGO) arr = np.array([0, 1, 2, 3, 4]) arr = np.insert(arr, 2, [10, 20, 30]) arr = np.delete(arr, np.where(arr == 3)[0]) print(arr). [0, 1, 10, 20, 30, 4]. [0, 1, 10, 20, 30]. [0, 1, 10, 20, 30]. [0, 1, 10, 20, 30, 4, 3]. (SALIDA CÓDIGO) arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) arr[1:3, 1:3] = arr[1:3, 1:3] * 2 print(arr). [[1, 2, 3], [4, 10, 12], [7, 16, 18]]. [[1, 2, 3], [4, 5, 6], [7, 16, 18]]. [[1, 2, 3], [8, 10, 12], [7, 8, 9]]. [[1, 2, 3], [8, 10, 12], [7, 16, 18]]. (SALIDA CÓDIGO) arr = np.array([1, 2, 3, 4, 5]) view_arr = arr[:3] copy_arr = arr[:3].copy() view_arr[0] = 100 print(arr) print(copy_arr). [100, 2, 3, 4, 5] y [100, 2, 3]. [100, 2, 3, 4, 5] y [1, 2, 3]. [1, 2, 3, 4, 5] y [100, 2, 3]. [1, 2, 3, 4, 5] y [1, 2, 3]. (SALIDA CÓDIGO) arr1 = np.array([[1, 2], [3, 4]]) arr2 = np.array([[5, 6], [7, 8]]) result = np.append(arr1, arr2, axis=0) result = np.append(result, [[9], [10], [11], [12]], axis=1) print(result). [[1, 2, 5, 6], [3, 4, 7, 8], [9, 10, 11, 12]]. [[1, 2, 9], [3, 4, 10], [5, 6, 11], [7, 8, 12]]. [[1, 2, 5, 6], [3, 4, 7, 8], [9, 10, 0, 0]]. [[1, 2, 9, 0], [3, 4, 10, 0], [5, 6, 11, 0], [7, 8, 12, 0]]. (SALIDA CÓDIGO) matrix = np.array([-1, -2, -3, 0, 1]) matrix2 = np.sort(matrix) print(matrix2). [-3 -1 -2 0 1]. [-3 -2 -1 0 1]. [-1 -2 -3 0 1]. [1 0 -1 -2 -3]. (SALIDA CÓDIGO) matrix = np.arange(8).reshape(4, 2) matrix2 = np.sort(matrix, axis=0) print(matrix2). [[0 1] [2 3] [4 5] [6 7]]. [[0 2] [1 3] [4 6] [5 7]]. [[6 7] [4 5] [2 3] [0 1]]. [[0 1] [1 3] [2 5] [3 7]]. (SALIDA CÓDIGO) matrix = np.ones((3, 2, 3), dtype=np.int32) matrix2 = np.sum(matrix, axis=-1) print(matrix2). [[6] [6] [6]]. [[1 1 1] [1 1 1] [1 1 1]]. [[3 3] [3 3] [3 3]]. [[2 2 2] [2 2 2] [2 2 2]]. (SALIDA CÓDIGO) matrix = np.arange(8).reshape(4, 2) indexed = matrix >= 7 print(indexed). [[False False] [False False] [False False] [True False]]. [[ True True] [ True True] [False False] [False False]]. [[False False] [False False] [False True] [False False]]. [[False False] [False False] [False False] [False True]]. (SALIDA CÓDIGO) matrix = np.arange(12).reshape(3, 4) matrix[0,:] = [49, 50, 51, 52] print(matrix). [[49 50 51 52] [ 4 5 6 7] [ 8 9 10 11]]. [[ 0 1 2 3] [49 50 51 52] [ 8 9 10 11]]. [[49 50 51 52] [49 50 51 52] [49 50 51 52]]. [[49 50 51 52] [ 0 1 2 3] [ 4 5 6 7]]. (SALIDA CÓDIGO) matrix1 = np.arange(4).reshape(2, 2) matrix2 = np.arange(6).reshape(3, 2) matrix3 = np.vstack((matrix1, matrix2)) print(matrix3). [[0 1] [2 3] [3 4] [5 6] [7 8]]. [[0 1 2] [3 0 1] [2 3 4]]. [[0 1] [2 3] [0 1] [2 3] [4 5]]. [[0 1] [2 3] [6 7] [8 9] [10 11]]. (SALIDA CÓDIGO) matrix = np.array([2, 1, 3, 0, -1]) matrix2 = np.nonzero(matrix) print(matrix2). (array([0, 1, 2, 4], dtype=int64),). (array([0, 1, 2, 3, 4], dtype=int64),). (array([0, 1, 2], dtype=int64),). (array([3], dtype=int64),). (SALIDA CÓDIGO) matrix = np.arange(6).reshape(3, 2) matrix2 = np.min(matrix, axis=0) print(matrix2). [3 4]. [0 2 4]. [0 1 2]. [0 1]. (SALIDA CÓDIGO) matrix = np.ones((3, 4, 3), dtype=np.int32) matrix2 = np.sum(matrix, axis=2) print(matrix2). [[3 3 3 3] [3 3 3 3] [3 3 3 3]]. [[1 1 1 1] [1 1 1 1] [1 1 1 1]]. [[4 4 4 4] [4 4 4 4] [4 4 4 4]]. [[3 3 3] [3 3 3] [3 3 3]]. (SALIDA CÓDIGO) matrix = np.arange(4).reshape(2, 2) matrix[matrix > 3] = -1 print(matrix). [[0 1] [2 3]]. [[-1 1] [ 2 3]]. [[0 1] [2 -1]]. [[-1 -1] [-1 -1]]. (SALIDA CÓDIGO) matrix = np.arange(9).reshape(3, 3) matrix[0,2] = 30 print(matrix). [[ 0 1 30] [ 3 4 5] [ 6 7 8]]. [[ 0 1 2] [ 3 4 5] [ 6 7 8]]. [[30 1 2] [ 3 4 5] [ 6 7 8]]. [[ 0 1 3] [ 4 5 6] [ 7 8 30]]. (SALIDA CÓDIGO) matrix1 = np.arange(6).reshape(2, 3) matrix2 = np.arange(6).reshape(2, 3) matrix3 = np.vstack((matrix1, matrix2)) print(matrix3). [[0 1 2 0 1 2] [3 4 5 3 4 5]]. [[0 1 2] [3 4 5] [0 1 2] [3 4 5]]. [[0 1 2] [3 4 5] [6 7 8] [9 10 11]]. [[0 1] [2 3] [4 5] [0 1] [2 3] [4 5]]. (COMPLETAR CÓDIGO) import numpy as np a = np.array([1, 2, 3]) b = np.array([4, 5, 6]) print(______) # Línea faltante Salida esperada: [5, 7, 9]. (COMPLETAR CÓDIGO) import numpy as np a = np.array([[1, 2], [3, 4]]) print(______) # Línea faltante Salida esperada: [2, 4]. (COMPLETAR CÓDIGO) import numpy as np a = np.array([1, 2, 3]) print(______) # Línea faltante Salida esperada: 3. (COMPLETAR CÓDIGO) import numpy as np a = np.array([1, 2, 3]) print(______) # Línea faltante Salida esperada: [1, 4, 9]. (COMPLETAR CÓDIGO) import numpy as np a = np.array([1, 2, 3]) print(______) # Línea faltante Salida esperada: [1, 3]. (COMPLETAR CÓDIGO) arr = np.array([1, 2, 3]) # Línea faltante print(arr) Salida: [1, 4, 2, 3]. (COMPLETAR CÓDIGO) arr = np.array([1, 2, 3, 6, 7]) arr[arr > 5] = ? print(arr) Salida: [1, 2, 3, 5, 5]. (COMPLETAR CÓDIGO) arr = np.array([1, 2, 3, 4, 5]) arr[arr == 2] = ? print(arr) Salida: [1, 0, 3, 4, 5]. (COMPLETAR CÓDIGO) arr = np.array([[1, 2, 3], [4, 5, 6]]) arr[1, :] = ? print(arr) Salida: [[1, 2, 3], [2, 3, 4]]. (COMPLETAR CÓDIGO) arr = np.array([5, 10, 15]) arr[arr > 7] = # Línea faltante aquí print(arr) Salida: [5, 7, 7]. (COMPLETAR CÓDIGO) arr = np.array([1, 2, 3]) arr = np.append(arr, [4, 5, 6]) arr[1:4] = # Línea faltante aquí print(arr) Salida: [1, 10, 11, 12, 4, 5, 6]. |