0

So I'm supposed to write a Python program that creates 3 circles of spheres: one on the xy plane, one in the yz plane, and one in the xz plane. Each ring should be centered on the origin, and I'm trying to use three while loops to do this, but nothing is working in VPython and I don't know why.

Web VPython 3.2 from visual import *

x = math.radians(360)

n = m = l = 0

while n <= x: sphere(pos = vector(math.sin(n), math.cos(m), 1), radius = 0.1, color = color.red) n = n + (math.radians(30)) m = m + (math.radians(30))

n = m = l = 0

while n <= x: sphere(post = vector(math.sin(n), m, math.cos(1)), radius = 0.1, color = color.blue) n = n + (math.radians(30)) l = l + (math.radians(30))

n = m = l = 0

while m <= x: sphere(pos = vector(n, math.sin(m), math.cos(1)), radius = 0.1, color = color.green) m = m + (math.radians(30)) l = l + (math.radians(30))

1
  • Please format your code block(s), in order to make your question more readable, and receive better quality answers. For more information, take a look on this link: meta.stackoverflow.com/questions/251361/… Commented Feb 15, 2023 at 4:37

1 Answer 1

0

Are you using Web VPython (webvpython.org or equivalently glowscript.org) or the vpython module available for use with installed Python (see installation info at vpython.org)? In either case, simply delete all occurrences of "math."; the math library is available without this (and its use with Web VPython gives an error). Also note that the name of the Python module is "vpython", not "visual".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.