Home > Projects/Experiments, Python > Python : Expenditure App

Python : Expenditure App




Expenditure Application

User input ‘choice’:

In today post we will add the user input to our menu and based on the user input the app some function will run. As we said in the previous post The Menu we will use (9) to Exit from the application.

To read the user input we will use ‘input(‘something’)’ statement and The Menu def will return the choice back so our if statement will take us to another function, or EXIT if choice = 9, so let’s start.

As we can see in the last two lines of the_menu def, we have

choice = input(‘What you want to do? ‘) and return choice

Then in the main application body we will have while statement holding if statement as here:

choice = the_menu() # Here we are calling the menu and putting the return in the choice.
while choice != ‘9’ :

if choice == ‘1’:

# Calling “Add New Entry” function

choice = the_menu()

if choice == ‘2’:

# Calling “Delete an Entry” function

choice = the_menu()

if choice == ‘3’:

# Calling “Change an Entry” function

choice = the_menu()

if choice == ‘4’:

# Calling “Show Total Expenditure in a Year.” function

choice = the_menu()

if choice == ‘5’:

# Calling “Show Expenditure Details in a year.” function

choice = the_menu()

if choice == ‘9’:

choice = the_menu()

brack


Your code should be something like what we have in the image.

Advertisements
  1. No comments yet.
  1. December 2, 2018 at 11:00 am
  2. December 4, 2018 at 10:52 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s