Python Programming - Simple One Using a Class and Method

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

About: Occupation: Tech Support

# 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()

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    Discussions