-2

↑ Yes, it does.

Python 2.7.13

I want to input 0 for the first prompt, then .37 for then next, so it comes out to .481 For some reason, and I know I've messed up, I cannot add the 'second' variable defined above, and the 'overallheight' value is not working:

u1 = 12.5
first = .481
u2 = 2
length = u1 * 12
second = u2 / 64
overallheight = first - second #this line is not subtracting
height_multiply = overallheight / .3075
width_multiply = length / 108
def calc():
    x = float(raw_input("first prompt"))
    y = float(raw_input("second prompt"))
    y1 = (y - .0625) * height_multiply
    x1 = x * width_multiply
    y2 = y1 + second #this is the 'second' that needs to be added
    print("(%s,%s)") % (x1, y2)
while 1>0:
    calc()`
Chety M
  • 9
  • 3
  • Can you show us the error you are getting, please? – Imran Jan 29 '18 at 01:31
  • 1
    It's not an error, I am just getting the wrong value printed. – Chety M Jan 29 '18 at 01:34
  • 1
    If you tried to debug it before asking on Stack Overflow, you would know that the line above that (`second = u2 / 64`) sets the value of `second ` to 0, thus looking up the operator `/` and solve the problem yourself. – user202729 Jan 29 '18 at 01:36

1 Answers1

1

You are using Python 2, so / used with integers will do an integer division. second = u2 / 64 with u2 = 2 is 2 / 64 which is 0.

To have float divistion, you can use from __future__ import division or use floats explicitely : u2 = 2.0.

Julien
  • 13,986
  • 5
  • 29
  • 53