0:00
Hello.
00:01
For this problem, you're being asked to essentially write a program that is going to generate a 6x6 matrix that is randomly filled with zeros and ones.
00:15
And then it will display that matrix and check to see if both every row and every column in the matrix has an even number of ones.
00:24
So because we want to randomly fill our matrix, we're going to start by importing random.
00:30
I need to generate the matrix.
00:32
I'm going to call the size of the matrix six.
00:35
I've just set this here so that you can easily change the size if you wanted to, but for this problem, it should be six by six.
00:41
Matrix is an empty list, and then we're going to iterate through the size of the list.
00:48
Row is now an empty list.
00:50
And for j, as we iterate again through the size of the list, we want to append to each row list, a random number between zero and one.
01:00
So either zero or one randomly.
01:03
And then once we've filled up an entire row, we want to append that row to the original matrix and then go through it again until we've filled every row in every column.
01:15
Once the matrix is generated, we need to print it out.
01:19
So i chose to print it out this way.
01:20
So four row in matrix, four value in row, we want to print that value.
01:26
And then we'll print a new line at the end of each row.
01:31
After the matrix has been printed, we now need to check if there are an even number of ones in every row or every column.
01:40
So we'll start by checking every row.
01:44
I'm going to assume that it is true.
01:47
I'm going to assume that there are an even number of ones in every row.
01:52
Then i'm going to actually iterate through the rows.
01:56
And if the count of ones on that row is not divisible by two.
02:04
So if two modulo, the count of that row is not equal to zero, which indicates that if you count up all of the ones, this highlighted part is what is doing is if you count up all of the ones in that row and you divide that number by two, you end up with a remainder.
02:26
So that would indicate that it's not an even number.
02:29
It's an odd number.
02:31
And so it is false that there is an even number of ones in that row.
02:37
I've also added the condition that the count is not equal to zero...