subject

You will create a program that will take in the values for two points (x1 , x2) and (y1, y2) to find the slope of a line that contains those two points. I have provided the pseudocode for you below. All you need to do is translate the pseudocode to a Python program that will run and output the correct slope.

You can test your program by entering the following two point values: (x1 , y1) –> (32, 22) and (x2 , y2) –> (53, 36). Your slope should be 2/3.

PROCEDURE getCoordinates ()
{
<< global variables predefined in starter code >>

DISPLAY (What is the value of x1?)

x1 ← INPUT()

DISPLAY (What is the value of y1?)

y1 ← INPUT()

DISPLAY (What is the value of x2?)

x2 ← INPUT()

DISPLAY (What is the value of y2?)

y2 ← INPUT()

}

PROCEDURE getSlope()

{

<< global variables predefined in starter code >>

numerator ← y2 - y1

denominator ← x2 - x1

getHighestMultiple()

numerator ← numerator / highestMultiple

denominator ← denominator / highestMultiple

DISPLAY(“Slope is ” + numerator + “/” + denominator)

}

PROCEDURE getHighestMultiple()

{

<< global variables predefined in starter code >>

temp ← numerator

while (temp > 1)

{

IF((numerator MOD temp == 0) and (denominator MOD temp == 0))

{

highestMultiple ← temp

}

temp ← temp - 1

}

}

getCoordinates();
getSlope();

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 16:00, oranzajimenez
Create a logic array qualifyingindex with true for any location where the runner is male with a running time less than 8.2. row array runnergenders indicate if a runner if male (m) or female ( f. row array runnertimes indicates the corresponding runner's time.
Answers: 1
image
Computers and Technology, 22.06.2019 12:00, dani19cano
The following function returns a string of length n whose characters are all 'x'. give the order of growth (as a function of n) of the running time. recall that concatenating two strings in java takes time proportional to the sum of their lengths. public static string f(int n) { if (n == 0) return ""; if (n == 1) return "x"; return f(n/2) + f(n - n/2); } options: a) constant b) logarithmic c) linear d) linearithmic e)quadratic f)cubic g) exponential
Answers: 2
image
Computers and Technology, 23.06.2019 12:00, muncyemily
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
image
Computers and Technology, 25.06.2019 02:30, LilCookies1
Ahammer should not be applied to the gear shafts of an electric rotisserie because the shafts may be made of
Answers: 1
You know the right answer?
You will create a program that will take in the values for two points (x1 , x2) and (y1, y2) to find...

Questions in other subjects: