What will be the output of the following Python code? [code]import turtle t=turtle.Pen() t.backward(100) t.penup() t.right(45) t.isdown()[/code]

Sơn Lê

Member
What will be the output of the following Python code?
Code:
import turtle
t=turtle.Pen()
t.backward(100)
t.penup()
t.right(45)
t.isdown()
A. True
B. False
C. Yes
D. No
 
Answer: b
Explanation: In the code shown above, we have used the function t.penup() to life the pen from the canvas. However, we have not used the function t.pendown() to keep the pen back down. The function turtle.isdown() returns True if the pen is down and False if the pen is not down. Hence the output is False.
 

Tìm kiếm

Back
Top