Since I'm done with making this code of the Average and the Distance:
x1=eval(input("Please insert a first number: "))
y1=eval(input("Please insert a second number: "))
x2=eval(input("Please insert a third number: "))
y2=eval(input("Please insert a fourth number: "))
add = x1
add = add + y1
add = add + x2
add = add + y2
average = add/4
d= distanceFormula(x1,y1,x2,y2)
print("Average:", average)
print("Distance:", d)
I am now currently working on adding graphics to connect intergermath on a bar graph with python turtle graphics. However, I came across upon with some problems when I'm typing this code (Input):
def doBar(height, clr):
begin_fill()
color(clr)
setheading(90)
forward(height)
right(90)
forward(40)
right(90)
end_fill()
y_values = [str(y1), str(y2)]
x_values = [str(x1), str(x2)]
colors= ["red", "green", "blue", "yellow"]
up()
goto(-300, -200)
down()
idx = 0
for value in y_values:
doBar(value, colors[idx])
idx += 1
And here's the result on the output that I got some errors after it went out as normal:
Traceback (most recent call last):
in main
doBar(value, colors[idx])
in doBar
forward(height)
line 1637, in forward
self._go(distance)
line 1604, in _go
ende = self._position + self._orient * distance
line 257, in __mul__
return Vec2D(self[0]*other, self[1]*other)
TypeError: can't multiply sequence by non-int of type 'float'
So am I trying to do here is using both average and distance as an input and the output should be asking a user to insert four numbers and it will draw four bars on a python turtle graphics.
So how can I make this code work on graphics?