Write a Python function, twoQuadratics, that takes in two sets of coefficients and x-values and prints the sum of the results of evaluating two quadratic equations. It does not do anything else. That is, you should evaluate and print the result of the following equation:

a1∗x12+b1∗x1+c1+a2∗x22+b2∗x2+c2

Answer :

MrRoyal

Answer:

The function is as follows:

def twoQuadratics(a1, b1, c1, x1, a2, b2, c2, x2):

   result = a1*x1**2+b1*x1+c1+a2*x2**2+b2*x2+c2

   return result

Explanation:

This defines the function

def twoQuadratics(a1, b1, c1, x1, a2, b2, c2, x2):

This calculates the required sum

   result = a1*x1**2+b1*x1+c1+a2*x2**2+b2*x2+c2

This returns the calculated sum

   return result

Following are the program to the given python function:

Program:

def evalQuadratic(a, b, c, x):#defining the method evalQuadratic that takes th 4 integer variable inside the parameter

   return a*x*x + b*x + c#using return keyword that calculates the parameter value

def twoQuadratics ():#defining a method twoQuadratics

   a1 = int (input("Enter a1:"))#defining a1 variable that input integer value from the user-end

   b1 = int (input("Enter b1:"))#defining b1 variable that input integer value from the user-end

   c1 = int (input("Enter c1:"))#defining c1 variable that input integer value from the user-end

   x1 = int (input("Enter x1:"))#defining x1 variable that input integer value from the user-end

   a2 = int (input("Enter a2:"))#defining a2 variable that input integer value from the user-end

   b2 = int (input("Enter b2:"))#defining b2 variable that input integer value from the user-end

   c2 = int (input("Enter c2:"))#defining c2 variable that input integer value from the user-end

   x2 = int (input("Enter x2:"))#defining x2 variable that input integer value from the user-end

   r1 = evalQuadratic(a1,b1,c1,x1)#defining r1 variable that calls evalQuadratic function

   r2 = evalQuadratic(a2,b2,c2,x2)#defining r2 variable that calls evalQuadratic function

   print("Result=",r1+r2)#using print method that adds r1 and r2 value

twoQuadratics ()#calling method twoQuadratics

Program Explanation:

  • Defining the method "evalQuadratic" that takes the for variable "a,b,c, x" integer variable inside the parameter, and use the return keyword that returns the calculated value.
  • In the next step, another method "twoQuadratics" is defined.
  • Inside this method, 8 variables which we input value from the user-end, and use r1 and r2 that adds the method value and prints its addition.
  • Outside the method, we call the "twoQuadratics" method.

Output:

Please find the attached file.

Learn more about the information from the function here:

brainly.com/question/24738846

${teks-lihat-gambar} codiepienagoya

Other Questions