#coding:utf-8
    
    #print("\n")
    #title= "  {:3} {:5} {:8} {:4}"  #最小幅
    #print(title.format("n","n^2","n^3","n^4")) 
    #文字列型では右側を空白で埋める
    
    print("\n  n   n^2   n^3      n^4")
    num = 2 
    while num <= 9:
        ans = "{:3g} {:4g} {:6g} {:8g}"
        print(ans.format(num,pow(num,2), pow(num,3),pow(num,4))) 
        #数字型は右寄せ、左側を空白で埋める
        num +=1
    
                
実行結果
IICA Lecture Guide
        #coding:utf-8
        
        #built-in math module
        
        import math
        print("\n d      a       sin(a)    cos(a)")
        d = 15 
        while d <= 180:
            a = math.radians(d)
            ans = "{:3g}   {:5.2f}     {:5.2f}    {:5.2f}" 
            print(ans.format(d, a, math.sin(a), math.cos(a))) 
            #浮動小数点数型(実数)は :幅.小数点以下何桁までf, :5.2f    
            d += 15