1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vlada [557]
3 years ago
9

Write a function that returns the sum of all the elements in a specified column in a matrix using the following header:

Computers and Technology
1 answer:
Leona [35]3 years ago
8 0

Answer:

Following are the code to this question:

def sumColumn(m, columnIndex):#defining a method sumColumn that accept two parameters  

   x = 0#defining a variable x that hold a value 0

   for i in range(3): #defining a for loop for count and add values

       x += m[i][columnIndex]#add value in x variable

   return x# return sum value

a = []#defining a empty list  

for i in range(3):#defining a for loop for input value

   print("Enter a 3-by-4 matrix row for row "+str(i)+":",end="")#use print method to input value

   a.append([])#use append method to add value in list

   y = input()#input value from user end  

   y = y.split(" ")#using split method to beak list value  

   for j in range(4):#defining a for loop count list value

       a[i].append(float(y[j]))#use list to add value float value

   print(a)#print value

for i in range(4):#defining for loop add all value

   t = sumColumn(a, i)#declare t variable to call sumColumn method

   print("Sum of the elements for column",i,"is",t)#defining print method print t variable value

Output:

Please find the attached file.

Explanation:

Please find the complete question in the attached file.

In the above-given program, a method "sumColumn" is declared, that uses two variable in its parameter, and an x variable is declared that use the for loop to add all list value and use a return variable to return its value.

In the next step, a for loop is declared, that use a list for input value and use split and append method and use another loop to add float value in the list.

In the next step, for loop is declared the defines the t variable and add all value in the list.    

You might be interested in
A. =A1&lt;= A14<br> B. Income – Expenses<br> C. SUM(A1:A14)<br> D. =150*.05
Tpy6a [65]
B that the anser yep i whent and reserch the the anser so itsb
8 0
4 years ago
I want to solve this question in C program, Please.
inn [45]

Answer:

#include <stdio.h>

#include <math.h>

int is_armstrong(int n) {

int cubedSum = 0;

int r = n;

while (r) {

         cubedSum += (int)pow(r % 10, 3);

          r = r / 10;

}

return cubedSum == n;

}

int stack_count(int n) {

int sum = 0;

while (n) {

         sum += n % 10;

         n = n / 10;

}

return sum;

}

int is_magical(int n) {

while (n > 9) {  

 n = stack_count(n);

 printf("%d ", n);

}

return n == 1;

}

int main()

{

int input = 0;

int isMagical, isArmstrong;

while (true) {

 printf("Enter a number: ");

 scanf_s("%d", &input, sizeof(int));

 if (input == -1) break;

 isArmstrong = is_armstrong(input);

 isMagical = is_magical(input);  

 if (isArmstrong && isMagical) {

  printf("%d is both an armstrong and a magical number.\n", input);

 } else if (isArmstrong) {

  printf("%d is an armstrong number\n", input);

 } else if (isMagical) {

  printf("%d is a magical number\n", input);

 } else {

  printf("%d is neither an armstrong or a magical number.\n", input);

 }

}

}

Explanation:

Here is a starting point. What's the definition of a magical number?

4 0
3 years ago
. ____ view displays the slides so that they almost fill the screen, and a status bar appears identifying the number of the curr
Mars2501 [29]
Reading view.  i checked on powerpoint

4 0
3 years ago
My e m a i l is chur.waifu.koko at g m a i l . c o m<br> E m a i l me, I'm lonely XD (!5 pts each)
skad [1K]

Answer:

Nice email!

Explanation:

5 0
3 years ago
Read 2 more answers
What happens as the key length increases in an encryption application?
pashok25 [27]
<span>The answer is : Increasing the key length of DES would  protect it against brute force attacks.  </span>Brute force is when the attacker tries every key knowing that one will eventually work.  <span>Key length increase proportionally increases the key space,  having a keyspace l</span>arge enough that it takes too much time and money to accomplish a brute force attack.
6 0
3 years ago
Other questions:
  • Write a program to process weekly employee time cards for all employees of an organization. Each employee will have three data i
    10·1 answer
  • The PRNG variable ___________ is defined in NIST SP 800-90 as a number associated with the amount of work required to break a cr
    7·1 answer
  • "The correct syntax for passing an array as an argument to a method when a method is called and an array is passed to it is: "
    15·1 answer
  • Which type of DNS zone resolves host names to IP addresses?
    8·1 answer
  • You need to buy a cable to connect a desktop PC to a router. Which cable should
    13·1 answer
  • Which of the following is considered a basic task in the context of computer operations? a. Connecting to the Internet b. Natura
    6·1 answer
  • Question Mode Matching Question Match the following description with the appropriate programming language generation. 1GL 1GL dr
    7·1 answer
  • Examples of hardware that computes on a network can share are the operating system and the web browsers
    10·1 answer
  • Please please help I don’t understand this
    7·2 answers
  • 1. Wash all work surfaces with a_______ wrung in hot soapy water.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!