0

I have a point (0,0), and I want to increase the x coordinate of that point by a value that a user will specify.

def change_coordinates():
    origin = (0,0)
    x = input("By how much do you want to increase the x value?")
    # here I need a code that would change origin from (0,0) to (0+x,0)
4

2 回答 2

1

如果您使用 python 2.7.3 或以下版本:

origin = (origin[0] + x, origin[1])

如果您的 python 版本大于 3:

origin = (origin[0] + int(x), origin[1])
于 2013-04-01T23:53:10.773 回答
0
position = (1, 2)
x, y = position
position = (x + 3, y)
# now position is (4, 2)
于 2013-04-01T23:53:26.490 回答