Question

Assume s and t are Numpy arrays with 100 rows and 300 columns. Consider the following...

Assume s and t are Numpy arrays with 100 rows and 300 columns. Consider the following two statements:

x = numpy.where(s > 1000, 100, t)

y = (s + t) > 10

Is x an array or a single value? Tell me what you can about its value or values. Is y an array or a single value? Tell me what you can about its value or values.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

    s = numpy.arange(30000).reshape((100, 300))

    print("array s is \n",s)

    t = numpy.arange(30000).reshape((100, 300))

    print("array t is \n",t)

    x = numpy.where(s > 1000, 100, t)

    

    y = (s + t) > 10

    print("value of x is \n",x)

    print("value of y is \n",y)

explanation:

here s and t are arrays with 100 rows and 300 columns.

for showing example i written 30000 values in arrays s and t using numpy.arange(30000)

reshape is used to show 30000 values as 100 rows and 300 columns .

here x=numpy.where(s>1000,100,t)

it print array of values with 100 rows and 300 columns.

here if cell value of s is >1000 then we place 100 otherwise we place t cell value with same row and column index.

y is printing boolean matrix with 100 rows and 300 columns.

sum of s[i][j]+t[i][j]>10 then we put TRUE OTHERWISE FALSE

output:

array s is [[ 300 [600 299] 599] 899] 1 2... 297 298 301 302 597 598 601 602 897 898 [29100 29101 29102 29400 29401 29402 [29

Add a comment
Know the answer?
Add Answer to:
Assume s and t are Numpy arrays with 100 rows and 300 columns. Consider the following...
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
  • Problem 1: Consider 2 integer arrays, x and y, of the same size (assume size =...

    Problem 1: Consider 2 integer arrays, x and y, of the same size (assume size = 10). Initialize array x with random numbers between 1 and 100. Write code that fills array y with values such that each element of y is the corresponding value of x multiplied by its index.

  • D Question 12 1.5 pts Check the true statements about NumPy arrays: O A single instantiated NumPy array can store multi...

    D Question 12 1.5 pts Check the true statements about NumPy arrays: O A single instantiated NumPy array can store multiple types (e.g., ints and strings) in its individual element positions. A NumPy array object can be instantiated using multiple types (e.g., ints and strings) in the list passed to its constructor O Memory freeing will require a double-nested loop. The number of bits used to store a particular NumPy array object is fixed. O The numpy.append(my.array, new_list) operation mutates...

  •     (10 pts) Define a two-dimensional array named temp with three rows and four columns of type int such that the first...

        (10 pts) Define a two-dimensional array named temp with three rows and four columns of type int such that the first row is initialized to 6, 8, 12, 9; the second row is initialized to 10, 13, 6, 16; and the third row is initialized to 27, 5, 10, 20.     (10 pts) Consider the following declarations, and see p.566: enum brands = { GM, FORD, TOYOTA, BMW, KIA }; const int N_BRANDS = 5; const int COLOR_TYPES = 6; double...

  • 1 Program 2-paramter Weibull distribution with β 100 rows by copying down the equation from Table...

    1 Program 2-paramter Weibull distribution with β 100 rows by copying down the equation from Table 4.1. In the next column generate 1000 rows and in the next column 10 000 rows. Calculate the mean and standard deviation for each column. By hitting Recalculate' (typically F9) observe the mean and standard deviation values. What can you say about the variation for each group? 3.0 and η 000 into Excel spreadsheet and generate 2. When simulating the function Z-X where X...

  • Consider the following statements: int numbers[][] = {{1}, {1, 2}, {1, 2, 3}}; What is the...

    Consider the following statements: int numbers[][] = {{1}, {1, 2}, {1, 2, 3}}; What is the size of the array? 3 rows, 3 columns 3 rows, 1 column 1 row, 3 columns 3 rows, 2 columns When you declare an array using the following statement inside a function, the element values are automatically initialized to 0. int matrix[5][5]; How many elements are array matrix[5][5][2]?

  • For the following C statement, what is the corresponding MIPS assembly code? Assume the arrays hold...

    For the following C statement, what is the corresponding MIPS assembly code? Assume the arrays hold 16-bit integer values, $ s0 is the base for array X, $ s1 is the base for array Y, and $ t0 and $ t1 are index variables i and j respectively. Comment code X [j] = Y [i + j];

  • Your array shall have 3 rows and 3 columns (row and column indices are from 0...

    Your array shall have 3 rows and 3 columns (row and column indices are from 0 to 2). You shall initialize all elements of your array with character 'v' Player-1 is assigned 'X' symbol and player-2 is assigned 'O' symbol. Player-1 shall start the game and enter row index and column index where (s)he wants to place an 'X'. The board is updated and displayed. Now player-2 is asked to enter row and column indices If any player tries to...

  • Arrays Artistic Solutions wants to keep track of 100 of customers, including the following fields: Customer...

    Arrays Artistic Solutions wants to keep track of 100 of customers, including the following fields: Customer ID Last Name First Name Street Address City State Zip Code Phone Number Email Address Without access to a database program, you decide that keeping this information in one or more arrays is the best solution. The question is, what kind or kinds of arrays would you use? Discuss whether any or all of the following is suitable for this application, indicating why you...

  • | ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l U...

    | ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l Unless you need to edit, it's safer to stay in 11. Write C++ statements that do the following: a. Declare an array alpha of 10 rows and 20 columns of type int. b. Initialize the array alpha to 0. c. Store 1 in the first row and 2 in the remaining rows d. Store 5 in the first column, and make...

  • Step 1. Open Excel and complete first two columns with any numbers Make 7-8 rows. Type...

    Step 1. Open Excel and complete first two columns with any numbers Make 7-8 rows. Type below first column "R = " We will use Excel function CORREL(Array-1, Array-2). STEP 2. Click on cell B11 and type: =CORREL( Highlight all numbers in A-column starting with cell A2 (do not include title). That will be Array-1 (input range). Type comma after Array-1 and highlight Array-2 from B-column. Press ENTER. You will see in cell B11 Coefficient of Linear Correlation. STEP 3....

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