1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nookie1986 [14]
3 years ago
13

Create a text file that contains your expenses for last month in the following categories: • Rent • Gas • Food • Clothing • Car

payment • Misc Write a Python program that reads the data from the file and uses matplotlib to plot a pie chart showing how you spend your money

Computers and Technology
1 answer:
ololo11 [35]3 years ago
3 0

Answer:

Check the explanation

Explanation:

Code:

import matplotlib.pyplot as plt

filename = input('Enter the name of file : ')

# open file in read mode

fptr = open(filename , 'r')

# set the labels

categories = [ 'Rent', 'Gas', 'Food', 'Clothing', 'Car Payment', 'Misc' ]

# store the expenses in the order of labels

expenses = []

# read the content of file

strng = fptr.read()

# read the file line by line

for line in strng.split('\n'):

   # add the current expense to expenses

   expenses.append( int( line ) )

colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue', 'green', 'red']

# plot the pie chart

plt.pie(expenses, labels = categories, colors = colors, autopct='%1.1f%%', shadow=True, startangle=140)

# set the axis as equsl

plt.axis('equal')

# display the chart

plt.show()

------------------------------input.txt--------------------------

1000

235

5600

800

480

758

Kindly check the attached output image below.

You might be interested in
Please select the word from the list that best fits the definition<br><br> Plagiarism
Pachacha [2.7K]
The practice of taking someone else's work or ideas and passing them off as one's own.
5 0
1 year ago
Read 2 more answers
A programmer has an idea to use just one language for the content, structure, and style of web pages. What might be a problem wi
Juliette [100K]
Doesn’t give the programmer a lot of freedom to be creative. Using only one language on the web limits the amount features the programmer could create.

For example, just only using HTML limits the web page’s features to use scripts like Javascripts.
8 0
2 years ago
The loop function is similar to range(), but handles the parameters somewhat differently: it takes in 3 parameters: the starting
nexus9112 [7]

Answer and Explanation:

def loop(start, stop, step):

   return_string = ""

   if step == 0:

       step = 1

   if start > stop:  # the bug was here, fixed it

       step = abs(step) * -1

   else:

       step = abs(step)

   for count in range(start, stop, step):

       return_string += str(count) + " "

   return return_string.strip()

5 0
3 years ago
Do you agree with the EU's decision that people should be able to ask Google to remove search results that contain incorrect, un
AnnyKZ [126]

Answer: Yes

Explanation: One should not be able to just find negative information on someone just because they googled it (unless they're famous of course)

7 0
3 years ago
Read 2 more answers
A user wants to quickly share pictures between mobile devices. The devices will be in close proximity so the necessity of a thir
BlackZzzverrR [31]

Answer:

NFC(Near Field Communication).

Explanation:

When user wants to share pictures quickly between the mobile devices which are in very close proximity we can use NFC(Near Field Communication).

Near Field Communication(NFC):-It is a group of communication protocols that lets two devices most of the times these are mobile phones to establish connection and the distance between them should be less around 4 centi meter.

8 0
3 years ago
Other questions:
  • Constructors ________. initialize instance variables when overloaded, can have identical argument lists when overloaded, are sel
    11·1 answer
  • Justin Blake and Raegan Beast anyone?? I miss Jaegan a ton and I need a fangirl to talk to.
    13·1 answer
  • The network layer of the Internet model uses the _____________ protocol to route messages though the network.
    13·1 answer
  • Which guideline should you use when downloading software from the Internet?
    15·1 answer
  • What does an operating system do?
    12·1 answer
  • Define client and.server​
    13·1 answer
  • Match each of the following terms to its definition: I. web-based II. open source III. project management IV. personal informati
    12·1 answer
  • The function's only behavior should be to return the sum of array userVals' elements. What common error does the function make?
    6·1 answer
  • What is an outcome in a game? Don't search google just give me an answer
    9·1 answer
  • Paragraph on uses of computer 100 words plss​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!