Rounding a sum in Python using round()
<p>I am very new to Python2.7 (like Day 1 new), and I am trying to write a simple Mils to Degrees conversion program as a learning exercise. The program asks the user to choose to convert from degrees to mils or vice versa, then asks for a value. It divides or multiplies accordingly and prints the converted answer. Here's where the problem arises. The converted answer should not be returned as an exact floating point number. For instance- if the user inputs 6400 mils I want the program to return 360 degrees (1 degree = 17.78 mils), not 359.955 degrees. My (limited) understanding of the round function is that it accepts a float and level of precision but does not accept variables. How do I pass the sum to round()?</p>

<p>Your input is greatly appreciated.</p>

<pre><code>import sys
import math

def menu():

    print ""
    print " Mils / Degrees Conversion Calculator"
    print "-" * 38
    print ""
    print "Options: "
    print "1. Degrees to Mils"
    print ""
    print "2. Mils to Degrees"
    print ""
    print "3. Quit"
    print "-" * 20
    print""
    return input ("Choose your option: ")
    print ""

#This function contains my attempt at rounding the sum and returns errors
def m2d(a):
    print "Enter azimuth in mils (ex. 6400)"
    b = 17.78
    c = a / b
    print a, " mils = ", c, "degrees"
    round(c[])

#This function works as intended but does not include round()
def d2m(b):
    print "Enter azimuth in degrees (ex. 90)"
    a = 17.78
    print b, " degrees = ", b * a, "mils"


loop = 1
choice = 0
while loop == 1:
    choice = menu()
    if choice == 1:
       d2m(input("Degrees: "))

    elif choice == 2:
        m2d(input("Mils: "))

    elif choice == 3:
        loop = 0
</code></pre>
