fork download
  1. class class_test:
  2. car = []
  3. human = []
  4. star = []
  5. universe = {}
  6. titles = ["Is made of", "Moves using", "Fueled by"]
  7. ids = ["car", "human", "star"]
  8.  
  9. def vivify(self):
  10. cardict = {}
  11. humandict = {}
  12. stardict = {}
  13. for x in range(3):
  14. cardict[self.titles[x]] = self.car[x]
  15. humandict[self.titles[x]] = self.human[x]
  16. stardict[self.titles[x]] = self.star[x]
  17.  
  18. self.universe[self.ids[0]] = cardict
  19. self.universe[self.ids[1]] = humandict
  20. self.universe[self.ids[2]] = stardict
  21.  
  22. def inculcate(self, topic):
  23. print "A "+topic+" is made of "+self.universe[topic]["Is made of"]
  24. print "A "+topic+" moves using "+self.universe[topic]["Moves using"]
  25. print "A "+topic+" is fueled by "+self.universe[topic]["Fueled by"]
  26.  
  27. def main():
  28. right = class_test()
  29. right.car = ['metal', 'wheels', 'gas']
  30. right.human = ['flesh', 'legs', 'food']
  31. right.star = ['plasma', 'inertia', 'hydrogen']
  32. right.vivify()
  33.  
  34. print "##RIGHT##"
  35. right.inculcate('car')
  36. right.inculcate('human')
  37. right.inculcate('star')
  38.  
  39. wrong = class_test()
  40. wrong.car = ['textiles', 'cookies', 'pop']
  41. wrong.human = ['onions', 'slither', 'dirt']
  42. wrong.star = ['ice', 'fins', 'time']
  43. wrong.vivify()
  44.  
  45. print "##WRONG##"
  46. wrong.inculcate('car')
  47. wrong.inculcate('human')
  48. wrong.inculcate('star')
  49.  
  50. if __name__ == "__main__":
  51. main()
Success #stdin #stdout 0.01s 7736KB
stdin
Standard input is empty
stdout
##RIGHT##
A car is made of metal
A car moves using wheels
A car is fueled by gas
A human is made of flesh
A human moves using legs
A human is fueled by food
A star is made of plasma
A star moves using inertia
A star is fueled by hydrogen
##WRONG##
A car is made of textiles
A car moves using cookies
A car is fueled by pop
A human is made of onions
A human moves using slither
A human is fueled by dirt
A star is made of ice
A star moves using fins
A star is fueled by time