We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import numpy as np x=np.array ([25,23,69,54,145,2]) #Cria um array print (x) y=np.reshape(x,(3,2)) # muda o vetor print (y) z=np.resize(x,(2,5)) #muda o tamanho print (z) a=x[0:4] #mostra os primeiros 4 elementos print (a) x=x.reshape(2,3) #muda o vetor print (x) x[0,0]=10 #Muda um elemento print (x) Resultado [ 25 23 69 54 145 2] [[ 25 23] [ 69 54] [145 2]] [[ 25 23 69 54 145] [ 2 25 23 69 54]] [25 23 69 54] [[ 25 23] [ 69 54] [145 2]] [[ 10 23] [ 69 54] [145 2]]
Tabuleiro de Xadres
import numpy as np r,c=np.indices ((8,8)) print (r) print (c) f=(r+c)%2 print (f) import matplotlib.pyplot as plt plt.title('Tabuleiro de xadres') plt.imshow(f,cmap='gray') plt.colorbar()
Resultado
[[0 0 0 0 0 0 0 0] [1 1 1 1 1 1 1 1] [2 2 2 2 2 2 2 2] [3 3 3 3 3 3 3 3] [4 4 4 4 4 4 4 4] [5 5 5 5 5 5 5 5] [6 6 6 6 6 6 6 6] [7 7 7 7 7 7 7 7]] [[0 1 2 3 4 5 6 7] [0 1 2 3 4 5 6 7] [0 1 2 3 4 5 6 7] [0 1 2 3 4 5 6 7] [0 1 2 3 4 5 6 7] [0 1 2 3 4 5 6 7] [0 1 2 3 4 5 6 7] [0 1 2 3 4 5 6 7]] [[0 1 0 1 0 1 0 1] [1 0 1 0 1 0 1 0] [0 1 0 1 0 1 0 1] [1 0 1 0 1 0 1 0] [0 1 0 1 0 1 0 1] [1 0 1 0 1 0 1 0] [0 1 0 1 0 1 0 1] [1 0 1 0 1 0 1 0]]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
import numpy as np
x=np.array ([25,23,69,54,145,2]) #Cria um array
print (x)
y=np.reshape(x,(3,2)) # muda o vetor
print (y)
z=np.resize(x,(2,5)) #muda o tamanho
print (z)
a=x[0:4] #mostra os primeiros 4 elementos
print (a)
x=x.reshape(2,3) #muda o vetor
print (x)
x[0,0]=10 #Muda um elemento
print (x)
Resultado
[ 25 23 69 54 145 2]
[[ 25 23]
[ 69 54]
[145 2]]
[[ 25 23 69 54 145]
[ 2 25 23 69 54]]
[25 23 69 54]
[[ 25 23]
[ 69 54]
[145 2]]
[[ 10 23]
[ 69 54]
[145 2]]
Tabuleiro de Xadres
import numpy as np
r,c=np.indices ((8,8))
print (r)
print (c)
f=(r+c)%2
print (f)
import matplotlib.pyplot as plt
plt.title('Tabuleiro de xadres')
plt.imshow(f,cmap='gray')
plt.colorbar()
Resultado
[[0 0 0 0 0 0 0 0]
[1 1 1 1 1 1 1 1]
[2 2 2 2 2 2 2 2]
[3 3 3 3 3 3 3 3]
[4 4 4 4 4 4 4 4]
[5 5 5 5 5 5 5 5]
[6 6 6 6 6 6 6 6]
[7 7 7 7 7 7 7 7]]
[[0 1 2 3 4 5 6 7]
[0 1 2 3 4 5 6 7]
[0 1 2 3 4 5 6 7]
[0 1 2 3 4 5 6 7]
[0 1 2 3 4 5 6 7]
[0 1 2 3 4 5 6 7]
[0 1 2 3 4 5 6 7]
[0 1 2 3 4 5 6 7]]
[[0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0]
[0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0]
[0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0]
[0 1 0 1 0 1 0 1]
[1 0 1 0 1 0 1 0]]
The text was updated successfully, but these errors were encountered: