Skip to content
New issue

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

Exercício 01 #14

Open
hugobertone opened this issue Aug 11, 2018 · 0 comments
Open

Exercício 01 #14

hugobertone opened this issue Aug 11, 2018 · 0 comments

Comments

@hugobertone
Copy link

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]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant