Friday, December 20, 2019

class lesson person and car

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age


def print_person(person):
    print("My name is ",person.name, " and i am " ,person.age, " years old")

ali = Person("ali", 43)

print_person(ali)
     
sonia = Person("sonia", 8)

print_person(sonia)

mum = Person("Solmaz", 37)

print_person(mum)






class Car:
  def __init__(self,name, color):
      self.name = name
      self.color = color
 

def print_car(car):
    print("I am a ", car.color, " ", car.name, " car.")

rusty = Car("Rusty", "Gray")
mum_car = Car("Mum", "Gray")
sonia_car = Car("pinkyyyyy", "Pink")
tina_car = Car("yellowwww","yellow")

print_car(rusty)
print_car(mum_car)
print_car(sonia_car)
print_car(tina_car)

No comments:

Post a Comment