Python 3 code
###################################
# Random sphere generation
# by Paramteric equations
# (graphics module)
###################################

# specify the absolute path of mod graphics folder (depends on user's choice)
import sys

sys.path.append("/Users/strumia/Library/Python/3.6/site-packages/graphics/")

from graphics import *  # import graphics module
import numpy as np   # import numpy module
import random as rd   # import random module

x = 200    # set x initial value
y = 100    # set y initial value
z = 100    # set z initial value

bgColor = "white"    # set background color
title = "Sphere"    # set window title
winWidth = 400   # set window width
winHeight = 400   # set window height

def pBall(x,y,z,rayBall,colBall):      # def cell function
  X = x
  Y = y

  Circle(Point(X,Y),rayBall)
  Circle(Point(X,Y),rayBall).draw(win).setFill(colBall)

win = GraphWin(title, winWidth, winHeight)    # define window
win.setBackground(bgColor)   # set background color

n = 126  #  set number of angular steps

x0 = np.int(.5*winWidth)   # set sphere center x co-ordinate
y0 = np.int(.5*winHeight)  # set sphere center y co-ordinate
z0 = 0    # set sphere center z co-ordinate

R = 150   # set sphere radius  value
t = 0     # set initial t parameter value
u = 0   # set initial u parameter value

# def 3D rendering functions on 2D plane
def xx(t):
  return R*np.sin(np.pi-np.pi*t/n)


def yy(t):
  return R*np.cos(np.pi-np.pi*t/n)

def co(u):
  return np.cos(2*np.pi*u/n)

def si(u):
  return np.sin(2*np.pi*u/n)

def x(t,u):
  return xx(t)*co(u)

def z(t,u):
  return yy(t)*si(u)

i = 1   # set positive value for random cycle index
while i > 0:   # random cycle
  u = rd.randrange(np.int(n/2),n,1)   # assign random values to parameter u
  t = rd.randrange(1,n,2)  # assign random values to parameter t

  # plot sphere point by point by spherical co-ordinates parametric equations
  pBall(x0 + x(t,u),y0 - yy(t),0,4, color_rgb(255,2*t,2*u))

# notice: the infinite loop needs to be stopped by the user when at the desired image stage
