[Tutor] how to define a function with multple parameters
Dave Angel
davea at ieee.org
Wed Sep 23 01:36:45 CEST 2009
shellcom3 at juno.com wrote:
> I want to know how to use multiple parameters for 1 function
>
>
> def display(message):
> print message
>
> def rate_score():
> score =ate_score
>
>
> if rate_score <=99:
> print "that's nothing."
> elif rate_score <=0000:
> print "ok."
> elif rate_score >=0000:
> print "great."
>
>
> #main
>
> display("Get the meaning !")
>
> raw_input("Please type in your score")
> print "here's your score", rate_score
> rate_score()
> This is the outcome:
>
> great.
> Get the meaning
> Please type in your score50
> here's your score <function rate_score at 0x025610F0>
>
>
>
I have no idea what the subject line is supposed to mean, but that
program is in sad shape. It won't compile and run as it stands, so I
suspect you didn't transcribe it correctly. Please use cut and paste to
show us what you really have, and what it really produces. Then maybe
we can comment on improvements.
Also, please delineate which parts of the message are from a python
script, and which parts are the echoes from an interactive run. And if
you're running from a command line, show the command used to launch the
script, all the way through to the end.
One thing that probably isn't a transcribing error is your total
confusion between a variable called rate_score and a function by the
same name. A given name can only have one meaning in one scope, so plan
carefully. And even if you can reassign a function name inside that
function to have a new value, it's almost never a good idea. For one
thing, it makes it hard to call the function a second time.
DaveA
More information about the Tutor
mailing list