TypeError: unsupported operand type(s) for /: 'float' and 'list', can't resolve
<p>I am trying to generate a plot in python to determine velocity of planets, V = sqrt(GM/r). My approach is this:</p>

<p>I can generate few hundred points for 'r' :</p>

<pre><code>r = range (57909227, 5906440628, 10000000)
</code></pre>

<p>using the largest and smallest values of 'r', which have already been given. the values of G and M are also given. my code looks like this :</p>

<pre><code>import sys
import os
import numpy
import matplotlib.pyplot as plt
from pylab import *

G=6.67*10**(-11)
M=2.0*10**30

radial_distance = range (57909227, 5906440629, 10000000)




for distance in radial_distance:
    plt.plot(radial_distance, ((G*M)/distance)**0.5, '*')
plt.show()
</code></pre>

<p>which returns me the following error:</p>

<pre><code>File "generate_list.py", line 20, in &lt;module&gt;
    plt.plot(radial_distance, ((G*M)/distance)**0.5, '*')
  File "/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.py", line 3154, in plot
    ret = ax.plot(*args, **kwargs)
  File "/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.py", line 1812, in inner
    return func(ax, *args, **kwargs)
  File "/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 1424, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 386, in _grab_next_args
    for seg in self._plot_args(remaining, kwargs):
  File "/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 364, in _plot_args
    x, y = self._xy_from_xy(x, y)
  File "/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 223, in _xy_from_xy
    raise ValueError("x and y must have same first dimension")
ValueError: x and y must have same first dimension
</code></pre>

<p>please help me fix the error.</p>

<p>What you need is to apply an expression element-wise on the list and then pass the resultant list to plot.</p>

<pre><code>y = [((G*M)/x)**0.5 for x in radial_distance]
plt.plot(radial_distance, y)
</code></pre>

python range