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
1. The Percentage of T9 and T10 also have the wrong number format. Change them to the Correct number format(to match the rest of
pentagon [3]

Answer:

60%

Explanation:

After changing the number format of the percentages of T9 and T10, the value that now shows in T10 due to the change from the wrong format to the Right format is 60%

This is because when a value is entered into a column in a wrong format the value would be different from other values entered rightly but when the format is changed to the right format, the correct value would show up.

5 0
3 years ago
Click/press _______ to remove the most recently typed text.
bagirrra123 [75]

Answer:

ctrl Z

Explanation:

ctrl Z is the shortcut for undo it will reverse the last thing you did ctrl Y is redo if i accidently did ctrl Z i can do ctrl Y. Hope this helps!

6 0
3 years ago
In order to protect your computer from the newest virus, which of the following should you do after you've installed a virus sca
grigory [225]
After the viruses would be detected we have to clean them.
means we have to erase the virus . 
6 0
3 years ago
Which of the following is an image that enhances comunaction? Illustration, logo, maps, or visual cue
melamori03 [73]

The answer is A.  Illustration

6 0
3 years ago
Critical Thinking Questions
Hoochie [10]

Answer:

One example of syntax in Logo is “[”. Two examples of Java are “;” and “{“or “}”. If you don’t use these parts of syntax then you could get a Syntax error, this will make you have to stop the code and debug.

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • When pasting an object which has been copied from a different slide, where on the slide does the object paste, assuming nothing
    15·1 answer
  • A technician wants to create a new partition on a new additional hard drive. what tool should be used?
    15·1 answer
  • To edit the text in a smartart graphic, what must be done first ?
    7·2 answers
  • The conflict between the user's goal for unfettered access to data and the security administrator's goal to protect that data is
    5·2 answers
  • West Point Bridge Designer | Does anyone know a way to make this bridge cost less?
    6·1 answer
  • Which kind of photography takes attractive photos of products to make them stand out?
    12·1 answer
  • Discuss what repetitions structures are, and how they differ from the vectorization approaches we have previously studied in the
    10·1 answer
  • What is ABC computer?​
    14·1 answer
  • What type of software is an antivirus?
    5·2 answers
  • Every windows service has the 3 start types what are those service types?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!