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
kenny6666 [7]
3 years ago
5

I am trying to create a line of code to calculate distance between two points. (distance=[tex]\sqrt{ (x2-x1)^2+(y2-y1)^2}) My li

ne is point_dist = math.sqrt((math.pow(x2 - x1), 2) + math.pow(y2 - y1), 2) but I am getting an error saying that pow is expecting two arguments and is only getting one. Can anyone help me?
Engineering
1 answer:
k0ka [10]3 years ago
6 0

Answer:

point_dist = math.sqrt((math.pow(x2 - x1, 2) + math.pow(y2 - y1, 2))

Explanation:

The distance formula is the difference of the x coordinates squared, plus the difference of the y coordinates squared, all square rooted.  For the general case, it appears you simply need to change how you have written the code.

point_dist = math.sqrt((math.pow(x2 - x1, 2) + math.pow(y2 - y1, 2))

Note, by moving the 2 inside of the pow function, you have provided the second argument that it is requesting.

You were close with your initial attempt, you just had a parenthesis after x1 and y1 when you should not have.

Cheers.

You might be interested in
computer language C++ (Connect 4 game)( this is all the info that was givin no input or solution) I used the most recent version
Mariana [72]

Answer:

C++ code explained below

Explanation:

#include "hw6.h"

//---------------------------------------------------

// Constructor function

//---------------------------------------------------

Connect4::Connect4()

{

ClearBoard();

}

//---------------------------------------------------

// Destructor function

//---------------------------------------------------

Connect4::~Connect4()

{

// Intentionally empty

}

//---------------------------------------------------

// Clear the Connect4 board

//---------------------------------------------------

void Connect4::ClearBoard()

{

// Initialize Connect4 board

for (int c = 0; c < COLS; c++)

for (int r = 0; r < ROWS; r++)

board[r][c] = ' ';

// Initialize column counters

for (int c = 0; c < COLS; c++)

count[c] = 0;

}

//---------------------------------------------------

// Add player's piece to specified column in board

//---------------------------------------------------

bool Connect4::MakeMove(int col, char player)

{

// Error checking

if ((col < 0) || (col >= COLS) || (count[col] >= ROWS))

return false;

// Make move

int row = count[col];

board[row][col] = player;

count[col]++;

return true;

}

//---------------------------------------------------

// Check to see if player has won the game

//---------------------------------------------------

bool Connect4::CheckWin(char player)

{

// Loop over all starting positions

for (int c = 0; c < COLS; c++)

for (int r = 0; r < ROWS; r++)

if (board[r][c] == player)

{

// Check row

int count = 0;

for (int d = 0; d < WIN; d++)

if ((r+d < ROWS) &&

(board[r+d][c] == player)) count++;

if (count == WIN) return true;

 

// Check column

count = 0;

for (int d = 0; d < WIN; d++)

if ((c+d < COLS) &&

(board[r][c+d] == player)) count++;

if (count == WIN) return true;

 

// Check first diagonal

count = 0;

for (int d = 0; d < WIN; d++)

if ((r+d < ROWS) && (c+d < COLS) &&

(board[r+d][c+d] == player)) count++;

if (count == WIN) return true;

 

// Check second diagonal

count = 0;

for (int d = 0; d < WIN; d++)

if ((r-d >= 0) && (c+d < COLS) &&

(board[r-d][c+d] == player)) count++;

if (count == WIN) return true;

}

return false;

}

//---------------------------------------------------

// Print the Connect4 board

//---------------------------------------------------

void Connect4::PrintBoard()

{

// Print the Connect4 board

for (int r = ROWS-1; r >= 0; r--)

{

// Draw dashed line

cout << "+";

for (int c = 0; c < COLS; c++)

cout << "---+";

cout << "\n";

// Draw board contents

cout << "| ";

for (int c = 0; c < COLS; c++)

cout << board[r][c] << " | ";

cout << "\n";

}

// Draw dashed line

cout << "+";

for (int c = 0; c < COLS; c++)

cout << "---+";

cout << "\n";

// Draw column numbers

cout << " ";

for (int c = 0; c < COLS; c++)

cout << c << " ";

cout << "\n\n";

}

//---------------------------------------------------

// Main program to play Connect4 game

//---------------------------------------------------

int main()

{

  int choice;

  int counter = 0;

  srand (time(NULL));

  Connect4 board;

  cout << "Welcome to Connect 4!" << endl << "Your Pieces will be labeled 'H' for human. While the computer's will be labeled 'C'" << endl;

  board.PrintBoard();

  cout << "Where would you like to make your first move? (0-6)";

  cin >> choice;

  while (board.MakeMove(choice,'H') == false){

  cin >> choice;

  }

  counter++;

  while (board.CheckWin('C') == false && board.CheckWin('H') == false && counter != 21){

  while (board.MakeMove(rand() % 7, 'C') == false){}

  board.PrintBoard();

  cout << "Where would you like to make your next move?" << endl;

  cin >> choice;

  board.MakeMove(choice,'H');

  while (board.MakeMove(choice,'H') == false){

  cin >> choice;

  }

  counter++;

  }

 

  if (board.CheckWin('C')){

  cout << "Computer Wins!" << endl;}

  else if (counter == 21){cout << "Tie Game!" << endl;}

  else {cout << "Human Wins!" << endl;}

  board.PrintBoard();

}

4 0
3 years ago
For a LED diode that has a= 632 nm, then the A1 is equal to:​
alexgriva [62]

Answer:

1.693242

Explanation:

The colors in the Light emitting diodes have been identified by wavelength which is measured in nano-meters. Wavelength is a function of LED chip material. The LED diode which has a = 632 then A1 will be 1.63242, this is calculated by 1 / 632. Wavelength are important for human eye sensitivity. The colors emitted from the LED will depend on the semiconductor material.

5 0
3 years ago
What is the primary responsibility of ABET?
nalin [4]

Answer:

C

Explanation:

The ABET (Accreditation Board for Engineering and Technology) is a non-governmental organization that accredits programs in applied science, computing, engineering, and engineering technology, both in the United States and elsewhere.

Give Brainliest pls

5 0
3 years ago
A simple formula to estimate the upward velocity of a rocket (neglecting the aerodynamic drag) is:
Bingel [31]

Answer:

Test code:

>>u=10;

>>g=9.8;

>>q=100;

>>m0=100;

>>vstar=10;

>>tstar=fzero_rocket_example(u, g, q, m0, vstar)

Explanation:

See attached image

5 0
3 years ago
Which of the following statements is true of a mature technology?
hoa [83]

Answer:

I think it is( More expensive than immature technologies) I took engineering class and this question is still quite tricky.

Explanation:

8 0
3 years ago
Other questions:
  • A food-services company with a 480 V, three-phase service entrance has the following set of loads:  A 7 ton walk-in refrigerati
    13·1 answer
  • A centimeter is Viooth of a meter, while a kilo-
    10·1 answer
  • If link AB of the four-bar linkage has a constant counterclockwise angular velocity of 58 rad/s during an interval which include
    11·1 answer
  • g Consider a thin opaque, horizontal plate with an electrical heater on its backside. The front end is exposed to ambient air th
    11·1 answer
  • 3–102 One of the common procedures in fitness programs is to determine the fat-to-muscle ratio of the body. This is based on the
    5·1 answer
  • 1. The area of the given triangle is 25 square units. What is the value of x?<br> X+2
    8·1 answer
  • A heat engine operates between a source at 477°C and a sink at 27°C. If heat is supplied to the heat engine at a steady rate of
    14·1 answer
  • What document should you have from the engine manufacturer when working on an engine
    8·1 answer
  • Factors such as brake shoe orientation, pin location, and direction of rotation determine whether a particular brake shoe is con
    12·1 answer
  • What measurement is the usable area of conduit based on?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!