In: Computer Science
Using Python Shell 2.7, create a file called Assignment6_1.py
Create an array based on a basic array
Create a for loop that will print the array
index the array, print out the index
append an element to the array, print out the array
insert an element into the array, print out the array
pop an element from the array, print out the array
remove an element from the array, print out the array
reverse the order of the array, print the array
NumPy
Using Kali Linux
Take snips of the following:
Create an array using numpy, print the array
Find elements of that array that are larger than a number; Return a boolean value
Create an array of all zeros, print
Create an array of all ones, print
Create a 2x2 identity matrix, print
Create an array filled with random values, print
import numpy as np
#Create an array based on a basic array
basicArray=[34,54,23,45,34,5]
#Create a for loop that will print the array
for i in basicArray:
print i
#index the array, print out the index
for i in range(0,len(basicArray)):
print i
#append an element to the array, print out the array
basicArray.append(45)
print basicArray
#insert an element into the array, print out the array
basicArray.insert(1,22)
print basicArray
#pop an element from the array, print out the array
basicArray.pop()
print basicArray
#remove an element from the array, print out the array
basicArray.remove(34)
print basicArray
#reverse the order of the array, print the array
basicArray.reverse()
print basicArray
########
#NumPy
#Create an array using numpy, print the array
numpyArray=np.array([12,23,43,4,0,2])
print numpyArray
#Find elements of that array that are larger than a number; Return a boolean value
a=numpyArray>10
print a
#Create an array of all zeros, print
z=np.zeros(5)
print z
#Create an array of all ones, print
o=np.ones(5)
print o
#Create a 2x2 identity matrix, print
I=np.eye(2)
print I
#Create an array filled with random values, print
R=np.random.rand(5)
print R