jueves, 9 de marzo de 2017

Quiz 9

Quiz 9 
This one was pretty easy, we had to find the distance between two points. This obviously using a function.



As you can see, a pretty good thing to do to make things more simple, is to asign variables to the operations you make.

Here´s the code:
import math

def distance (x1,y1,x2,y2):
    a=(x2-x1)
    b=(y2-y1)
    c=math.pow(a,2)+math.pow(b,2)
    d=math.sqrt(c)
    return d

x1=float(input("Enter X1:"))
y1=float(input("Enter Y1:"))
x2=float(input("Enter X2:"))
y2=float(input("Enter Y2:"))

print("The distance between the two points is:",(distance(x1,y1,x2,y2)))


  


No hay comentarios:

Publicar un comentario