Skip to content

Instantly share code, notes, and snippets.

@chhantyal
Last active May 23, 2021 15:32
Show Gist options
  • Save chhantyal/e02c9af0a6d0f4302f8a219374aa6626 to your computer and use it in GitHub Desktop.
Save chhantyal/e02c9af0a6d0f4302f8a219374aa6626 to your computer and use it in GitHub Desktop.
Baby abbouncement
#!/usr/bin/env python
from dataclasses import dataclass
@dataclass
class Baby:
name: str
birthday: str
mother: str = "Mother's name"
father: str = "Father's name"
family_name: str = "Family name"
@staticmethod
def greeting():
print("Hello World!")
def get_fullname(self):
return f"{self.name} {self.family_name}"
def introduce(self):
print(f"My name is {self.get_fullname()}. I was born on {self.birthday}.")
if __name__ == "__main__":
newborn = Baby(
name="Baby's name",
birthday="01.01.2020"
)
newborn.greeting()
newborn.introduce()
# Hello World!
# My name is [full name]. I was born on 01.01.2020.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment