[Tutor] Input parameters for functions

David Rock david at graniteweb.com
Fri Jun 19 19:04:28 EDT 2020


* Mary Knauth via Tutor <tutor at python.org> [2020-06-19 10:44]:
> Hello Everyone,
> 
> I have a script for a school assignment, an ATM transaction script
> based on the purpose of creating functions.  The draft I submitted all
> worked fine, but the feedback from my instructor was that I needed to
> use parameters in my functions.
>
> Questions:
> My original py script worked 100% with no parameters in the functions, so
> what is the advantage of adding the parameters?  I have put in what I think
> should be the parameters in my new py file, all the functions work, but do
> you think I have utilized the parameters correctly?
>
> Many thanks in advance for your insight and thoughts.

Hello, Mary. Welcome!

> My original py script worked 100% with no parameters in the functions, so
> what is the advantage of adding the parameters?  

The advantage of using parameters is it allows you to feed information
to the functions so it can be used with more than one static case.  For
example, your deposit function can be called with different values to
allow the same function to be used for any deposit amount, not just a
hard-coded amount.

> def balance(account_balance)
> def deposit(account_balance, deposit_amount) ———----——is ‘account_balance’ necessary?
> def withdrawal(account_balance, withdrawal_amount) —— is ‘account_balance’ necessary?

If you included your .py file, it probably got stripped.  The email list
does not normally accept any attachments.  Please send the text of the
file inside the body of the email if you want us to look at it.  That
said, account_balance is probably necessary in all cases because both
deposit and withdrawal functions have two pieces of information they
need to be successful: the account balance, and the dollar amount you
wish to add/subtract.

It looks to me like you are on the right track. :-)

-- 
David Rock
david at graniteweb.com


More information about the Tutor mailing list