[Tutor] how to define a function with multple parameters
David
david at pythontoo.com
Wed Sep 23 03:01:48 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 = rate_score
>
>
> if rate_score <= 999:
> print "that's nothing."
> elif rate_score <= 10000:
> print "ok."
> elif rate_score >= 10000:
> 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>
>
Here is something that you can try;
#!/usr/bin/python
def display(message):
print message
def rate_score(selection):
if selection <= 99:
print 'Thats nothing !'
else:
print 'Thats something !'
def main():
display('Get the meaning !')
while True:
try:
selection = int(raw_input('Please enter your score: '))
break
except ValueError:
print 'Oops! Did you forget to enter a number !'
print 'You entered %s as your score' % selection
rate_score(selection)
main()
--
Powered by Gentoo GNU/Linux
http://linuxcrazy.com
More information about the Tutor
mailing list