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
Why is brainly so addictinggggggggg!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Lady_Fox [76]

Answer:

ok but give me brainliest also plz

Explanation:

5 0
3 years ago
Database queries is an example of
storchak [24]

Answer:

A query in a database is a request for information stored within a database management system (DBMS), which is the software program that maintains data.

SQL(Structured Query Language ( is a standard language for storing, manipulating, and retrieving data in database.

Five types of SQL queries are:

1) Data Definition Language (DDL).

used to define and modify the structure of a database.

2) Data Manipulation Language (DML).

used to manipulate (change) the data in the database.

3) Data Control Language(DCL).

used for access control and permission management for users in the database.

4) Transaction Control Language(TCL).

used for maintaining consistency of the database and for the management of transactions made by the DML commands.

5) Data Query Language (DQL).

used for performing queries on the data within schema objects.

8 0
2 years ago
What is the main disadvantage of parallel circuits?
ANTONII [103]

Answer:

If one bulb goes out, the other bulbs will go out.

They are complicated to design and build.

7 0
3 years ago
Write a program to move the Turtle based on the user’s request. Display a menu with options for the user to choose. Use the foll
Strike441 [17]

Answer:

#import turtle

import turtle

 

# set screen

Screen = turtle.Turtle()

 

# decide colors

cir= ['red','green','blue','yellow','purple']

 

# decide pensize

turtle.pensize(4)

 

# Draw star pattern

turtle.penup()

turtle.setpos(-90,30)

turtle.pendown()

for i in range(5):

   turtle.pencolor(cir[i])

   turtle.forward(200)

   turtle.right(144)

 

turtle.penup()

turtle.setpos(80,-140)

turtle.pendown()

 

# choose pen color

turtle.pencolor("Black")

# importing turtle module

import turtle

 

# number of sides

n = 10

 

# creating instance of turtle

pen = turtle.Turtle()

 

# loop to draw a side

for i in range(n):

   # drawing side of  

   # length i*10

   pen.forward(i * 10)

 

   # changing direction of pen  

   # by 144 degree in clockwise

   pen.right(144)

 

# closing the instance

turtle.done()

turtle.done()

Explanation:

7 0
2 years ago
Identify the correct shell sort algorithm for the given interleaved sorting. InsertionSortInterleaved(numbers, numbersSize, star
Sergio039 [100]
Sinturda Okayama 314 magnolia
8 0
3 years ago
Other questions:
  • Pointers with classes a) A user-defined class named Timer has a constructor that takes two integer parameters to initialize hour
    14·1 answer
  • The purpose of the img element's ________ attribute is to provide a method for a browser to display different images depending o
    7·1 answer
  • Suppose that TCP's current estimated values for the round trip time (estimatedRTT) and deviation in the RTT (DevRTT) are 400 mse
    9·1 answer
  • All web traffic is based on the ____________________ protocol.
    14·1 answer
  • An example of movement as a gameplay mechanic includes
    14·2 answers
  • In Microsoft Excel, which formula will yield a value of 10? 5x2 5x2*.5+5 =5*1.5 =(100/5*2)*.25
    13·2 answers
  • Plz answer me will mark as brainliest​
    13·1 answer
  • Write down the stages in the information prcessing cycle in correct order​
    5·1 answer
  • If an engineer wants to verify changes that she has been making on a router, which commands will allow her to check the routers
    15·1 answer
  • Who first demonstrated the computer mouse ?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!