Question: This is the third time I post this question and I always get answers with errors Python Write a program (Ex1) to define a two

This is the third time I post this question and I always get answers with errors

Python

Write a program (Ex1) to define a two dimensional array (44) of integers as follow. Calculate and print the sum for each row and column separately.

4*4 matrix

Row 1: 18

Row 2: 17

... Column 1: 15

Column 2: 20

...

Write a program (Ex2) to creates a 2D array of 5x5 values of type boolean. Suppose indices represent people and that the value at row i, column j of a 2D array is true just in case i and j are friends and false otherwise.

Ex2-1: Initialize your array to represent the following configuration: (1 point)

Friends List

Ex2-2: Write a method to count how many pairs of friends are represented in the array.(1 point)

Note that each friendship pair appears twice in the array, so in the example above there are 6 pairs of friends).

Ex2-3: Write a method to check whether two people have a common friend. (1 point)

For example, in the example above, 0 and 4 are both friends with 3 (so they have a common friend), whereas 1 and 2 have no common friends. The method should have three parameters: a 2D array of boolean representing the friendship relationships and two integers i, j. The method should return true if there is an integer k, such that i is a friend of k and k is a friend of j and return false otherwise.

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!