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
.What is a wildcard character? How would you use it to find a record?
7nadin3 [17]

Answer and Explanation:

A wildcard character is a character that can be substituted for either a single character or a string of characters. For instance, in certain operating systems, the asterisk character "*" can be used in lieu of a set of characters, while the character "?" can be used in lieu of a single character.

It is a special character that represents one or more other characters. The most commonly used wildcard characters are the asterisk (*), which typically represents zero or more characters in a string of characters, and the question mark (?), which typically represents any one character.

For example, in searching: run* would mean "any word that starts with 'run' and has any kind of ending." If you entered "run*" at a search engine that offered a wildcard character capability, you would get results for run, runs, running, runner, runners - in short, any possible word that might begin with the three letters.

Use of wildcard character:

Wildcard characters are utilized in customary articulations (a programming type wherein input information is adjusted depending on indicated designs) and in scanning through record catalogs for comparable document names (for instance, if all the work documents on an undertaking start with the characters "F7," you could undoubtedly find all the venture records by just looking for "F7*").  

It is a special case character and is a sort of Meta character .  

In different card games, a wildcard is an assigned card in the deck of cards.

8 0
3 years ago
Which of the following are safety guidelines when socializing online?
DochEvi [55]

Answer:

All of them execpt five and three.

Explanation:

It is okay to have social media and receive messages.

3 0
2 years ago
One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input
salantis [7]

Answer:

import java.util.Scanner;

public class Miles {

public static void main(String[] args) {

   //initialization

       double Number_Miles;

       //print the message

       System.out.print("Enter the number of miles: ");

       Scanner scn1 = new Scanner(System.in);

       

       Number_Miles = scn1.nextDouble();  //read the input from user

       //calculate the laps

       double yourValue = Number_Miles/0.25;

       //display the output on the screen

       System.out.printf("%.2f", yourValue);

     

}

}  

Explanation:

First import the library Scanner than create the class and define the main function. In the main function, declare the variables.

print the message on the screen and then store the value enter by the user into the variable.

Scanner is a class that is used for reading the output. So, we make the object of the class Scanner and then object call the function nextDouble() which reads the input and store in the variable.

After that, calculate the number of laps by dividing the number of miles with the given one lap running track value (0.25 miles).

Number\,of\,laps = \frac{Number\,of\,miles}{0.25}

the output is stored in the variable.

After that, print the value on the screen with 2 digits after the decimal point.

we can use "%.2f" in the printing function in java.

like System.out.printf("%.2f", output);

5 0
3 years ago
Read 2 more answers
What is an example of a dedicated computer system?
Maslowich
Database server - computer dedicated to databases
Hope this helped
5 0
4 years ago
Read 2 more answers
Objectives ** WILL GIVE BRAINIST PLEASE**
mamaluj [8]

Answer:

of which std this question is

8 0
3 years ago
Read 2 more answers
Other questions:
  • Local television news networks cover only
    8·2 answers
  • How are the stop lamp bulbs connected in relation to each other? a. In parallel. b. In series. c. In series/parallel. d. None of
    13·1 answer
  • To prevent injury when pulling a nail be sure the material holding the nail is
    14·1 answer
  • G Suite for Education offers which benefits to educators? (Select all that apply.) Select All Correct Responses Android apps ava
    10·1 answer
  • Before his job interview, Shabnam took the time to carefully wash and iron his best khaki pants and a button-down shirt. He even
    15·2 answers
  • There are several different formats for storing images. They are prints, slides, negatives, and digital. Which is the best forma
    8·1 answer
  • 14. You can store data copied from any Office application file with the
    14·1 answer
  • A technician is troubleshooting a Windows computer and needs to stop the explorer.exe process. Multiple attempts to open Task Ma
    5·1 answer
  • Given all of the limitations of MBR, is it still relevant in current day use?
    15·1 answer
  • There is a population of owls in a forest. In one year there are 20 new owls born and 10 owls die. In this same year, 5 owls ent
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!