Estimating of the size of the Milky Way from the Sun's motion I am trying to run a simple first-principles calculation to estimate the diameter of the Milky Way from what we know about the motion of the Sun around its center. In particular, from various online sources and books, we can roughly say that:

*

*The period of the Sun's orbit around the center of the Milky Way is $T_{sun}\approx 200$ million years.

*The speed of the Sun in its orbit is $v_{sun}\approx 200$ km/s.

*The sun is located about halfway between the Milky Way's center and its edge.

This is a purely kinematic problem. I'll assume that the Sun's orbit is circular, so that we may write:
$$
\omega_{sun}r_{sun} = v_{sun},
$$
where $\omega_{sun}=2\pi/T_{sun}$ is the angular velocity of the Sun around the Milky Way center. Hence:
$$
r_{sun} = \frac{T_{sun}}{2\pi}v_{sun}.
$$
The radius of the Milky Way is twice that (the Sun is halfway out to the edge), and the diameter is twice that again. So the overall diameter of the Milky Way, in light years (denoting the speed of light by $c$):
$$
d_{MilkyWay} = \frac{2T_{sun}v_{sun}}{c\pi}.
$$
We know all the quantities on the right hand side. A short Python code evaluates the solution.
T_sun = (200e6)*365.25*24*3600 # [s]
v_sun = 200e3 # [m/s]
c = 2.99792458e8 # [m/s]
pi = 3.14159
d_MilkyWay = 2*T_sun*v_sun/(c*pi) # [ly]

print "d_MilkyWay = %.2e [light years]"%(d_MilkyWay)

The answer: $d_{MilkyWay} = 2.68\cdot 10^{12}$ light years. This is much, much larger than the current best estimate given by scientists: about $10^5$ light years.
How come there is such a huge discrepancy between the measured size, and my rough estimate? Is the assumption that the Sun's orbit is circular wrong?
 A: It took me embarrassingly long to figure this out. Your calculations are mostly correct, except at the end. The "diameter" of the Milky Way would indeed be $$d = 2 \frac{T_\text{sun} v_\text{sun}}{c\pi},$$ but this is in light-seconds not years. You need to further divide this by the number of seconds in one year. And if you do this, you will find that $$d \approx 85,000 \text{ light years}.$$
(Alternatively, and perhaps much more efficiently, you could just measure $T_\text{sun}$ in years, that would give the same answer with fewer calculations.)
A: Dimensional
analysis is hard,
and I just wanted to verify the calculations of other answers here.
Since you are using Python, you should know that there are tools that
can assist in dimensional analysis; These tools can be very helpful and
would in this case show you where you went wrong.
Taking your sample code and turning it into a dimensional one, using
pint (other tools for
dimensional analysis are available), will look as follows:
import pint
U = pint.UnitRegistry()

T_sun = 200e6 * U.years
v_sun = 200 * U.km / U.s
r_sun = (T_sun / (2 * U.pi)) * v_sun
d_milkyway = 2 * 2 * r_sun

print('d_milkyway ~ {:.1f}'.format(d_milkyway.to('light_years')))

Which yields
d_milkyway ~ 84941.4 light_year

Note that if we omit the conversion to('light_years'), we would see
d_milkyway ~ 8.0e+10 kilometer * year / pi / second

A: Problem: Wrong units

$$
 d_{MilkyWay} = \frac{2T_{sun}v_{sun}}{c\pi}
 $$

And that's your first problem, right here. You cannot disregard units and expect to get any correct or even well-defined result from your calculations.
The left-hand side is a distance (e.g. in meters, light-years or light-seconds), the right-hand side is a duration. This cannot work, and you cannot use this equation anywhere.
Light-years are not years, just like light-seconds are not seconds.
Solution: Remove $c$
The correct formula is simply:
$$
d_{MilkyWay} = \frac{2T_{sun}v_{sun}}{\pi}
$$
Order of magnitude
Before using any tool in order to calculate the exact result, you should first try to get some idea about the correct order of magnitude (see Fermi problem).
The goal should be to simplify the calculation until it becomes easy to do mentally, without being too wrong.

So $3 \approx 1$ and $4 \approx 10$ are perfectly acceptable, but $10^5\approx10^{12}$ isn't.
You could notice that 200 km/s is approximately $\frac{c}{1000}$.
Here's the order-of-magnitude estimate:
\begin{align}
d_{MilkyWay} & \approx \frac{2v_{sun}T_{sun}}{\pi} \\
 & \approx \frac{2*200\mathrm{km/s}*200\thinspace000\thinspace000\mathrm{y}}{\pi} \\ 
 & \approx \frac{2*\frac{c}{1\thinspace000}*200\thinspace000\thinspace000\mathrm{y}}{\pi} \\
 & \approx \frac{2*c*200\thinspace000\mathrm{y}}{\pi} \\
 & \approx \frac{400\thinspace000}{\pi}*c*\mathrm{y} \\
 & \approx 100\thinspace000 \mathrm{ly}
\end{align}
This is not the exact answer. But whichever tool you use, you should expect to get a result not too far away from $10^{5}\mathrm{ly}$.
Result
With Python
If you want to stick with Python, you could use @PålGD's excellent answer.
With Wolfram Alpha
Wolfram Alpha does a good job at converting units:
2*200km/s*200million years/pi to lightyears
You get many different units as a bonus, and even a direct comparison to the correct galactic diameter:

With Qalculate
Qalculate! is an excellent desktop calculator, and it supports many units:

A: You messed up a bit in your calculation. Your answer is in light-seconds, not light-years. If you divide by the number of seconds in a year, you'll get the correct answer.
T_sun = (200e6)*365.25*24*3600 # [s]
v_sun = 200e3 # [m/s]
c = 2.99792458e8 # [m/s]
pi = 3.14159
d_Milkyway_m = 2*T_sun*v_sun/pi # [m]
d_MilkyWay = d_Milkyway_m/(c*365.25*24*3600) # [ly]

print "d_MilkyWay = %.2e [light years]"%(d_MilkyWay)

