Question

7. i) Let n and k be some given positive integers, and x a 1-dimensional NumPy array of length n. Write a Python code that cr
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import numpy as np
##(1)
n=5
k=3
x=np.arange(0,1,0.2)
z = np.zeros((n,k))
for i in range(n):
for j in range(k):
z[i][j]=x[i]
print(z)
a=np.arange(0,1,0.2)
b=np.arange(1,2,0.2)
c=np.arange(2,3,0.2)
##(2)
z1 = np.zeros((3,a.size))
for i in range(3):
for j in range(a.size):
if(i==0):
z1[i][j]=a[j]
if(i==1):
z1[i][j]=b[j]
if(i==2):
z1[i][j]=c[j]
print(z1)   

##PLEASE UPVOTE IF FOUND USEFUL :

***​​​In ques parameters are said to be provided so I took the one for the test cases provided..

Add a comment
Know the answer?
Add Answer to:
7. i) Let n and k be some given positive integers, and x a 1-dimensional NumPy...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a statement that creates a 1-dimensional NumPy array whose entries are the even integers from...

    Write a statement that creates a 1-dimensional NumPy array whose entries are the even integers from 0 to 20 inclusive, in increasing order, and assigns it to the variable a. You may assume that numpy has been imported as np.

  • I can't find the solution for (i), I tried the hint but still lost   Let X...

    I can't find the solution for (i), I tried the hint but still lost   Let X denote the amount of space occupied by an article placed in a 1-ft3 packing container. The pdf of X is below 90x8(1-x) 0 0<x<1 otherwise rx) = Adapt the following R code to graph the PDF in R. here the pdf is fx)-ax*u-x) 0<x<1 otherwise ### R Code a-a ; b-b ; ### You must plug in values for a and b. r seq(0,1,0,01)...

  • Let X denote the amount of space occupied by an article placed in a 1-ft3 packing...

    Let X denote the amount of space occupied by an article placed in a 1-ft3 packing container. The pdf of X is belovw otherwise Adapt the following R code to graph the PDF in R Where the pdf is fx)x( -x) 0< 1 ### R Code a-a ; b b ; ### You must plug in values for a and b. r-seq (0,1,0.0!) # Defines range of X from 0 to 1 pdf = function(x)(a*x^b"(1-x)} # Creates the pdf function...

  • Python, given a code in class i just need help with the third bullet point ; using a and n (defin...

    Python, given a code in class i just need help with the third bullet point ; using a and n (defined in the second picture of python code) find the first digit for k! for k =1,...,n. you dont have to type in all this code just help me write the code in the first picture where it says: def benford(a): b = [0 for d in range(1,10)] #Do everthything in here return b 2.2 Generating data In this assignment...

  • PYTHON import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import...

    PYTHON import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split Our goal is to create a linear regression model to estimate values of ln_price using ln_carat as the only feature. We will now prepare the feature and label arrays. "carat"   "cut" "color"   "clarity"   "depth"   "table"   "price"   "x"   "y"   "z" "1" 0.23   "Ideal" "E" "SI2" 61.5 55 326   3.95   3.98   2.43 "2" 0.21   "Premium" "E" "SI1"...

  • please there are some specific instructions on the question so i would greatly appreciate if they...

    please there are some specific instructions on the question so i would greatly appreciate if they are followed . thank you very much for your time This lab covers: arrays functions input exception handling Question 1 The purpose of this question is to write a python program (script) that manipulates arrays using vector arithmetic. You will compute the values of points The ellipse has a major axis whose length is a and a minor axis whose length is b. For...

  • Sc Python 1 Task 2 3 Consider a binary tree of N vertices 4 such that children of node K are 2* K + 1. Vertex 1...

    Sc Python 1 Task 2 3 Consider a binary tree of N vertices 4 such that children of node K are 2* K + 1. Vertex 1 is the root Kand 2 of the tree and each node has an integer value associated with it. Such a tree may be represented as an array of N integers by writing down values from consecutive nodes For example, the tree below 8 Test might be represented as an array o A node...

  • MATLAB question: I have written a code to solve for a metals resitance. Here is the...

    MATLAB question: I have written a code to solve for a metals resitance. Here is the problem statement: Part 1 (Algorithms) – due Friday: Think about how you might solve the problem of calculating the resistance of a given group of metals depending on the type of metal, the length of the wire and the area of the wire (if given the diameter only – so you must calculate the area). Write instructions (an algorithm) for a script that behaves...

  • NEED HELP WITH PROBLEM 1 AND 2 OF THIS LAB. I NEED TO PUT IT INTO...

    NEED HELP WITH PROBLEM 1 AND 2 OF THIS LAB. I NEED TO PUT IT INTO PYTHON CODE! THANK YOU! LAB 9 - ITERATIVE METHODS FOR EIGENVALUES AND MARKOV CHAINS 1. POWER ITERATION The power method is designed to find the dominant' eigenvalue and corresponding eigen- vector for an n x n matrix A. The dominant eigenvalue is the largest in absolute value. This means if a 4 x 4 matrix has eigenvalues -4, 3, 2,-1 then the power method...

  • This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to...

    This C++ Programs should be written in Visual studio 2017 PROGRAM 1: Comparing Using Arrays to Using Individual Variables One of the main advantages of using arrays instead of individual variables to store values is that the program code becomes much smaller. Write two versions of a program, one using arrays to hold the input values, and one using individual variables to hold the input values. The programs should ask the user to enter 10 integer values, and then it...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT