Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code
- -----------
- def say_hello(input_func):
- name = input_func()
- return "Hello " + name
- def prompt_for_name():
- return raw_input("What is your name? ")
- print say_hello(prompt_for_name)
- Testing
- -----------
- def test_say_hello():
- output = say_hello(lambda: "Random Name")
- assert(output == "Hello Random Name")
- OR
- Code
- -----------
- def say_hello():
- if __name__ == '__main__':
- name = raw_input("What is your name? ")
- else:
- name = 'Random Name'
- return "Hello" + name
- Testing
- -----------
- def test_say_hello():
- output = say_hello()
- assert(output == "Hello Random Name")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement