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. by using python function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started