From 034ac93007781dfe5bea5f19d8265495e5d398b5 Mon Sep 17 00:00:00 2001 From: kunyaw12 <86627300+kunyaw12@users.noreply.github.com> Date: Fri, 30 Jul 2021 23:44:31 +0800 Subject: [PATCH 1/4] Create Class and Object This is a simple program to help other learn to create class and object --- Creating Class and Object | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Creating Class and Object diff --git a/Creating Class and Object b/Creating Class and Object new file mode 100644 index 0000000..ce3fd0d --- /dev/null +++ b/Creating Class and Object @@ -0,0 +1,21 @@ +class Lion: + + # class attribute + species = "bird" + + # instance attribute + def __init__(self, name, age): + self.name = name + self.age = age + +# instantiate the Parrot class +blu = Parrot("Blu", 10) +woo = Parrot("Woo", 15) + +# access the class attributes +print("Blu is a {}".format(blu.__class__.species)) +print("Woo is also a {}".format(woo.__class__.species)) + +# access the instance attributes +print("{} is {} years old".format( blu.name, blu.age)) +print("{} is {} years old".format( woo.name, woo.age)) From 3a5d08d1b33a68feea13f8a6e4535e2dfebb4534 Mon Sep 17 00:00:00 2001 From: kunyaw12 <86627300+kunyaw12@users.noreply.github.com> Date: Sat, 31 Jul 2021 04:19:02 +0800 Subject: [PATCH 2/4] Creating class and objects A simple python program for creating calss and object --- Creating Class and Objectst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Creating Class and Objectst diff --git a/Creating Class and Objectst b/Creating Class and Objectst new file mode 100644 index 0000000..024ab74 --- /dev/null +++ b/Creating Class and Objectst @@ -0,0 +1,21 @@ +class Lion: + + # class attribute + species = "animal" + + # instance attribute + def __init__(self, name, age): + self.name = name + self.age = age + +# instantiate the Parrot class +blu = Lion("Blu", 10) +woo = Lion("Woo", 15) + +# access the class attributes +print("Blu is a {}".format(blu.__class__.species)) +print("Woo is also a {}".format(woo.__class__.species)) + +# access the instance attributes +print("{} is {} years old".format( blu.name, blu.age)) +print("{} is {} years old".format( woo.name, woo.age)) From 28adfd456e0efba4dd78b3e67fbb19022dcf2119 Mon Sep 17 00:00:00 2001 From: kunyaw12 <86627300+kunyaw12@users.noreply.github.com> Date: Sat, 31 Jul 2021 04:19:26 +0800 Subject: [PATCH 3/4] Delete Creating Class and Object --- Creating Class and Object | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 Creating Class and Object diff --git a/Creating Class and Object b/Creating Class and Object deleted file mode 100644 index ce3fd0d..0000000 --- a/Creating Class and Object +++ /dev/null @@ -1,21 +0,0 @@ -class Lion: - - # class attribute - species = "bird" - - # instance attribute - def __init__(self, name, age): - self.name = name - self.age = age - -# instantiate the Parrot class -blu = Parrot("Blu", 10) -woo = Parrot("Woo", 15) - -# access the class attributes -print("Blu is a {}".format(blu.__class__.species)) -print("Woo is also a {}".format(woo.__class__.species)) - -# access the instance attributes -print("{} is {} years old".format( blu.name, blu.age)) -print("{} is {} years old".format( woo.name, woo.age)) From 16bd5a6cff505db9bf98f6aa26f7883fc45619d4 Mon Sep 17 00:00:00 2001 From: kunyaw12 <86627300+kunyaw12@users.noreply.github.com> Date: Sun, 29 Aug 2021 03:50:18 +0800 Subject: [PATCH 4/4] Create class and object Simply python program to create class and object --- Create class and object | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Create class and object diff --git a/Create class and object b/Create class and object new file mode 100644 index 0000000..62dc700 --- /dev/null +++ b/Create class and object @@ -0,0 +1,16 @@ +class Person: + "This is a person class" + age = 10 + + def greet(self): + print('Hello') + + +# Output: 10 +print(Person.age) + +# Output: +print(Person.greet) + +# Output: "This is a person class" +print(Person.__doc__)