SHARE
TWEET

SUPyF2 Objects/Classes-Lab - 01. Comment

SimeonTs Oct 18th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. Objects and Classes - Lab
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1733#0
  4.  
  5. SUPyF2 Objects/Classes-Lab - 01. Comment
  6.  
  7. Problem:
  8. Create a class with name "Comment". The __init__ method should accept 3 parameters
  9. • username
  10. • content
  11. • likes (optional, 0 by default)
  12. Use the exact names for your variables
  13. Note: there is no input/output for this problem. Test the class yourself and submit only the class
  14.  
  15. Example:
  16. Test Code                                           Output
  17. comment = Comment("user1", "I like this book")      user1
  18. print(comment.username)                             I like this book
  19. print(comment.content)                              0
  20. print(comment.likes)
  21. """
  22.  
  23.  
  24. class Comment:
  25.     def __init__(self, username, content, likes=0):
  26.         self.username = username
  27.         self.content = content
  28.         self.likes = likes
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top