You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-3Lines changed: 10 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -37,25 +37,32 @@ A class mainly contains methods, attributes, instances and a prefix
37
37
38
38
39
39
At 1, i defined a class and named it as Introduction (keep first letter in capitals).
40
+
40
41
At 2, i defined a method by def and the method name is __init__(), having 3 parameters self, age, name
42
+
41
43
At 3, i mentioned attributes by using self.(anything you like to print) = the same parameter,
42
44
in this case our attributes are name and age
45
+
43
46
At 4, i defined another method describe(), which will take care in what manner the output will be printed.
47
+
44
48
At 5, i gave the print command which basically gives us the output when describe method is called via instance.
49
+
45
50
At 6, i used str() function (use to define strings) with age.self, as python will only take strings not integers.
51
+
46
52
At 7, i mentioned an instance 'intro' which is use to call the class Introduction,
47
53
also the values of parameters (name, age) are defined here (that is 'yash', 23)
54
+
48
55
At 8, i used the instance (intro) and method (describe) together in order to get the output that particulat method only
49
56
50
-
Note: You can define as many as methods you like and to get all of them printed you need to mention the method name
51
-
with the instance name. As shown above (8).
57
+
*Note: You can define as many as methods you like and to get all of them printed you need to mention the method name with the instance name. As shown above (8).
58
+
52
59
53
60
54
61
55
62
56
63
64
+
* Brief Explanation:
57
65
58
-
# Brief Explanation:
59
66
The __init__() method at is a special method that Python runs automatically whenever
60
67
we create a new instance based on the Dog class.
61
68
This method has two leading underscores and two trail-ing underscores,
0 commit comments