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
Zielflug [23.3K]
3 years ago
12

Write a Python3 program to check if 3 user entered points on the coordinate plane creates a triangle or not. Your program needs

to repeat until the user decides to quit, and needs to deal with invalid inputs.
Computers and Technology
1 answer:
natulia [17]3 years ago
4 0

Answer:

tryagain = "Y"

while tryagain.upper() == "Y":

    x1 = int(input("x1: "))

    y1 = int(input("y1: "))

    x2 = int(input("x2: "))

    y2 = int(input("y2: "))

    x3 = int(input("x3: "))

    y3 = int(input("y3: "))

    area = abs(x1 *(y2 - y3) + x2 * (y1 - y3) + x3 * (y1 - y2))

    if area > 0:

         print("Inputs form a triangle")

    else:

         print("Inputs do not form a triangle")

    tryagain = input("Press Y/y to try again: ")

Explanation:

To do this we simply calculate the area of the triangle given that inputs are on plane coordinates i.e. (x,y).

If the area is greater than 0, then it's a triangle

If otherwise, then it's not a triangle.

This line initializes iterating variable tryagain to Y

tryagain = "Y"

while tryagain.upper() == "Y":

The following lines get the coordinates of the triangle

    x1 = int(input("x1: "))

    y1 = int(input("y1: "))

    x2 = int(input("x2: "))

    y2 = int(input("y2: "))

    x3 = int(input("x3: "))

    y3 = int(input("y3: "))

This calculates the area

    area = abs(x1 *(y2 - y3) + x2 * (y1 - y3) + x3 * (y1 - y2))

This checks for the condition stated above.

    if area > 0:

         print("Inputs form a triangle") This is printed, if true

    else:

         print("Inputs do not form a triangle") This is printed, if otherwise

    tryagain = input("Press Y/y to try again: ") This prompts the user to try again with another set of inputs

You might be interested in
The top 3 most popular male names of 2017 are Oliver, Declan, and Henry according to babynames.
Naddik [55]

Answer:

#Set of three most popular names in 2007

male_names =  {'Oliver', 'Declan', 'Henry'}

#The male_names set is displayed to the user

print(male_names)

#The name to be removed is accepted from the user as a string

remove_name = str(input("Enter name to remove: "))

#The name to be added is accepted from the user as a string

add_name = str(input("Enter name to add: "))

#The remove method of a set is use to remove the received remove_name

male_names.remove(remove_name)

#The add method of a set is use to add the received add_name

male_names.add(add_name)

#The new set of male_names is displayed to the user

print(male_names)

Explanation:

4 0
3 years ago
Four examples of computer virus​
Nikitich [7]

Virus that infects files. Macro Virus is a virus that attaches itself to an executable application. This type of virus is commonly found in Microsoft Word or Excel programs.... Browser Hijacker.... Web Scripting Virus.

Good morning, I hope this helps, and if you don't mind, please mark me as brainliest ❤

4 0
3 years ago
What is an compiler?
marissa [1.9K]
The accurate answer is

A compiler takes your source code, it converts the entire thing into machine language and then stores these equivalent machine language instructions in a separate file. We programmers call that the "executable file.

Glad to help :)<span />
6 0
4 years ago
Read 2 more answers
Assume that your body mass index (BMI) program calculated a BMI of 20.6. What would be the value of category after this portion
algol [13]

Answer:

B normal is the answer

5 0
3 years ago
Read 2 more answers
Which term is used to describe a network security device or host software that filters communications, usually network traffic,
tensa zangetsu [6.8K]

This term could apply to a router.

4 0
3 years ago
Other questions:
  • 12.
    9·1 answer
  • What office application has animations on the home ribbon?
    7·2 answers
  • List the seven steps used by a laser printer to print a page
    9·2 answers
  • A friend of yours is having trouble getting good Internet service. He says his house is too remote for cable TV—he doesn’t even
    11·1 answer
  • An engineer plans to connect three switches (SW1, SW2, and SW3) in a lab. Before connecting the switches, he starts by configuri
    7·1 answer
  • Who does Electronic waste (E-Waste) effect
    14·1 answer
  • When using the Simple Query Wizard, Kirsten wanted to transfer all of her available data to a new table. She should click
    14·1 answer
  • Earthquakes happen when _____.
    12·1 answer
  • In computer science how can you define "copyright, designs and patents act 1988"?​
    8·1 answer
  • Who plays rocket league?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!