Question: Write a Python program that outputs a n x n matrix of zeroes and ones where the zeroes and ones are randomly generated and n

Write a Python program that outputs a n x n matrix of zeroes and ones where the zeroes and ones are randomly generated and n is input by user.

For example, if n = 2 then the output may look as follows

1 0

00

Use a top-down design for this solution

Your program should have a main function which calls other functions. You should have other functions in your program such as

Getinput - this function asks user to input a nonnegative integer. If user inputs a negative integer then this function should repeatedly ask for input until a nonnegative integer input is received from the user

ShowMatrix(n) - this function displays a n x n matrix. of zeroes and ones where the zeroes and ones are randomly generated. n is assumed to be a non-negative integer. Each row of the matrix will be on a different line on the output.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!