Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
simply! solution in Creative category for Every Person is Unique by tamagoyaki
class Person:
def __init__(self,*para):
self.para = list(para)+["unknown"]
def name(self):
return self.para[0] + " " + self.para[1]
def age(self):
return 2018 - int(self.para[2][-4:]) -1
def work(self):
return {"male":"He is","female":"She is","unknown":"Is"}[self.para[8]]+" a "+self.para[3]
def money(self):
return f"{self.para[5]*self.para[4]*12:,}".replace(","," ")
def home(self):
return f"Lives in {self.para[7]}, {self.para[6]}"
if __name__ == "__main__":
# These "asserts" using only for self-checking and not necessary for auto-testing
p1 = Person(
"John", "Smith", "19.09.1979", "welder", 15, 3600, "Canada", "Vancouver", "male"
)
p2 = Person(
"Hanna Rose", "May", "05.12.1995", "designer", 2.2, 2150, "Austria", "Vienna"
)
assert p1.name() == "John Smith", "Name"
assert p1.age() == 38, "Age"
assert p2.work() == "Is a designer", "Job"
assert p1.money() == "648 000", "Money"
assert p2.home() == "Lives in Vienna, Austria", "Home"
print("Coding complete? Let's try tests!")
Feb. 28, 2024