project_to_distance does not have a return statement Click Here so
print project_to_distance(2, 7,4)
prints None
5. the variable, scale, does not exist outside of the function in the code posted
temp1= point_x * scale
Here is a general example that might help ...
''' distance_two_points.py
calculate the distance between two points given the coordinates
of the points (x1, y1) and (x2, y2) in a 2D system
'''
import math
def get_distance(x1, y1, x2, y2):
'''
returns distance between two points using the pythagorean theorem
the function parameters are the 2D coordinates of the two points
'''
dx = x2 - x1
dy = y2 - y1
return math.sqrt(dx**2 + dy**2)
sf = "Distance between point({}, {}) and point({}, {}) is {}"
x1, y1 = 1, 3
x2, y2 = 4, 7
print(sf.format(x1, y1, x2, y2, get_distance(x1, y1, x2, y2)))
x1, y1 = 2, 5
x2, y2 = 11, 23
print(sf.format(x1, y1, x2, y2, get_distance(x1, y1, x2, y2)))
''' result ...
Distance between point(1, 3) and point(4, 7) is 5.0
Distance between point(2, 5) and point(11, 23) is 20.1246117975
'''
Hi!
I have two tables, I will call them first-half and second-half (of the year)
Table: first
id jan feb mar apr
-----------------------
2 80 90 70 60
3 50 40 60 30
Table: second
id jan feb mar apr
-----------------------
2 50 70 60 90
3 80 60 50 ...
from turtle import *
import random
def allTriMedian (w=300):
speed (0)
vertices = []
point = turtle.Point(x,y)
for i in range (3):
x = random.randint(0,300)
y = random.randint(0,300)
vertices.append(trutle.Point(x,y))
point = turtle.Point(x,y)
triangle = turtle.Polygon(vertices)
a = triangle.side()
b = triangle.side()
c = triangle.side()
m1 = tirangle.median
m2 = triangle.median ...
I'm trying to figure out how do i print a distinct enum value by using a conditional statement in my construction of array.
I have a enum declaration
enum Animal {Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Sheep, Monkey, Rooster, Dog, Pig};
And i construct my array using a voidptr ...