Question

Programming in python code please!

1. Create a two-dimensional, 13 by 17 array of random, positive entries such that the sum each row is 1.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import random
result = []
for i in range(13):
    temp = []
    index = random.randint(0,16)
    for j in range(17):
        if j==index:
            temp.append(1)
        else:
            temp.append(0)
    result.append(temp)
print(result)

Note: Please comment below if you have any doubts. upuote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
Programming in python code please! 1. Create a two-dimensional, 13 by 17 array of random, positive...
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 code to create a two-dimensional array named numbers containing 500 random numbers from 1 to...

    Write code to create a two-dimensional array named numbers containing 500 random numbers from 1 to 1000 inclusive. The array has 50 rows. Then walk through the array and output the random numbers 10 to a line. Format the numbers in right-aligned columns. Use the command prompt window for output. Note: do NOT create a class or main.

  • need help with this python progam using numpy Create a 4x4 two dimensional array with numbers...

    need help with this python progam using numpy Create a 4x4 two dimensional array with numbers from 1 thru 16. show this then: Change the last element by dividing it in half. Show that the original array has changed. show this then: Set all values in row 2 to zero. Show the original array contains this change show this then: Set all values in column 1 to one. Shoe the original array contains this change. show this then: Display the...

  • Write a method that takes in a two-dimensional array of integers, do some calculation for each...

    Write a method that takes in a two-dimensional array of integers, do some calculation for each row in the two-dimensional array, and returns a one-dimensional array of sums for each row. Your code must work any array dimensions, including jagged arrays. The calculations are: • Sum of each row • Maximum value of each row • Minimum value of each row • Average of each row Here is an example an array passed and returns an array of sums for...

  • Create a program that uses a Jagged Array. The program will create an array with 50...

    Create a program that uses a Jagged Array. The program will create an array with 50 rows. Each of the values for each element of the array will be randomly generated. The random values will be between 1 and 20. Depending on the value generated for each row, you will create an array with that number of columns for that row. Each column created will contain the value to the left plus 1. After you create and populate the entire...

  • C++ Lab 11 – Is This Box a Magic Box? Objectives: Define a two dimensional array Understand h...

    C++ Lab 11 – Is This Box a Magic Box? Objectives: Define a two dimensional array Understand how to traverse a two dimensional array Code and run a program that processes a two dimensional array Instructions: A magic square is a matrix (two dimensional arrays) in which the sum of each row, sum of each column, sum of the main diagonal, and sum of the reverse diagonal are all the same value. You are to code a program to determine...

  • Create an application that instantiates a 20?20 two-dimensional array of Date objects, populates it with random...

    Create an application that instantiates a 20?20 two-dimensional array of Date objects, populates it with random dates drawn from the range of 1/1/1970 to 12/31/2020, and then outputs the index and actual date of the row with the most recent date (relative to today) among all the rows and the index and actual date of the column with the oldest date (closest to 1/1/1970) among all the columns.

  • The following are short Python calculations. Give the answer and the Python code for each. 1....

    The following are short Python calculations. Give the answer and the Python code for each. 1. What is the sum of the numbers from 22:100 incrementing by 2? Do this in two ways: Use a while statement and a for loop to do the calculation. (Hint: make sure the numbers include 100) 2. What is the mean, standard deviation of the square root of the numbers from 3 to 5 incrementing by 0.1? Use the linspace function from the numpy...

  • Write the java code for printing a two dimensional array. You may assume any number of...

    Write the java code for printing a two dimensional array. You may assume any number of row and columns for this array. Just declare the array and write the code to print the elements row by row.

  • in java / You will: // 1- create a square 2 dimensional array of random size...

    in java / You will: // 1- create a square 2 dimensional array of random size (less than 11) // 2- fill the array with random integers from 1 to the size limit // 3- print the array // 4- prompt to see if the user wants to do another //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 1- The square can use the same random value for x and y. Don't allow 0 size arrays. // 2- Maybe a nested set of for loops? to...

  • Array processing Create a program that processes two-dimensional array according to task variant Additional requirements 1....

    Array processing Create a program that processes two-dimensional array according to task variant Additional requirements 1. 2. 3. 4. Input dimensions of array form keyboard (use dynamic memory allocation) Fill array with random numbers in range R. Processing of array should be implemented as function (using indices). Displaying the content of array should be implemented as function (using pointers) 5 12 8 2 8 3 3 16 1 22 215 34 0 11 88 13 22 6 5 81 76...

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