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

Python Create a Python script file called hw3.py. Ex. 1. Write a program that inputs numbers...
Python Create a Python script file called hw3.py. Ex. 1. Write a program that inputs numbers from the user until they enter a 0 and computes the product of all these numbers and outputs it. Hint: use the example from the slides where we compute the sum of a list of numbers, but initialize the variable holding the product to 1 instead of 0. print("Enter n") n = int(input()) min = n while n != 0: if n < min:...
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...
Please make an Array-based implementation of a Binary Tree in Python based on the given file...
Please make an Array-based implementation of a Binary Tree in Python based on the given file below. Make sure to keep the Abstract Data File of the starter code below when building the Array-based implementation. Python Starter Code Given Below: class ArrayBinaryTree(BinaryTree): """Linked representation of a binary tree structure.""" # -------------------------- nested _Node class -------------------------- class _Node: def __init__(self, element, parent=None, left=None, right=None): # -------------------------- nested Position class -------------------------- class Position(BinaryTree.Position): """An abstraction representing the location of a single element."""...
Problem: Write a Python module (a text file containing valid Python code) named p5.py. This file...
Problem: Write a Python module (a text file containing valid Python code) named p5.py. This file must satisfy the following. Define a function named rinsert. This function will accept two arguments, the first a list of items to be sorted and the second an integer value in the range 0 to the length of the list, minus 1. This function shall insert the element corresponding to the second parameter into the presumably sorted list from position 0 to one less...
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 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.
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT