What is the name of jane’s attribute (not method) that is referred to in the following code?
import turtle
jane = turtle.Turtle()
jane.forward(20)
print(jane.x)
Answers
Answered by
3
'x' is the name of jane's attribute referred in the given code.
Given code :
import turtle
jane = turtle.Turtle()
jane.forward(20)
print(jane.x)
Attribute is nothing but the instance of a class. Here, the turtle's object 'jane' is accessing its attribute x. In reality, we didn't create that attribute, so it will raise an Error.
Explanation of code :
- Coming to the complete code, we have imported the turtle library and created a turtle object with the variable name 'jane'
- jane.forward(20) moves forward the turtle object by 20 pixels on Turtle screen.
- In the next line, Jane tries to access its attribute x, which isn't yet created.
Learn more :
1) What is the output Of kill 9042018?
https://brainly.in/question/13538278
2) Given the following permutation of a,b,c,d,e,f,g,h,i,j, what is the next permutation after 'eibjdhgfca', in lexicographic (dictionary) order?
https://brainly.in/question/12375223
Attachments:
Answered by
1
the attributeof the object
is. x
Similar questions