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
Ksenya-84 [330]
4 years ago
14

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

r 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:
Whitepunk [10]4 years ago
7 0

Answer:

  1. from matplotlib import pyplot as plt
  2. with open("text.txt") as file:
  3.    data = file.readlines()
  4.    category = []
  5.    amount = []
  6.    for row in data:
  7.        values = row.split(" ")
  8.        category.append(values[0])
  9.        amount.append(float(values[1]))
  10.    
  11. figure = plt.figure()
  12. ax = figure.add_axes([0,0,1,1])
  13. ax.axis('equal')
  14. ax.pie(amount, labels = category, autopct='%1.2f%%')
  15. plt.show()

Explanation:

Firstly, we need to import matplotlib library (Line 1).

Next, open a file stream and use readlines method to read the data from the text file (Line 4). Presume the data read from the text files are as follows:

Rent 450

Gas 150

Food 500

Clothing 120

Car 600

Create two lists, category and amount (Line 5-6). Use a for loop to traverse through the read data and use split method to break each row of data into two individual items. The first item is added to category list whereas the second item is added to amount list (Line 7 - 10).

Next, create a plot figure and then add the axes (Line 12 - 13). We can use the pie method to generate a pie chart (Line 15) by setting the amount list as first argument and category list as value of labels attributes. The output pie chart can be found in the attachment.

You might be interested in
What is the purpose of a forecast worksheet?
Liono4ka [1.6K]

Answer: It’s a

Explanation:

I got it right on edj

8 0
3 years ago
15. You read a news article that's politically biased and not well organized. It's
kati45 [8]

You read a news article that's politically biased and not well organized. It's likely; A: A fake news

<h3>Understanding how to report a story</h3>

Let us look at each of the options given;

A: A fake news: This is a news that lacks credibility based on lack of proper research or evidence.

B: An indirect Citation; An indirect citation is when the ideas of one author are published in another author's text but then you have not read or accessed the original author's work.

C: A reliable source; This is a source that provides a thorough, well-reasoned theory, argument, discussion that is based on strong evidence.

D: A direct Citation; A direct citation is when you directly quote the exact words of an author or speaker.

Read more about reporting of a Story at; brainly.com/question/10111803

3 0
2 years ago
Why would you use a topic web?
sergejj [24]
<span>A topic web is commonly used to expand the subject of your research paper. It is a tool to help researcher for a flexible framework of developing ideas, information and its relationships between concepts. Moreover, it is a brainstorming strategy where the subject will be link to the supportive ideas or details that would improve fluency of topic. </span>
7 0
4 years ago
Read 2 more answers
The arrow next to all programs indicates
myrzilka [38]

Answer:

the presence of a submenu

Explanation:

The options are:

  • this item cannot be selected
  • that this was the most recently used item
  • the importance of the item
  • the presence of a submenu

And the correct option is certainly the fourth option, and which is the presence of the submenu. The arrow next to all the programs certainly indicates that there is a submenu, and hence, the fourth option is the correct option here.

6 0
3 years ago
My Mac is stuck on this screen? How to fix?
mixer [17]

Answer:

Press and hold the power button for up to 10 seconds, until your Mac turns off. If that doesn't work, try using a cellular device to contact Apple Support.

Explanation:

If that also doesn't work try click the following keys altogether:

(press Command-Control-Eject on your keyboard)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This makes the laptop (macOS) instruct to restart immediately.

Hopefully this helps! If you need any additional help, feel free and don't hesitate to comment here or private message me!. Have a nice day/night! :))))

<em>Another Tip:</em>

<em>(Press the shift, control, and option keys at the same time. While you are pressing those keys, also hold the power button along with that.)</em>

<em></em>

<em>(For at least 10 seconds)</em>

6 0
4 years ago
Other questions:
  • True or false? malware problems and other compromises of your computer information are rare.
    15·1 answer
  • Create a short document titled "Guide to web searches" that Sergio can give to users of the facility he supervises. The document
    7·1 answer
  • Under what circumstances would it be appropriate to use the sentence method of note taking, and what are the advantages and disa
    7·2 answers
  • Percy is a lighting technician in a film production. For a shot, the chief lighting technician instructs Percy to get the kind o
    15·1 answer
  • Ted reads a sentence: The man said that it would take 10 to 12 days for a reply. He believes the hyphen symbol can replace the w
    11·1 answer
  • Which option describes the purpose of configuring native supplicant profile on the cisco ise?
    7·1 answer
  • A computer reads a sequence from top to bottom and left to right.
    13·1 answer
  • Read the following scenario, and then decide if you should upgrade the computer. You have a desktop that you use primarily for w
    7·1 answer
  • Which is not and input device , keyboard , joystick, Monitor, Microphone​
    10·2 answers
  • 2
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!