|
If you're new to Python A VPython tutorial Pictures of 3D objects Choose an object: Work with objects: Windows & Events: What's new in Visual 5 VPython web site |
Floating DivisionFor versions of Python prior to 3.0, Python performs integer division with truncation, so that 3/4 is 0, not 0.75. This is inconvenient when doing scientific computations, and can lead to hard-to-find bugs in programs. You can write 3./4., which is 0.75 by the rules of "floating-point" division. You can change the default so that
3/4 is treated as 0.75. Place this at the start of your program: from __future__ import division There are two underscores ("_" and "_") before "future" and two after. Starting with Python 3.0, 3/4 means 0.75 and from __future__ import division is no longer needed and is ignored. You may wish to include this statement, however, so that your program will run correctly on earlier versions of Python. The Visual module converts integers to floating-point numbers for you when specifying attributes of objects: object.pos = (1,2,3) is equivalent to object.pos = (1.,2.,3.) |
||