Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Methods
#1
Does anyone here knows how to do methods inside a class? 
I need help to find:

1)  a method to mark a book as completed

2 )a method to determine if the book is long (500 or more pages)

Like how do i write it?

Help is appreciated!

Update: i have wrote down the class. I just need that two method, but how do i write it?
class Book:
    def __init__(self, title="", author="", pages=0, status=""):
        self.title = title
        self.author = author
        self.pages = pages
        self.status = status

    def __str__(self):
       return "{} by {}, total pages is {}.".format(self.title, self.author, self.pages)
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