In: Computer Science
Write an if statement that uses the turtle graphics library to determine whether the turtle’s pen color is red or blue. If so, set the pen size to 5 pixels.
Python.
RAW CODE
from turtle import *
if pencolor() == 'red' or pencolor() == 'blue':
#print(pencolor()) # Uncomment it to show pencolor.
pensize(5) #### Set pen size to 5 pixels in case of red or blue pen color
SCREENSHOTS (CODE WITH OUTPUT) ### TAKEN EXAMPLE OF DRAWING CIRCLES ###
WHEN ITS RED OR BLUE COLOR (Pen size changes)
FOR ANY OTHER COLOR EXCEPT RED OR BLUE (Pen size remains same)
##### FOR ANY QUERY, KINDLY GET BACK, THANKYOU. #####