|
738 | 738 | " print \"The {0} costs ${1}\".format(sushi, price)" |
739 | 739 | ] |
740 | 740 | }, |
| 741 | + { |
| 742 | + "cell_type": "markdown", |
| 743 | + "metadata": {}, |
| 744 | + "source": [ |
| 745 | + "# Project: Party Budget\n", |
| 746 | + "\n", |
| 747 | + "You are tasked with writing budgetting software, but at this point, things are a mess. You have two files. `budget_prices.txt` has a list of costs for each item separated by new lines (\\n). `budget_items.txt` has a list of the items that were bought. Luckily they are both in order. You need to write a program that will take the files and a value for the overall budget and print out the total spent and how close they are to reaching the budget. In step 2 you will create a new file where the items and prices are in the same document and there is a sum printed out at the end.\n", |
| 748 | + "\n", |
| 749 | + "\n", |
| 750 | + "## Step 1\n", |
| 751 | + "1. Create a function called file_to_float_list that takes in a file and returns a list containing a float for each line **Hint** Make sure to remove the newlines when casting as floats.\n", |
| 752 | + "2. Store the budget of 2000.00 in a variable called budget.\n", |
| 753 | + "3. Run file_to_float_list on budget_prices.txt and save the result in a variable called prices.\n", |
| 754 | + "4. Calculate the sum of the prices array and store in a variable called spent.\n", |
| 755 | + "5. Calculate the percentage of budget spent and store in a variable called percent_spent\n", |
| 756 | + "6. Print out the results:\n", |
| 757 | + "\n", |
| 758 | + " Budget: 2000.00 Spent: (amt spent) Percentage Spent: (percent spent)\n", |
| 759 | + "\n", |
| 760 | + "7. ** Bonus ** Print out a progress bar for the budget. Print out = for every 10% spent and - for every 10% unspent. =====>-----\n", |
| 761 | + "\n", |
| 762 | + "## Step 2\n", |
| 763 | + "1. Create a function called file_to_string_list that takes in a file and returns a list containing a string for each line with newlines removed.\n", |
| 764 | + "2. Run file_to_string_list on budget_items.txt and save the result in a variable called stuff_bought.\n", |
| 765 | + "3. Zip stuff_bought and prices together and store in a varible called items_and_prices\n", |
| 766 | + "4. Loop through items and prices and print out the item, then a tab character '\\t' and then the price (use string formatting)\n", |
| 767 | + "5. Print another line 'Sum\\t(amount spent)'\n", |
| 768 | + "6. Print a final line 'Budget\\t(budget)'\n", |
| 769 | + "\n", |
| 770 | + "7. **Bonus** Print everything you printed for step 2 into a new file. (Then try to open the file in excel.)" |
| 771 | + ] |
| 772 | + }, |
741 | 773 | { |
742 | 774 | "cell_type": "code", |
743 | 775 | "execution_count": null, |
|
0 commit comments