I need help with a computer science (Python) assignment: to create a pie chart

This is a Python assignment. I already did most of the work, it's just its not able to run properly and I haven't been able to figure it out. It'd be helpful to figure out why and edit it right. 


Important* This assignment needs to run on Python IDLE.


Below is the code I completed that needs to be edited (expense_pie.py), a pdf of the specific instructions for the assignment and the txt external file (month.txt) that are the data points for the pie chart. The code I wrote is on the last page of the assignment instructions but also in a txt file. You also need to download matplotlib.pyplot to create the pie chart. Thank you for the help! 

Get Help With a similar task to - I need help with a computer science (Python) assignment: to create a pie chart

Login to view and/or buy answers.. or post an answer
Additional Instructions:

Instructions/Design Your program will process a file that contains your expenses for last month in the following six categories: ​Rent, Gas, Food, Clothing, Transportation, Misc Write a program that reads the data from an external file and uses ​matplotlib​ to plot a ​pie chart​ showing how you spend your money. Input You need an external file called month.txt with the following points: 1000 250 350 200 375 800 Output *Needs to look similar to this* Here is how to lose points on this assignment: ● Program doesn’t execute ● program does not correctly open/read from the external file ​month.txt ● graph produced is not based on data read in from file month.txt # This program displays a pie chart that expresses the money spent given data from an external file # Inputs: External file (month.txt) added to data that contains money spent # Outputs: A pie chart # Written by: Jessica Valenzuela # Modified Date: Mar 16, 2020 import matplotlib.pyplot as plt # Output that asks for external file (month.txt) filename = input('Enter the name of file : ') # Labels for pie chart labels = [ 'Rent', 'Gas', 'Food', 'Clothing', 'Transportation', 'Misc' ] # Store expenses based on labels expenses = [] strng = fptr.read() # Read the file for line in strng.split('\n'): expenses.append(int(line)) # Add color to pie chart color = ['blue', 'gold', 'green', 'red', 'purple', 'brown'] # Set the axis as equal plt.axis('equal') # Title for pie chart plt.title('Total Expenses Paid in a Month') # To plot and create the pie chart plt.figure(figsize=(5,5)) plt.pie(expenses, labels=labels, color=color, shadow=True, startangle=140) plt.show() (HERE IS THE DATA I ALREADY HAVE. Again it needs to run in Python IDLE. The problem is that it’s not running properly. I think I messed up on the store expenses based on labels part and read the file code. Please let me know what is wrong. Thank you!)

# This program displays a pie chart that expresses the money spent given data from an external file # Inputs: External file (month.txt) added to data that contains money spent # Outputs: A pie chart # Written by: Jessica Valenzuela # Modified Date: Mar 16, 2020 import matplotlib.pyplot as plt # Output that asks for external file (month.txt) filename = input('Enter the name of file : ') # Labels for pie chart labels = [ 'Rent', 'Gas', 'Food', 'Clothing', 'Transportation', 'Misc' ] # Store expenses based on labels expenses = [] strng = fptr.read() # Read the file for line in strng.split('\n'): expenses.append(int(line)) # Add color to pie chart color = ['blue', 'gold', 'green', 'red', 'purple', 'brown'] # Set the axis as equal plt.axis('equal') # Title for pie chart plt.title('Total Expenses Paid in a Month') # To plot and create the pie chart plt.figure(figsize=(5,5)) plt.pie(expenses, labels=labels, color=color, shadow=True, startangle=140) plt.show()

Related Questions

Similar orders to I need help with a computer science (Python) assignment: to create a pie chart
7
Views
0
Answers
Java Customer Program
Problem 1: Customer Max has opened his own pet supply store so he can help himself to treats and toys whenever he wishes. In order to encourage customers to shop at his store more, he is implementing a customer loyalty program. For every $100 spent, the c...
11
Views
0
Answers
Literature Review for Smart Case for tracking monitoring and tracing packages being delivered
They're three attachments below one being the handbook to help guidance during this progress another being the first proposal of the project and then the assignment that needs completing, the Literature review....
15
Views
0
Answers
c++ lab 1 intro lab
P ROBLEM STATEMENT: A review and extension of cs132: sort a file with 120 records. However, due to memory restrictions only 20 records may be placed into memory. You are to implement a “quasi” external sort CODE/DIRECTIONS: For the sake of si...
19
Views
0
Answers
Cryptography Assignment C
1. Write two programs that use some of the build-in Cryptographic APIs a. Write one C program that uses Symmetric-Key algorithm b. Write one C program that used Asymmetric-key algorithm c. Use C programming language to write your code d. Make sure tha...