WSQ13 Exam 2

Good morning! This blog post will explain the exercise that we did for Exam 2.

Exercise number 1

Is about get the distance between two points. The code is the following one:

quiz1parcial

O line 1 we import the “sqrt” function form the “math” library, we’ll need it because the main formula to get the distance is .

From line 2 to line 5, we ask the user for the four values to get the location of the points. Two values for “x” and two values for “y”.

Then, let’s convert them all to floats so we can manipulate them later.

The magic comes out in line 11, where we ‘translate’ the algebraic formula to a code. As you can notice, we use the ‘sqrt’ function on line 13, and finally, let’s print the result.

Exercise number 2

quiz2parcial

Can you see the red chart? Yep, don’t do that. It was my failing code at the test.

 

 

CC BY-SA 4.0 WSQ13 Exam 2 by paogarcia2401 is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.