answer.
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]
1 year 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]1 year 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 processing of data in a computer involves the interplay between its various hardware components.
Ronch [10]

True.

Data processing involves the conversion of raw data and the flow of data through the Central Processing Unit and Memory to output devices. Each CPU in a computer contains two primary elements: the Arithmetic Logic Unit (ALU) and the control unit. The Arithmetic Logic Unit performs complex mathematical calculations and logical comparisons. On the other hand, the control unit accesses computer instructions, decodes them, and controls the flow of data in and out of the Memory, ALU, primary and secondary storage, and various other output devices.  


8 0
2 years ago
. Write a statement that throws an IllgalArgumentException with the error message Argument cannot be negative.
dybincka [34]

Answer:

public class PostAccount

{

  public void withdraw(float savings)

  {

     if (savings >=0 )

     {

        IllegalArgumentException exception

              = new IllegalArgumentException("Savings cannot be negative");

        throw exception;

     }

     balance = savings - withdraw;

  }

 }

Explanation:

IllgalArgumentException is a type of NumberFormatException  of runtime exception. Here in the program we have created an object of IllgalArgumentException class and after that we have thrown the error to show the condition if it does not satisfy the if condition.

8 0
1 year ago
Which type of styles can be applied to a word, phrase, or sentence?
Anna [14]

Answer:

I think the answer is going to be paragraph

6 0
2 years ago
A restaurant manager wants to advertise that his lunch special offers enough choices to eat different meals every day of the yea
riadik2000 [5.3K]
2 to 12 options for each customer
6 0
1 year ago
Var name = prompt("Enter the name to print on your tee-shirt");
Vinil7 [7]

Willy Shakespeare has 17 characters. It's higher than 12,so the output will be Too long. Enter a name with fewer than 12 characters.

Letter a.

3 0
2 years ago
Other questions:
  • De'Von is graduating from college and wants to create a professional development plan in order to prepare for his future. What i
    8·1 answer
  • The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
    7·1 answer
  • Memory is a _____________ that includes the organization and shaping of information by processing, storage, and retrieval of inf
    15·1 answer
  • Choose the correct sequence for classifier building from the following.
    7·1 answer
  • A good way to avoid skids is to _____ when coming into a turn. A. accelerate B. decelerate C. counter steer D. cover brake
    8·2 answers
  • Which of the following should get a Page Quality (PQ) rating of Low or Lowest? Select all that apply. True False A page with a m
    8·1 answer
  • 1.the following code example would print the data type of x, what data type would that be?
    12·1 answer
  • Why are smartphones and tablets capable of handling rich content and interactivity?
    12·1 answer
  • When do images or graphics in Microsoft Word hurt the document rather than help
    9·1 answer
  • If Maya wants to access a view that would control multiple slides within a presentation, which view should she utilize? Master v
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!