1.Is pen color a local variable or a global variable? import turtle import rando
ID: 3887238 • Letter: 1
Question
1.Is pen color a local variable or a global variable? import turtle import random def square(tortoise, fcolor, pcolor, length): Draws a square. Parameters: tortoise: a Turtle object used to draw the square. fcolor: a string representing fill color pcolor: a string representing pen color length: an integer representing the distance of each line segment Return value: None em tortoise.pencolor(pcolor) tortoise.fillcolorffcolor) tortoise.down0 tortoise.begin_fill0) for segment in range(4): tortoise.forwardsize) tortoise.left(90) tortoise.end_fill0 tortoise.upo def makeSquare(x, y): Draws a square. Parameters: x: the x coordinate at which to draw a square y: the y coordinate at which to draw a square Return value:Explanation / Answer
1. Pen color variable is local variable because it is defined inside the function or section in parameters.
2. george is a global variable because it is directly used in this program until unless it is defined outside the scope this variable doesn't work i.e the george variable is declared outside, here we have directly used it.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.