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
The file type blank identifies a word 2013 document
ZanzabumX [31]
Hey there! Hello!

The exclusive file type for Microsoft Word documents is .docx. You can see the attachment showing all the information you need to know about the example Word document I created. As long as you are using Word, the file type will be the same no matter what type of computer you're on or what it's running, so you don't need to worry about it being different for me on Mac than it might be for you on Windows. 

Hope this helped you out! Feel free to ask me any additional questions you may have. :-)

4 0
3 years ago
Your car's engine, transmission, power steering, and brakes all require __________ inspection and changes.
kvasek [131]

The answer is C


All parts require fluid

4 0
3 years ago
Read 2 more answers
Edhesive code practice 4.8 Question 3
vovangra [49]

Answer:

for i in range(200,301,2):

  print(i)

Explanation:

just copy and paste 100 percent

3 0
3 years ago
Read 2 more answers
Write a program and flowchart. The program should ask the user for the average temperature in each of the last 12 months. After
Afina-wow [57]

#First we define the variables to house the temperatures

#temp is an empty array that will be used to store the temperature

Temp = []

#The months is defined as stated below

months = 12

#Ask the user for the temperature input and unit if possible

print("Kindly enter the temperature here")

#the program enter loop to get the temperatures.

for x in range(months):  

   InitTemp = str(input("Kindly add the unit behind the number .eg C for celcius"))

   Temp.append(InitTemp)

j=0

for x in range(len(Temp)):  

   j=j+1

   print("The Temperature is", " ", Temp[x], "for the ", j, "Month" )

#there is an attached photo for the flowchart

5 0
3 years ago
How are static variables and methods created in Java? What happens if a non-static method of a class tries to access a static va
9966 [12]

Answer:

Static variables are the variables decaraed with keyword static, static variables must be deacraled inside the class body, means we can not declare a static variable inside a method or consttructor, static variable belongs to class, for a class only one copy is created for static variable and used by all the objects/instances.

Static variable can access with class name like

X.i

Static method are the methods defined with static keyword, static method are also part of a class, we can access static meethod using class name like

X.printI()  

Explanation:

class X

{

//to create a static variable we need use static keyword with variable name like

public static int i;

// to create a static method we need to use static keyword while defining a method like

public static void printHello() {

 System.out.println("Hello");

}

/*

 * A non static method can access static variable of a class there is no issue

 * with that we can use a static variable in a non static method like

 */

public void printI() {

 System.out.println(i);

}

/*

 * As long as the class exist in JVM static variables will be there, as static

 * variable belong to class not with the instance,

 * it does not matters if there are instance exist or not

 */

}

4 0
3 years ago
Other questions:
  • Consider the clipping of a line segment in two dimensions against a rectangular clipping window. Show that you require only the
    10·1 answer
  • Stealing passwords by using software code to run through various password schemes with numbers, symbols, capital letters, and ch
    6·1 answer
  • A man-made world event that would affect the labor market would be a(n) _____.
    13·1 answer
  • A new company will have 40 workstations in one building sharing a single network. All users must be able to share ¬les and print
    7·1 answer
  • If I use google incognito mode or a throwaway google account can my search history be tracked by Microsoft parental controls?
    7·1 answer
  • Henry has created a software product that manages a database of company clients. He wants to install the software on a client's
    13·1 answer
  • What constructs break or bend the normal Syntax patterns of scheme?
    15·1 answer
  • What is a sensitive compartmented information program
    12·1 answer
  • Find the output<br>I need it immediately​
    15·1 answer
  • If a computer uses 500 characters, how many bits this system requires to give different code to all characters?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!