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

Picture of 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()

Comments

About This Instructable

562views

7favorites

License:

Bio: Occupation: Tech Support
More by matt392:Box for Raspberry Pi Model B and Power Supply Made From Wood ShimsQ-Tip Paint PenReplace Letters on Computer Keyboard (or Make Bigger Letters) With Nail Polish
Add instructable to: