#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from math import pi, sin, radians, sqrt


def select_metric(kilometers):
    if kilometers >= 1:
        return kilometers, 'km'

    if kilometers * 1000 >= 1:
        return kilometers * 1000, 'm'

    if kilometers * 100000 >= 1:
        return kilometers * 100000, 'cm'

    return kilometers * 1000000, 'mm'


def km_to_mile(km):
    return km * 0.621371192


def mile_to_km(mile):
    return mile * 1.609344


def calculate_chord(radius, arc_degrees):
    """
    Please see the wikipedia link for more information on how this works.
    https://en.wikipedia.org/wiki/Chord_(geometry)
    """

    # Calculate the arc_degrees in radians.
    # We need this because sin() expects it.
    arc_radians = radians(arc_degrees)

    # Calculate the chord.
    return radius * (2 * sin(arc_radians / 2))  # km


def calculate_half_chord(radius, arc_degrees):
    """
    Convenience function.
    I forgot to divide by 2 at some point, and ended up with your 800 meter figure.
    This function makes it harder to repeat that mistake.
    """
    return calculate_chord(radius, arc_degrees) / 2  # km


def calculate_sagitta(radius, half_chord):
    """
    Please see the wikipedia link for more information on how this works.
    https://en.wikipedia.org/wiki/Sagitta_(geometry)
    """

    # There are two possible results of this formula, corresponding to both sides of the base of the arc.
    # This will return both sides. The smaller one is the one we want to use.

    squared = sqrt((radius ** 2) - (half_chord ** 2))
    return min(radius + squared, radius - squared)  # km


def calculate_arc_degrees(viewing_distance, circumference):
    """
    Calculate how many degrees an arc of the given length would cover of the circle.
    http://www.regentsprep.org/regents/math/geometry/gp15/circlearcs.htm
    """
    return (viewing_distance / circumference) * 360  # degrees

def display_results(viewing_distance, arc_degrees, sagitta):
    print('View distance:')
    print('%0.2f miles' % km_to_mile(viewing_distance))
    print('%0.2f %s' % select_metric(viewing_distance))
    print()

    print('Arc:')
    print('%0.2f degrees' % arc_degrees)
    print()

    print("Covered by curvature:")
    print('%0.2f miles' % km_to_mile(sagitta))
    print('%0.2f %s' % select_metric(sagitta))
    print()

def main():
    # Earth's dimensions.
    circumference = 40000  # km
    diameter = circumference / pi  # km
    radius = diameter / 2  # km

    # Claimed numbers.
    viewing_distance = (Mile(126) >> Kilometer).value  # km

    # The distance in degrees.
    arc_degrees = calculate_arc_degrees(viewing_distance, circumference)

    # Calculate the half chord and the sagitta.
    # Note: if you forget to divide the chord by 2, like I just did,
    # you'll end up with the 800 meter (0.5 mile) figure.
    half_chord = calculate_half_chord(radius, arc_degrees)  # km
    sagitta = calculate_sagitta(radius, half_chord)  # km

    # Display results.
    display_results(viewing_distance, arc_degrees, sagitta)

if __name__ == '__main__':
    main()

@@ -1,27 +1,4 @@
-#!/usr/bin/env python3%0A
 # -*
@@ -1963,16 +1963,17 @@
 gitta):%0A
+%0A
     prin
@@ -1979,12 +1979,19 @@
 nt('
+### 
 View
+ing
  dis
@@ -2047,32 +2047,44 @@
 wing_distance))%0A
+    print()%0A
     print('%250.2f
@@ -2147,16 +2147,20 @@
  print('
+### 
 Arc:')%0A 
@@ -2223,16 +2223,20 @@
  print(%22
+### 
 Covered 
@@ -2290,32 +2290,44 @@
 _mile(sagitta))%0A
+    print()%0A
     print('%250.2f
@@ -2349,32 +2349,68 @@
 etric(sagitta))%0A
+    %0A    print()%0A    print('-----')%0A
     print()%0A%0Adef
@@ -2553,35 +2553,140 @@
 km%0A%0A
+%0A
     # 
-Claimed numbers
+Show the viewing distances of 10, 20, ... 60 miles,%0A    # and how much of the earth's curvature will get in the way
 .%0A    
+for 
 view
@@ -2702,48 +2702,197 @@
 nce 
-= (Mile(126) %3E%3E Kilometer).value
+in (10, 20, 30, 40, 50, 60, 125):%0A%0A        # I'll be using SI units, so I'm going to have to convert the miles to kilometers.%0A        viewing_distance = mile_to_km(viewing_distance)
   # km%0A%0A
     
@@ -2883,24 +2883,28 @@
 nce)  # km%0A%0A
+    
     # The di
@@ -2922,24 +2922,28 @@
 egrees.%0A    
+  
+  
 arc_degrees 
@@ -3000,16 +3000,20 @@
 rence)%0A%0A
+    
     # Ca
@@ -3052,16 +3052,20 @@
 agitta.%0A
+    
     # No
@@ -3125,16 +3125,20 @@
 st did,%0A
+    
     # yo
@@ -3183,24 +3183,28 @@
 le) figure.%0A
+    
     half_cho
@@ -3260,16 +3260,20 @@
  km%0A    
+  
+  
 sagitta 
@@ -3315,24 +3315,28 @@
 ord)  # km%0A%0A
+    
     # Displa
@@ -3346,16 +3346,20 @@
 esults.%0A
+    
     disp

Update main.py