Demonstrates parameters and return values : Return « Function « Python

Home
Python
1.2D
2.Application
3.Buildin Function
4.Class
5.Data Structure
6.Data Type
7.Database
8.Development
9.Dictionary
10.Event
11.Exception
12.File
13.Function
14.GUI Pmw
15.GUI Tk
16.Language Basics
17.List
18.Math
19.Network
20.String
21.System
22.Thread
23.Tuple
24.Utility
25.XML
Python » Function » ReturnScreenshots 
Demonstrates parameters and return values
Demonstrates parameters and return values
 


def display(message):
    print message

def give_me_five():
    five = 5
    return five

def ask_yes_no(question):
    """Ask a yes or no question."""
    response = None
    while response not in ("y""n"):
        response = raw_input(question).lower()
    return response

# main
display("Here's a message for you.\n")

number = give_me_five()
print "Here's what I got from give_me_five():", number

answer = ask_yes_no("\nPlease enter 'y' or 'n': ")
print "Thanks for entering:", answer

raw_input("\n\nPress the enter key to exit.")


           
         
  
Related examples in the same category
1.Assign value returned from function to a variable
2.Returning Multiple Values from Functions
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.