Write a program that inputs names of personal expenses

Assignment Help Python Programming
Reference no: EM132356197

INTRODUCTION

The goal of this programming project is to enable students practice solving a problem that uses the Python features of functions and lists.

PROBLEM

Write a program that inputs names of personal expenses and a corresponding amount for each expense. The program should store all input data in lists. The program should then allow the user to select how the information will be displayed from the list of (a) pie chart (b) bar chart (c) table. The program should achieve this in functions described below. To ensure good programming and modularity, none of the functions should call itself and the only function calls should be in the main function. Functions should not be defined inside other functions. At the bottom, there should be a statement that calls the main function.

Here are the descriptions of what should be in the functions:

1. main

This function will have statements to call the other functions. The first function called will input names of the expenses into a list and assign the list to a list object. The second call will pass the expense items list to a function that inputs expense amounts into a second list that is then assigned to a list object. The third call passes the two lists to a function that will display the contents on the two lists. Here are the Python statements:

expense_items_list = inputExpenseNames()
expense_amounts_list = inputExpenseAmounts(expense_items_list)
displayExpenseReport(expense_items_list, expense_amounts_list)

2. inputExpenseNames

First create an empty list for expense items. Next, enter a loop that iterates for as long as the user responds that there are more item names to enter. In the loop, display a message asking the user to input the name of an expense item, then input the name and append it to the list. Then input a response to the question whether there are more item names. After the loop ends, return the expense items list.

3. inputExpenseAmounts

Create an empty list for expense amounts. Enter a loop that uses the size (you may use the len function) of the expense_items_list to determine number of iterations. For each iteration, display a message that says:

How much was spent on xxxxxxxxxx expense item?

where xxxxxxxxxx is replaced by the name from the expense_items_list corresponding to the current iteration. The amount should then be input and appended to the expense amounts list. Input validation should be done including using try ... except ... to ensure a number was entered.

After the loop ends, return the expense amounts list.

4. displayExpenseReport

Parameters to this function will be the expense items and expense amounts lists. Your program should offer the user the menu of (a) table display (b) pie chart (c) bar chart. When the user selects option (a), the program should output column headings and then enters a loop that iterates as many times as the size of the expense items list and outputs the contents of the lists. The total of the amounts in the expense amounts list should be computed. After exiting the loop, the program should display the totals line of the report. Use the format function and format strings. Here is an example of what the output may look like.

EXPENSE ITEM AMOUNT
------------------- ------------
Rent 450.00
Car loan payment 375.50
Food and groceries 250.00
Electricity 75.00
Water 35.68
TOTALS 1,186.18

When the user selects option (b), the program should output a pie chart of the data in the lists using matplotlib.

When the user selects option (c), the program should output a bar chart of the data in the lists using matplotlib.

PROGRAM STYLE REQUIREMENTS

Your program should start with several comment lines that state your name and the purpose of the program as well as the date the program was written.

There should be a comment just before each function to state the purpose of the function and what parameters it takes as well as what it returns. Furthermore, there should be a comment to the right of each variable declaration (no comment inside parameter list) to briefly state what the variable will store. There should be a comment before every loop and every if statement to state what the loop/if is doing.

Reference no: EM132356197

Questions Cloud

Do you have a standard way to communicate : It does take a team for a smooth transition of care. Do you have a standard way to communicate? How do you assure effective communication between the discipline
Why is operational definition important in a research study : What is the difference between a conceptual definition and an operational definition? Give an example of a conceptual definition and a corresponding operational
Displays the assessed value and the property tax : Prompts the user to enter the actual value of a piece of property. Uses an internal function to calculate the assessed value of the property and property tax.
Discuss professional nursing leadership and management roles : Discuss professional nursing leadership and management roles that have arisen and how they are important in responding to emerging trends and in the promotion.
Write a program that inputs names of personal expenses : Write a program that inputs names of personal expenses and a corresponding amount for each expense. The program should store all input data in lists.
Operational and managerial impacts of the aggregate planning : Compare and contrast the operational and managerial impacts of the aggregate planning decisions in terms of customer satisfaction.
Estimate cost of construction of a house : CPCCCM2001A - Read and interpret plans and specifications - Take the role of a Construction Estimator - estimate the cost of construction of a house
Define how the practice of nursing is expected to grow : It is expected that more and more nursing jobs will become available out in community, and fewer will be available in acute care hospitals. Write an informal.
What are some strategies you can use to help clients : What are some strategies you can use to help clients envision different possibilities? Choose a counseling theory you are considering using and explain.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd