Skip to content

Instantly share code, notes, and snippets.

@JonyBepary
Last active December 31, 2019 19:04
Show Gist options
  • Select an option

  • Save JonyBepary/6de15f74c6e889eabe19682339492c17 to your computer and use it in GitHub Desktop.

Select an option

Save JonyBepary/6de15f74c6e889eabe19682339492c17 to your computer and use it in GitHub Desktop.
New Year Greeting (OOP).
# Author: Jony Bepary
# Python Object-Oriented Programming
# A function/data associate with class
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# in class :
# method = function
# data/variable = Attribute
# builtin library
import datetime
# A Class
class Greet(object):
"""docstring for Greet For New Year"""
# Init/magic/super function / Constructor
def __init__(self, year, month, day):
# Instance attributes / Variable
self.year = year
self.month = month
self.day = day
# Class fucntion / method
def greet_msg(self):
if self.day and self.day:
print("Happy New Year //~~~> {0}".format(self.year))
# Class object assignment
t = datetime.datetime.now()
kal = Greet(t.year, t.month, t.day)
if __name__ == '__main__':
kal.greet_msg()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment