Python Programming - Simple One Using a Class and Method

569

7

Posted

Introduction: Python Programming - Simple One Using a Class and Method

# Basic program that creates a class and a method

# create a class called "Person"
class Person:
# Create method "hello"
# Note: must use 'self' in parameter list
def hello(self):
  print "Hello world!"
 
# create object "bob" of class "Person"
bob = Person()

# call method "hello" on object "bob"
bob.hello()

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • First Time Author Contest 2018

    First Time Author Contest 2018
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

Comments