jeudi 27 septembre 2018

How to use/insert a generated random number?

I generate a number in the range 1 to 100. This number should be in the first coordinate of the pos = vec(0,0,0) (so on the x-axis). The other axes should stay 0. How can I transfer the generated number to this point?

from vpython import *
from random import randint

print(randint(1, 100))


#Sonne
sun = sphere(pos = vec(0,0,0), radius = s_rad1, make_trail = True ) 
sun.mass = 2e30   
sun.velocity = vec(0,0,0)

#Merkur
mercury = sphere(pos = vec(0,0,0), radius = s_rad1/2, color=color.red, make_trail = True ) 
mercury.mass = 3.25e23
mercury.velocity = vec(0,0,-47000)

#Venus
venus = sphere(pos = vec(0,0,0), radius = s_rad1/1.8, color=color.cyan, make_trail = True ) 
venus.mass = 4.9e24
venus.velocity = vec(0,0,-35000)




Aucun commentaire:

Enregistrer un commentaire