Methods | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 3


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
3 ответов
+ 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
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