Предмет: Информатика, автор: annawash

Срочно !!!!!!!
Трикутник заданий координатами своїх вершин A(xa, ya), B(xb, yb) та  C(xc,yc). Знайти:
а) периметр трикутника;
б) площу трикутника. Написати мовою пайтон

Ответы

Автор ответа: asphaltlev
1

Ответ:

import math

def calculate_distance(x1, y1, x2, y2):

   return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)

def calculate_perimeter(xa, ya, xb, yb, xc, yc):

   # Обчислюємо відстані між вершинами трикутника

   side_a = calculate_distance(xa, ya, xb, yb)

   side_b = calculate_distance(xb, yb, xc, yc)

   side_c = calculate_distance(xc, yc, xa, ya)

   # Знаходимо периметр

   perimeter = side_a + side_b + side_c

   return perimeter

def calculate_area(xa, ya, xb, yb, xc, yc):

   # Обчислюємо відстані між вершинами трикутника

   side_a = calculate_distance(xa, ya, xb, yb)

   side_b = calculate_distance(xb, yb, xc, yc)

   side_c = calculate_distance(xc, yc, xa, ya)

   # Знаходимо півпериметр

   semi_perimeter = (side_a + side_b + side_c) / 2

   # Знаходимо площу за формулою Герона

   area = math.sqrt(semi_perimeter * (semi_perimeter - side_a) * (semi_perimeter - side_b) * (semi_perimeter - side_c))

   return area

# Задані координати вершин трикутника

xa, ya = 1, 1

xb, yb = 4, 5

xc, yc = 7, 2

# Обчислюємо периметр та площу трикутника

perimeter = calculate_perimeter(xa, ya, xb, yb, xc, yc)

area = calculate_area(xa, ya, xb, yb, xc, yc)

print("Периметр трикутника:", perimeter)

print("Площа трикутника:", area)

Объяснение:


asphaltlev: изи
Автор ответа: firsofmark
1

Ответ:

import math

def calculate_distance(x1, y1, x2, y2):

  return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)

def calculate_perimeter(xa, ya, xb, yb, xc, yc):

  # Обчислюємо відстані між вершинами трикутника

  side_a = calculate_distance(xa, ya, xb, yb)

  side_b = calculate_distance(xb, yb, xc, yc)

  side_c = calculate_distance(xc, yc, xa, ya)

  # Знаходимо периметр

  perimeter = side_a + side_b + side_c

  return perimeter

def calculate_area(xa, ya, xb, yb, xc, yc):

  # Обчислюємо відстані між вершинами трикутника

  side_a = calculate_distance(xa, ya, xb, yb)

  side_b = calculate_distance(xb, yb, xc, yc)

  side_c = calculate_distance(xc, yc, xa, ya)

  # Знаходимо півпериметр

  semi_perimeter = (side_a + side_b + side_c) / 2

  # Знаходимо площу за формулою Герона

  area = math.sqrt(semi_perimeter * (semi_perimeter - side_a) * (semi_perimeter - side_b) * (semi_perimeter - side_c))

  return area

# Задані координати вершин трикутника

xa, ya = 1, 1

xb, yb = 4, 5

xc, yc = 7, 2

# Обчислюємо периметр та площу трикутника

perimeter = calculate_perimeter(xa, ya, xb, yb, xc, yc)

area = calculate_area(xa, ya, xb, yb, xc, yc)

print("Периметр трикутника:", perimeter)

print("Площа трикутника:", area)

Похожие вопросы
Предмет: Английский язык, автор: baktybekovas79
Choose the correct answer
1.I don't understand this sentence. What .... ?
A) does mean this word, B) does this word mean, C) means this word
2. Where's the book I gave you? What.... with it?
A) have you done, B) have you been doing, C) are you doing
3.It's two years .... Joe.
A) that I don't see, B) that I haven't seen, C) since I didn't see, D) since I saw
4..... tomorrow, so we can go out somewhere.
A) I'm not working, B) I don't work, C) I won't work
5. What was wrong with you? Why.... go to the hospital?
A) had you to, B) did you have to, C) must you
6. I decided to stay at home last night. I would have gone out if I ... so tired.
A) wasn't, B) weren't, C) wouldn't have been, D) hadn't been
7. "Where...? "In London".
A) were you born, B) are you born, C) have you been born, D) did you born
8. The path was icy, so we walked very carefully. We were afraid ....
A) of falling, B) from falling, C) to fall
9. .... A problem in most big cities.
A) Crime is, B) The crime is, C) The crimes are
10. He's lazy. He never does ... work.
A) some, B) any, C) no
11. What's the name of the man....?
A) you borrowed his car, B) which car you borrowed, C) whose car you borrowe
12. The film was really boring. It was... I've ever seen.
A) most boring film, B) the more boring film, C) the most boring film
13. I'll be in London next week. I hope to see Tom... there.
A) while I will be, B) while I'm, C) during my visit, D) during I am
14. What is informal name of New York?
A) the Big Plate, B) the Big Apple, C) the Melting Pot, D) the Small cup
15. The British flag is popularly known as .... A) Union Jack, B) Royal Ensign, C) St.
Предмет: Английский язык, автор: baktybekovas79
Choose the correct answer
1.I don't understand this sentence. What .... ?
A) does mean this word, B) does this word mean, C) means this word
2. Where's the book I gave you? What.... with it?
A) have you done, B) have you been doing, C) are you doing
3.It's two years .... Joe.
A) that I don't see, B) that I haven't seen, C) since I didn't see, D) since I saw
4..... tomorrow, so we can go out somewhere.
A) I'm not working, B) I don't work, C) I won't work
5. What was wrong with you? Why.... go to the hospital?
A) had you to, B) did you have to, C) must you
6. I decided to stay at home last night. I would have gone out if I ... so tired.
A) wasn't, B) weren't, C) wouldn't have been, D) hadn't been
7. "Where...? "In London".
A) were you born, B) are you born, C) have you been born, D) did you born
8. The path was icy, so we walked very carefully. We were afraid ....
A) of falling, B) from falling, C) to fall
9. .... A problem in most big cities.
A) Crime is, B) The crime is, C) The crimes are
10. He's lazy. He never does ... work.
A) some, B) any, C) no
11. What's the name of the man....?
A) you borrowed his car, B) which car you borrowed, C) whose car you borrowe
12. The film was really boring. It was... I've ever seen.
A) most boring film, B) the more boring film, C) the most boring film
13. I'll be in London next week. I hope to see Tom... there.
A) while I will be, B) while I'm, C) during my visit, D) during I am
14. What is informal name of New York?
A) the Big Plate, B) the Big Apple, C) the Melting Pot, D) the Small cup
15. The British flag is popularly known as .... A) Union Jack, B) Royal Ensign, C) St.
Предмет: Оʻzbek tili, автор: n30352405