fork download
  1. class Test(object):
  2. def __init__( self, teamName, record, winStreak, scoringPercentage,
  3. rebounds,passing,turnovers ):
  4. self.teamName = teamName
  5. self.record = record
  6. self.winStreak = winStreak
  7. self.scoringPercentage = scoringPercentage
  8. self.rebounds = rebounds
  9. self.passing = passing
  10. self.turnovers = turnovers
  11. def __str1__(self):
  12. return """Team name is {name}
  13. Their regular season record was {record}
  14. Their win streak is {streak}
  15. Their scoring percentage is {score}
  16. Their average rebounds are {rebounds}
  17. Their passing is {passing}
  18. Their turnovers are {turnovers}""".format( name=self.teamName,
  19. record=self.record, streak=self.winStreak, score=self.scoringPercentage,
  20. rebounds=self.rebounds,passing=self.passing, turnovers=self.turnovers )
  21.  
  22. def __str2__(self):
  23. return "Team name is {0}\n"\
  24. "Their regular season record was {1}\n"\
  25. "Their win streak is {2}\n"\
  26. "heir scoring percentage is {3}\n"\
  27. "Their average rebounds are {4}\n"\
  28. "Their passing is {5}\n"\
  29. "Their turnovers are {6}".format( self.teamName,
  30. self.record, self.winStreak, self.scoringPercentage,self.rebounds,
  31. self.passing, self.turnovers )
  32.  
  33. def __str3__(self):
  34. return """Team name is {0}
  35. Their regular season record was {1}
  36. Their win streak is {2}
  37. heir scoring percentage is {3}
  38. Their average rebounds are {4}
  39. Their passing is {5}
  40. Their turnovers are {6}""".format( self.teamName,
  41. self.record, self.winStreak, self.scoringPercentage,self.rebounds,
  42. self.passing, self.turnovers )
  43.  
  44. def __str__(self):
  45. return """Team name is %s
  46. Their regular season record was %.2f
  47. Their win streak is %s
  48. Their scoring percentage is %s
  49. Their average rebounds are %s
  50. Their passing is %s
  51. Their turnovers are %s"""%( self.teamName, self.record, self.winStreak,
  52. self.scoringPercentage, self.rebounds,self.passing, self.turnovers )
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. t = Test("John",1,2,3,4,5,6)
  60. print(t.__str1__())
  61.  
  62. print(t.__str2__())
  63.  
  64. print(t.__str3__())
  65.  
  66. print(t)
  67.  
Success #stdin #stdout 0.04s 9496KB
stdin
Standard input is empty
stdout
Team name is John
Their regular season record was 1
Their win streak is 2
Their scoring percentage is 3
Their average rebounds are 4
Their passing is 5
Their turnovers are 6
Team name is John
Their regular season record was 1
Their win streak is 2
heir scoring percentage is 3
Their average rebounds are 4
Their passing is 5
Their turnovers are 6
Team name is John
Their regular season record was 1
Their win streak is 2
heir scoring percentage is 3
Their average rebounds are 4
Their passing is 5
Their turnovers are 6
Team name is John
Their regular season record was 1.00
Their win streak is 2
Their scoring percentage is 3
Their average rebounds are 4
Their passing is 5
Their turnovers are 6