Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
loan
#8
(Apr-03-2019, 07:30 AM)mcgrim Wrote: Those variables are declared in line 2,3,4.

I did not give any indication on where my beliefs stand. I am only asking explanations to what is written.

There were no (global) variables (balance, r, n, or A) in your initial code. They were assigned within function and therefore existed only within function. You can't access these names from outside of this function (unless using some techniques which are frowned upon). By stating that you declared them indicates that you believe it to be true as reality is somewhat different.

Usually functions are written using parameters and called using arguments. Generally it's done this way:

>>> def f(balance,r,A):                  # defining function with parameters
...    return (balance)*(r/100.0 +1) - A
...
>>> f(10000, 13.0, 1000.0)               # calling function with arguments
10299.999999999998
Some observations:

- you defined n as parameter but never used it. While calling this function you should provide n otherwise function call will raise TypeError about missing required positional argument (in version above this parameter is skipped)

- for clarity it's good use keyword arguments. What is r? What is A?

- I have no idea what function return represents

You can read documentation about arguments and parameters
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
loan - by mcgrim - Apr-02-2019, 08:56 PM
RE: loan - by Yoriz - Apr-02-2019, 10:05 PM
RE: loan - by ichabod801 - Apr-02-2019, 10:05 PM
RE: loan - by micseydel - Apr-02-2019, 10:07 PM
RE: loan - by mcgrim - Apr-03-2019, 06:56 AM
RE: loan - by perfringo - Apr-03-2019, 07:27 AM
RE: loan - by mcgrim - Apr-03-2019, 07:30 AM
RE: loan - by perfringo - Apr-03-2019, 08:00 AM
RE: loan - by mcgrim - Apr-03-2019, 08:07 AM
RE: loan - by perfringo - Apr-03-2019, 08:23 AM
RE: loan - by mcgrim - Apr-03-2019, 08:33 AM
RE: loan - by perfringo - Apr-03-2019, 08:56 AM
RE: loan - by mcgrim - Apr-03-2019, 04:12 PM
RE: loan - by Yoriz - Apr-03-2019, 05:18 PM
RE: loan - by ichabod801 - Apr-03-2019, 05:54 PM
RE: loan - by mcgrim - Apr-03-2019, 06:22 PM
RE: loan - by ichabod801 - Apr-03-2019, 07:13 PM
RE: loan - by mcgrim - Apr-03-2019, 07:44 PM
RE: loan - by ichabod801 - Apr-03-2019, 07:55 PM
RE: loan - by mcgrim - Apr-03-2019, 08:06 PM
RE: loan - by Yoriz - Apr-03-2019, 08:24 PM
RE: loan - by mcgrim - Apr-03-2019, 08:30 PM
RE: loan - by Yoriz - Apr-03-2019, 08:35 PM
RE: loan - by mcgrim - Apr-03-2019, 08:44 PM
RE: loan - by Yoriz - Apr-03-2019, 08:52 PM
RE: loan - by mcgrim - Apr-04-2019, 07:08 PM
RE: loan - by ichabod801 - Apr-04-2019, 07:22 PM
RE: loan - by mcgrim - Apr-06-2019, 02:12 PM
RE: loan - by ichabod801 - Apr-06-2019, 02:37 PM
RE: loan - by Yoriz - Apr-06-2019, 02:41 PM
RE: loan - by mcgrim - Apr-07-2019, 10:35 AM
RE: loan - by mcgrim - Apr-07-2019, 11:40 AM
RE: loan - by Yoriz - Apr-07-2019, 11:55 AM
RE: loan - by mcgrim - Apr-07-2019, 12:00 PM
RE: loan - by Yoriz - Apr-07-2019, 12:08 PM
RE: loan - by mcgrim - Apr-07-2019, 12:13 PM
RE: loan - by ichabod801 - Apr-07-2019, 12:58 PM
RE: loan - by micseydel - Apr-07-2019, 02:10 PM
RE: loan - by ichabod801 - Apr-07-2019, 07:27 PM
RE: loan - by mcgrim - Apr-08-2019, 11:23 AM
RE: loan - by mcgrim - Apr-08-2019, 08:05 PM
RE: loan - by ichabod801 - Apr-08-2019, 08:42 PM
RE: loan - by mcgrim - Apr-08-2019, 08:48 PM
RE: loan - by ichabod801 - Apr-08-2019, 08:52 PM
RE: loan - by mcgrim - Apr-08-2019, 08:55 PM
RE: loan - by ichabod801 - Apr-08-2019, 09:10 PM
RE: loan - by mcgrim - Apr-09-2019, 07:30 AM
iterations - by mcgrim - Apr-04-2019, 08:15 PM
RE: iterations - by nilamo - Apr-04-2019, 08:20 PM
RE: iterations - by mcgrim - Apr-04-2019, 08:23 PM
RE: iterations - by nilamo - Apr-04-2019, 08:30 PM
RE: iterations - by ichabod801 - Apr-04-2019, 09:42 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020