Methods | SoloLearn: Learn to code for FREE!

+3

Methods

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

3/8/2018 4:24:54 AM

Adaobi

3 Answers

New Answer

+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.

+1

Also, is Fido.Color = Print (Fido.Color)

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 ().