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
if a person walks 10 metres due to south in 10 seconds 10 due east in the next 10 seconds and transmitted you're not in the next
Scorpion4ik [409]

Answer:

\frac{1}{3}\ m/s

Explanation:

The computation of the velocity by using the following formula is

As we know that

Velocity = \frac{Displacement}{Total\ time\ taken}

where,

Displacement is 10 meters

Total time taken is 30 seconds

Now placing these values to the above formula

So, the velocity of Dash is

= \frac{10\ meters}{30\ seconds}

= \frac{1}{3}\ m/s

We simply applied the above formula so that we can get the velocity and the same is to be considered

5 0
3 years ago
6. How can you encrypt an entire drive, including files and folders belonging to other users? a. EFS b. User Account Control c.
matrenka [14]

Answer:

A.

Explanation:

Encrypting File System (EFS) is a file system which enables you to encrypt files, thus making them unviewable by any account but your own.

6 0
3 years ago
Saturn has an orbital period of 29.46 years
Alona [7]

This is true. I'm not sure what you're asking here, but if it's a true/false statement, it's true.

3 0
3 years ago
Read 2 more answers
Why do people take off the keys on the school computers
beks73 [17]

Answer:

is this supposed to be a joke-

Explanation:

cuz i dont get it

8 0
2 years ago
#Write a function called "scramble" that accepts a string #as an argument and returns a new string. The new string #should start
mojhsa [17]

Answer:

def scramble(s):

   if len(s) % 2 == 1:

       index = int(len(s)//2)

   else:

       index = int(len(s)/2)

   

   return s[index:] + s[:index]

Explanation:

Create a function called scramble that takes one parameter, s

Check the length of the s using len function. If the length is odd, set the index as the floor of the length/2. Otherwise, set the index as length/2. Use index value to slice the s as two halves

Return the second half of the s and the second half of the s using slice notation (s[index:] represents the characters from half of the s to the end, s[:index] represents the characters from begining to the half of the s)

8 0
3 years ago
Other questions:
  • 4.2.3: Basic while loop expression. Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Fol
    6·2 answers
  • Recording relative positions should reduce total programming time true or false
    7·1 answer
  • Which of the following is the best example of a manager with a delegator leadership style
    10·2 answers
  • Date criteria are automatically enclosed in ____ when entered in a query design.
    11·1 answer
  • Business customers pay $0.006 per gallon for the first 8000 gallons. If the usage is more than 8000 gallons, the rate will be $0
    11·1 answer
  • The ______ is the information center that drivers need to refer to when they're NOT scanning the road.
    14·1 answer
  • What is motivation and state the two forms​
    14·1 answer
  • Rewritable (write, erase, write again) is known as _______.
    7·1 answer
  • Name the major types of computer systems from slowest to fastest. ​
    9·1 answer
  • Jennifer turns on her laptop and hears a series of beeps. What do they probably indicate?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!