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]
4 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]4 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
A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output i
Oksi-84 [34.3K]

Answer:

Follows are the code to the given question:

def steps_to_miles(user_steps):#defining a method steps_to_miles that takes a variable user_steps

   return user_steps/2000#use return to calculate the steps

user_steps = int(input())#defining a variable user_steps that holds value from the user-end

print('%0.2f' % steps_to_miles(user_steps))#defining print that calls the steps_to_miles method

Output:

5345

2.67

Explanation:

In this code a method "steps_to_miles" that takes "user_steps" in the parameter inside the method a return keyword is used that calculates the user steps and return its values.

Outside the method, a "user_steps" variable is declared that inputs the value from the user-end pass into the method and prints its value.

3 0
3 years ago
// Marian Basting takes in small sewing jobs.
Len [333]

Answer:

start

  Declarations

     num weddingMonth

     num weddingDay

     string weddingClientName

     num weddingPhoneNum

     string weddingDescription

     num weddingPrice

    num replaceMonth

     num replaceDay

     string replaceClientName

     num replacePhoneNum

     string replaceDescription

     num replacePrice

     num weddingDate

     num replaceDate

     num bothAtEnd=0

    num END_YEAR=9999

     InputFile weddingFile

     InputFile replaceFile

    ouputFile mergedFile

getReady()

while bothAtEnd<>1

mergeRecords()

  endwhile

  finishUp()

stop

getReady()

  open weddingFile "weddingDress.dat"

  open replaceFile "replaceJacketZipper.dat"

  open mergedFile “Merged.dat”

   readWedding()

  readreplace()

  checkEnd()

return

readWedding( )

     input weddingMonth,weddingDay,weddingClientName,weddingPhoneNum,weddingDescription,weddingPricee from weddingFile

while eof

 weddingDate=END_YEAR

endwhile

return

readreplace( )

     input replaceMonth,replaceDay,replaceClientName,replacePhoneNum,replaceDescription,replacePricee from replaceFile

while eof

 replaceDate=END_YEAR

endwhile

return

checkEnd()

if weddingDate=END_YEAR

if replaceDate=END_YEAR

bothAtEnd=1

endif

endif

return

mergedFile()

if weddingDate<replaceDate

         output weddingMonth,weddingDay,weddingClientName,weddingPhoneNum,weddingDescription,weddingPricee to weddingFile

readWedding()

endif

      output replaceMonth,replaceDay,replaceClientName,replacePhoneNum,replaceDescription,replacePricee to replaceFile

readreplace()

return

finishUp()

close weddingFile

close replaceFile

close mergedFile

return

6 0
3 years ago
Simple mail transfer protocol (smtp) uses the well-known port number ______________ by default.
Elden [556K]
I believe it's default is port 587. 
8 0
4 years ago
Read 2 more answers
The person who suggested that the continents were once a supercontinent, called Pangaea, but slowly drifted apart was who
kherson [118]
Alfred Wegener was the one who came up with the Pangea.
3 0
3 years ago
Read 2 more answers
Which of the following is a set of short-range wireless technologies used to share information among devices within about two in
8_murik_8 [283]

Answer:

Option (c) NFC

Explanation:

  • The NFC Technology is a Wireless Technology which works in the range of 10 cm or less.
  • NFC stands for Near Field Communications.
  • The name itself indicates that it a communication mode with the near by objects.
  • The NFC technology is used in Access Cards, Payment Cards and Mobile Devices etc.
  • Option (a) IM - Instant Messaging is the instant text messaging technology sends and receives messages over the internet. It is used in Social Media where instant messaging is available. So, option (a) is not correct option.
  • Option (b) text messaging the technology is the technology in which the text messages are sent over the mobile networks ( in case of text messaging in mobile phones ) or over the internet ( emails, blogging etc). So, option (b) is not correct option.
  • Option (d) DES is not a short range wireless technology. So, option (d) is not correct.
  • Option (c) NFC is correct option.
3 0
3 years ago
Other questions:
  • X=10 ;
    14·1 answer
  • Write a function "nonRepeatings" that takes a string "s3" and returns the non-repeating characters in this string. Sample Input
    11·1 answer
  • Which is an example of a local government enforcing a national law?
    5·2 answers
  • Here is free points im leaving
    11·2 answers
  • What is a common use for spreadsheets? A.drawing B.writing C.budgeting D.video production
    8·1 answer
  • O O O O O O O
    9·1 answer
  • Google Slides is most similar to which of the following programs?
    10·2 answers
  • In the program below, numA is a _____.
    8·2 answers
  • Which option correctly identifies if the researcher’s approach was the best start in the following scenario and explains why?
    10·2 answers
  • Which document outlines the activities carried out during testing?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!