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
HELP PLS
Umnica [9.8K]
Smart phones and wireless devices
6 0
2 years ago
Read 2 more answers
When you see ##### in a cell, you should A. increase the cell width. B. increase the cell height. C. decrease the cell width. D.
Usimov [2.4K]
A. Increase the cell width this is because there is not enough room in the cell to display the number that was given. 
4 0
3 years ago
Quiz
UkoKoshka [18]

Answer:

The correct choice is "Inappropriate content can be accessed accidentally".

Explanation:

It is also known as insufficient material, which includes the information or photographs which distress the child, adult material, incomplete data, or feedback, which can lead to illegal or dangerous actions of the child. On the internet, it enables the computer, which may have improper content access, and the wrong choice can be defined as follows:

  • It does not appears on the website.
  • The people will not be inclined for looking in the inadequate material.  
  • There are no few resources available to prevent inappropriate conductors.
3 0
3 years ago
Read 2 more answers
Help me or I'll go insane I've 6x already I'm about to lose it!!!!
Lemur [1.5K]
Two:
<span>Hiding the complexities of hardware from the user.
Managing between the hardware's resources which include the processors, memory, data storage and I/O devices.
Handling "interrupts" generated by the I/O controllers.
<span>Sharing of I/O between many programs using the CPU.

Three:
</span></span><span>Desktops
icons
menus
windows.</span><span>

Seven:
</span><span>The convention is that ellipses following a menu item usually means that the menu item will open a dialog box with further choices, rather than immediately carrying out an action.
</span>
Eight:
Organize Your Files

Nine:
Use the save as Command
name the File

Ten:
Open the file you want to delete
Select the file you want to delete
select Delete from the file menu
Confirm the deletion

Hope this helps
5 0
3 years ago
Read 2 more answers
Converting raw data into a more meaningful form is called:
White raven [17]
Converting raw data into a more meaningful form is called: processing
8 0
3 years ago
Other questions:
  • major m,ajorrr points helpppppppppppppppppppppppppppi have a question i hit a few buttons and now my computer is saying everythi
    11·2 answers
  • What is process equipment?
    12·1 answer
  • How can a wiki contribute to an academic paper?
    9·2 answers
  • If you have a windows 8, but want the features of windows 8 pro, purchase and install _______.
    7·1 answer
  • A proprietary operating system designed for mobile devices, with associated libraries, user interface, frameworks and reference
    9·1 answer
  • CAD workstations
    11·1 answer
  • It is necessary tto save updates often when working in google docs? True or false
    11·2 answers
  • I like the impact that the increasing number of social grants may have on the things mothers​
    14·1 answer
  • If you do a Find and Replace for a term, where will Word begin looking for the term?
    6·1 answer
  • This seems like a good time to ask the basic question, “How’s it going in class?” Feel free to offer constructive feedback about
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!