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]
2 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]2 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
Which of the following statements is CORRECT? a. Multiple IRRs can occur only if the signs of the cash flows change more than on
BigorU [14]

Answer: i think the answer is

a. Multiple IRRs can occur only if the signs of the cash flows change more than once.

Explanation:

3 0
2 years ago
What type of software repairs or improves a larger application that is already installed on a system?
earnstyle [38]

Answer:

<h2>Mapping</h2>

Explanation:

<h2>Hope it helps you</h2>
7 0
2 years ago
Read 2 more answers
What can a method do with a checked exception? Check the exception or ignore it. Return the exception to the sender or handle it
Serggg [28]

Answer:

Handle the exception in a catch block or throw the exception to the method that called this method.

Explanation:

The try and catch statements occur in pairs. The try statement allows the user to define a block of code to be tested for errors while it is being executed.

The catch statement allows the user to define a block of code to be executed, if an error occurs in the try block.

If an exception is checked by a method, the method either handles the exception in a catch block or throw the exception to the method calling it.

8 0
2 years ago
Read 2 more answers
Essay regarding a magic cell phone that turns into robot
igor_vitrenko [27]
Hey off the juice codine got me trippin
8 0
3 years ago
Smileys Pizzeria has a special on cheese pizza this month. 6- inch personal pizzas are $5, 10-inch small pizzas are $8, 14-inch
ValentinkaMS [17]

Answer:

THE PROGRAM IS ANEW ONE IT IS CALLED SMILEYS CHOOSER

Explanation:

4 0
3 years ago
Other questions:
  • Your friend is working on fixing their Homework assignment. They need a lot of help. You know all the bugs in the file, but due
    12·1 answer
  • My computer have black spots and line
    7·2 answers
  • Which cisco ios command is used to display the current ospf neighbors and their rids?
    11·1 answer
  • The times per second an audio file is converted from analog to digital is the ______. audio file format bandwidth sample rate wa
    5·2 answers
  • 15. Write a program in python to read three numbers in three variables and swap first two variables with the sums of
    8·1 answer
  • Your baby brother has found the hammer and is eagerly eyeing one of the boxes. Describe and analyze an algorithm to determine if
    15·1 answer
  • Not all hardware is connected with wires, some hardware might be connected wirelessly with
    9·1 answer
  • An example of computer hardware is ? A. keyboard B. app C. web browser D. operating system
    13·2 answers
  • Question 8 of 10
    5·1 answer
  • If I want to make it look like slide number one is turning a page to slide number two, what
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!