Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Methods
#8
this one
# a method to determine if the book is long (500 or more pages)
def is_long(self):
  if self.pages > 500:
      return True
  return False
is more or less correct, i.e. it could be done better, e.g.
# a method to determine if the book is long (500 or more pages)
def is_long(self):
  return self.pages >= 500
as to this one:
# a method to mark the book as completed
def mark_completed(self):
  if self.status == "c"
      self.title += "Mark as completed"
  elif self.status == "r"
      self.title += "Book is not completed"
I think you need to change status property and not change the book title.
Reply


Messages In This Thread
Methods - by infernoblaze - Jan-19-2017, 06:20 AM
RE: Methods - by j.crater - Jan-19-2017, 07:36 AM
RE: Methods - by infernoblaze - Jan-19-2017, 07:37 AM
RE: Methods - by j.crater - Jan-19-2017, 07:44 AM
RE: Methods - by infernoblaze - Jan-19-2017, 08:15 AM
RE: Methods - by wavic - Jan-19-2017, 07:53 AM
RE: Methods - by buran - Jan-19-2017, 08:07 AM
RE: Methods - by buran - Jan-19-2017, 08:25 AM
RE: Methods - by infernoblaze - Jan-19-2017, 10:05 AM
RE: Methods - by buran - Jan-19-2017, 12:44 PM
RE: Methods - by infernoblaze - Jan-19-2017, 03:04 PM
RE: Methods - by j.crater - Jan-19-2017, 03:08 PM
RE: Methods - by infernoblaze - Jan-19-2017, 03:10 PM
RE: Methods - by buran - Jan-19-2017, 03:36 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020