In [ ]:
# Part 1

def file_to_float_list(file_name):
    nums = []
    with open(file_name) as fh:
        for line in fh:
            num = float(line.rstrip())
            nums.append(num)
    return nums

budget = 2000.00
prices = file_to_float_list('budget_prices.txt')
spent = sum(prices)
percent_spent = (spent/float(budget)) * 100
print("Budget: {} Spent: {} Percentage Spent: {}%".format(budget, spent, percent_spent))

In [ ]:
# Part 2

def file_to_string_list(file_name):
    lines = []
    with open(file_name) as fh:
        for line in fh:
            lines.append(line.rstrip())
    return lines

stuff_bought = file_to_string_list('budget_items.txt')
items_and_prices = list(zip(stuff_bought, prices))
for item, price in items_and_prices:
    print("{}\t{}".format(item, price))
print("Sum\t{}". format(sum(prices)))
print("Budget\t{}".format(budget))

In [ ]: