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
When using a graphics editing program, which option allows you to adjust the space around an image?
Natalija [7]
Adobe photoshop? CS6? I dont know if this is a test question or a standard question but yeah i would assume CS6 but im not sure if im right so dont rely on me lol
3 0
3 years ago
The rectangular marquee tool can select an area to be used as a pattern?<br> True<br> False
Alex17521 [72]
The correct answer is true
8 0
4 years ago
The technological advancements allowing for
antiseptic1488 [7]

Answer:

Better life

Explanation:

Technologies like Smartphone technologies, AI, ML, Lithium Ion Batteries, Quantum batteries, Smart Watches, Various Web 3.0, Block chain, Crypto currencies, VR, AR etc are making the life easier. ioTs, VPNs and various other advanced networks are making our life much simpler as well.

So much of technology is evolving,  and the humanity is certainly up with the best prospects. However, Climate change can be a problem within next few years, if not checked. By 2034, the earth's temperature will rise by 2%. And this will result in heavy flooding, drought, and a lot of coastal cities might be drowned completing. Hence, we need to take the precautions, as well as we need to learn tech to develop floating island like Lake Titicaca in Peru where they use the reeds to make floating islands, and you can also take advantages of the similar by different architectural technology from Amsterdam, where they make floating houses.

We need to act on Climate change now, and rest is fine definitely.

3 0
4 years ago
Write a filter that reads in a sequence of integers and prints the integers, removing repeated values that appear consecutively.
lara31 [8.8K]

Answer:

Following is the code for filter:

public class filter

{ public static void main(String[] args)

{ int x = StdIn.readInt();

System.out.print(" " + x + " ");

while(!StdIn.isEmpty())

{ int y = StdIn.readInt();

    if(y != x)

          System.out.print(" " + y + " ");

    x = y;

    }

    }

    }

Explanation:

  • A public class filter is used.
  • The main function will accept a single argument as string[], it is also known as java command line argument.
  • Now the Stdln.readInt is used to read the integers in the sequence and store it in integer x.
  • The value stored in variable x will be printed using System.out.print
  • Now unless the Stdln.readInt gets an empty value, check each value of sequence and store in variable y.
  • If y is not equal to previous value x, print it and shift the value of y into x.
  • Repeat the loop again.

i hope it will help you!

7 0
4 years ago
Read 2 more answers
Write two statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a slash, and
Montano1993 [528]

Answer:

1/2000

Explanation:

import java.util.Scanner;

public class InputExample {

public static void main(String [] args) {

Scanner scnr = new Scanner(System.in);

System.out.print("Enter birth month and date:");//comment this line if not needed

int birthMonth=scnr.nextInt();

int birthYear=scnr.nextInt();

String output= birthMonth+"/"+birthYear+"\n";

System.out.println(output);

}

}

if using this code the out put should be 1/2000

5 0
3 years ago
Other questions:
  • Can you give me a long list of old kid's cartoons
    8·1 answer
  • The keyboard, mouse, trackpad, microphone, light pen, and voice recognition are examples of _____ devices.
    5·1 answer
  • A customer states that when she removes the printed pages from her laser printer output tray, the black ink smears all over her
    14·1 answer
  • Answer the following questions which are based on the study "Patients' Engagement with Sweet Talk." Submit your answers to the e
    9·1 answer
  • Which is an example of an active visual interface? a display indicating the amount of ammunition for the currently equipped weap
    13·2 answers
  • ____________________ software is a type of security software designed to identify and neutralize web bugs, ad-serving cookies, a
    8·1 answer
  • Which of the choices Sean are not true when considering virus behavior
    9·1 answer
  • Which computer are used by mobile employees such as meter readers.​
    6·2 answers
  • Which of the following terms means the computer operating system automatically detects and installs the proper driver for a new
    9·1 answer
  • Where is the option to set Conditional Formatting rules found?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!