Skip to content

Instantly share code, notes, and snippets.

@letuananh
Created March 25, 2015 03:56
Show Gist options
  • Save letuananh/3845288a361064d4a437 to your computer and use it in GitHub Desktop.
Save letuananh/3845288a361064d4a437 to your computer and use it in GitHub Desktop.
Demo code - Adopted from http://pastebin.com/duV5fwGh
import sys
class Player:
def __init__(self, name, age):
self.lives = 10
self.name = name
self.age = age
def eat(self, food):
if food == "apple":
self.health -= 10
elif food == "banana":
self.health += 10
def introduce(self):
print("I'm %s and I'm %s year(s) old." % (self.name, self.age))
#-----------------------------------------
name = raw_input("What is your name? ")
age = raw_input("How old are you? ")
player1 = Player(name, age)
player1.introduce()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment