#taken from byteofpython
#!/usr/bin/python
# Filename: method.py
class Person:
def sayHi(self):
print 'Hello, how are you?'
p = Person()
p.sayHi()
# This short example can also be written as Person().sayHi()
#!/usr/bin/python
# Filename: method.py
class Person:
def sayHi(self):
print 'Hello, how are you?'
p = Person()
p.sayHi()
# This short example can also be written as Person().sayHi()
and its output
$ python method.py
Hello, how are you?
-----------------------------------------------------------------------------------------------------------------------------------------
Procedural Programming example sad does the same function as above)
#!/usr/bin/python
#filename:Superior.py
a="Hello,how are you?"
print a
or
#!/usr/bin/python
#filename=Easier.py
def hi():
a="Hello, how old are you?"
print hi()
and its output
Hello, how are you?