Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING PYTHON: Write a function called triangle_centroid() that has sex parameter

ID: 674628 • Letter: U

Question

USING PYTHON: Write a function called triangle_centroid() that has sex parameters x1, y1, x2, y2, x3, y3 (in that order) and that computes and returns the distance from the origin to the centroid of the triangle defined by the points (x1, y1), (x2, y2), and (x3, y3) . For more information about triangle centroids, see your function should print a meaningful error message such as “triangle_centroid: error– arguments must all be numbers”, and return None. Your function should work whether the passed values are integers or floats , and positive, negative or zero. Your function does NOT have to confirm that the three points form a triangle – you may assume they do for this problem.

Explanation / Answer

/* Write a program for centroid of triangle/

import math
import turtle

def tempconvert(var):

        try:
            return int(var)
        except ValueError , Argument:
            print "Arguments must be all number ", Argument

def main():
    
     x1 = tempconvert(input('Enter the length of X first side: '))
    x2 = tempconvert(input('Enter the length of X second side: '))
    x3 =tempconvert(input('Enter the length of X third side: '))

    y1 = tempconvert(input('Enter the length of Y first side: '))
    y2 = tempconvert(input('Enter the length of Y second side: '))
    y3 =tempconvert(input('Enter the length of Y third side: '))
  

print('The centroid of the triangle X is: ', format(x(x1, x2, x3),',.1f'))
print('The centroid of the triangle Y is: ', format(y(y1, y2,y3),',.1f'))

def x(x1,x2,x3):
     c1=x1+x2+x3
     s1=c1/3
     return s1

def y(y1,y2,y3):
     c2=y1+y2+y3
     s2=c2/3
     return s2

main()