+ 3

Methods

fido = Dog("Fido", "brown") print(fido.color) fido.bark() Can we say Fido.color ()=Brown? What does the () represent please?

8th Mar 2018, 4:24 AM
Adaobi
3 Answers
+ 4
"Can we say Fido.color ()=Brown?" Answer : No, we cannot say that. If you wanted to change the color attribute of fido, you use fido.color = "brown" without the parantheses "What does the () represent please?" The parentheses i.e () is characteristic of methods so doing something like fido.color() implies that you are calling a method color() inside class Dog.
8th Mar 2018, 7:24 AM
David Akhihiero
David Akhihiero - avatar
+ 1
Also, is Fido.Color = Print (Fido.Color)
8th Mar 2018, 4:29 AM
Adaobi
0
Since you didn't include whole code, i can only make assumption. I think 'color' may be a variable (if not property ofcourse). And bark is a method, so you must include parenthesis () inorder to call it. A variable doesn't need ().
8th Mar 2018, 6:37 AM
Sylar