コード例 #1
0
ファイル: koed_lab5.py プロジェクト: TazmanOne/KOED_LAB5
def print_result_of_tab(table, col_names):
    result = VeryPrettyTable()
    tmp = []
    ll = ""
    #print(len(table))
    #print(table)
    print(result)
    for j in [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]:
        tmp = [elem[1] for elem in table if elem[0] == j]
        pop = []
        for elem in tmp:
            ll = "{0}".format(j)
            pop.append(elem)
            print(pop)
        result.add_column(ll, [format(i, ".2f") for i in pop])
        print(pop)
    print(result)
コード例 #2
0
net_total = total_net(netsalarylist)
roundednettotal = round(net_total, 2)
sal_total = total_sal(salaries)
roundedsaltotal = round(sal_total, 2)
ret_total = total_ret(retdollarlist)
roundedrettotal = round(ret_total, 2)

#rounding the lists themselves to two decimal places
roundedretdollarlist = [round(x, 2) for x in retdollarlist]
roundednetsalarylist = [round(x, 2) for x in netsalarylist]
roundedsalarieslist = [round(x, 2) for x in salaries]

#defining space as a place holder  to make room in the pretty table
space = ' '

#adding the information to the pretty table column by column
x.add_column("Employee Code", employee_code)
x.add_column("Salary($)", roundedsalarieslist)
x.add_column("Retirement($)", roundedretdollarlist)
x.add_column("Net Salary($)", roundednetsalarylist)

#adding a blank row to created space in the pretty table between the values and the totals
x.add_row([" ", space, space, space])
#adding the last total row to the pretty table
x.add_row(["Total($):", roundednettotal, roundedrettotal, roundedsaltotal])

#printing the pretty table with the title "Title Boxing Franchise"
print(x.get_string(title="Title Boxing Franchise"))

#printing the employee with the largest salary
print("Note! Employee: %s has the largest salary!" % maxemployee)