Question

In: Computer Science

Using Python Shell 2.7, create a file called Assignment6_1.py Create an array based on a basic...

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

Solutions

Expert Solution

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


Related Solutions

Using Python create a script called create_notes_drs.py. In the file, define and call a function called...
Using Python create a script called create_notes_drs.py. In the file, define and call a function called main that does the following: Creates a directory called CyberSecurity-Notes in the current working directory Within the CyberSecurity-Notes directory, creates 24 sub-directories (sub-folders), called Week 1, Week 2, Week 3, and so on until up through Week 24 Within each week directory, create 3 sub-directories, called Day 1, Day 2, and Day 3 Bonus Challenge: Add a conditional statement to abort the script if...
USE BASIC PYTHON Focus on Basic file operations, exception handling. Save a copy of the file...
USE BASIC PYTHON Focus on Basic file operations, exception handling. Save a copy of the file module6data.txt (Below) Write a program that will a. Open the file module6data.txt b. Create a second file named processed. txt c. Read the numbers from the first file one at a time. For each number write into second file, if possible, its I. Square ii. Square root iii. Reciprocal (1/number)use a math module function for the square root. use exception handling to trap possible...
Write a python program: There is a file called file 2. File2 is a txt file...
Write a python program: There is a file called file 2. File2 is a txt file and I have written the contents of file 2 below in the exact format it was in notepad. # This comment does not make sense # It is just to make it harder # The job description starts after this comment, notice that it has 4 lines. # This job description has 700150 hay system points\\ the incumbent will administer the spending of kindergarden...
Assignment Requirements Write a python application that consists of two .py files. One file is a...
Assignment Requirements Write a python application that consists of two .py files. One file is a module that contains functions used by the main program. NOTE: Please name your module file: asgn4_module.py The first function that is defined in the module is named is_field_blank and it receives a string and checks to see whether or not it is blank. If so, it returns True, if not it return false. The second function that is defined in the module is named...
Create a geoprocessing tool from the .py file included (script from this file included below). Use...
Create a geoprocessing tool from the .py file included (script from this file included below). Use any csv file you would like. I will work around that. This is for a programming for GIS class. We work with jupyter, idle, arcgis pro import os import arcpy from arcpy import env input_table = r"C:\Answers\January2018.CSV" output_fc = r"C:\Answers\crime.gdb\January2018_Crime" spRef = arcpy.SpatialReference("NAD 1983 StatePlane Missouri East FIPS 2401 (US Feet)") gdb_name = os.path.dirname(output_fc) fc_name = os.path.basename(output_fc) env.overwriteOutput = True print("Creating File GDB") arcpy.CreateFileGDB_management(os.path.dirname(gdb_name),...
Using Python : Create a 4×5 4 × 5 array ? X with random value. Print...
Using Python : Create a 4×5 4 × 5 array ? X with random value. Print out ? X , as well as the largest value of each column.
Using Python 3 Write a function reads the file called simpleinterest.txt. Each row in simpleinterest.txt is...
Using Python 3 Write a function reads the file called simpleinterest.txt. Each row in simpleinterest.txt is a comma seperated list of values in the order of PV, FV, n, r. For each row, there is one value missing. Write an output file that fills in the missing value for each row.
Write a Python program stored in a file q3.py that: Gets single-digit numbers from the user...
Write a Python program stored in a file q3.py that: Gets single-digit numbers from the user on one line (digits are separated by white space) and adds them to a list. The first digit and the last digit should not be a zero. If the user provides an invalid entry, the program should prompt for a new value. Converts every entry in the list to an integer and prints the list. The digits in the list represent a non-negative integer....
Create a Python program that: Reads the content of a file (Vehlist.txt) The file contains matching...
Create a Python program that: Reads the content of a file (Vehlist.txt) The file contains matching pairs of vehicle models and their respective makes Separate out the individual make and model on each line of the file Add the vehicle make to one list, and the vehicle model to another list; such that they are in the same relative position in each list Prompt the user to enter a vehicle model Search the list containing the vehicle models for a...
WITH using methods create an array with numbers
IN JAVA  Prompt 3:WITH using methods create an array with numbersint [] number = { 35, 68, 80, 34, 45, 79, 80};Display the numbers in the array using for loopDisplay the sumFind biggest element in the arrayDisplay the numers in the array with index numbersDisplay the numers using for loop in ascending order (sort)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT