Variable decimal place limit in function set by user?
Question: I just started learning python and am currently writing a script that converts
Celsius to Fahrenheit and vise versa. I have the main part done but now I want
to be able to let the user set the number of decimals displayed in the
output... The first function contains my failed attempt and the second is set
at 2 decimal places.

    
    
    def convert_f_to_c(t,xx):
    c = (t - 32) * (5.0 / 9)
    print "%.%f" % (c, xx)
    
    def convert_c_to_f(t):
        f = 1.8 * t + 32
        print "%.2f" % f    
    
    
    print "Number of decimal places?"
    dec = raw_input(">")
    
    print "(c) Celsius >>> Ferenheit\n(f) Ferenheit >>> Celcius"
    option = raw_input(">")
    
    if option == 'c':
        cel = int(raw_input("Temperature in Celcius?"))
        convert_c_to_f(cel)
    
    else: 
        fer = int(raw_input("Temperature in Ferenheit?"))
        convert_f_to_c(fer,dec)
    


Answer: 
    num_dec = int(raw_input("Num Decimal Places?")
    print "%0.*f"%(num_dec,3.145678923678)
    

in % format strings you can use a `*` for this feature

afaik there is no equivelent method in `'{}'.Format`method

    
    
    >>> import math
    >>> print "%0.*f"%(3,math.pi)
    3.142
    >>> print "%0.*f"%(13,math.pi)
    3.1415926535898
    >>>
    

