Question

In: Computer Science

Write an if statement that uses the turtle graphics library to determine whether the turtle’s pen...

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.

Solutions

Expert Solution

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


Related Solutions

Write the code in python only. You will need the graphics library for this assignment. Please...
Write the code in python only. You will need the graphics library for this assignment. Please download the library and place it in the same file as your solution. Draw a 12" ruler on the screen. A ruler is basically a rectangular outline with tick marks extending from the top edge. The tick marks should be drawn at each quarter-inch mark. Below the tick marks, your ruler should show large integers at each full-inch position.
with python, create a fake logo for a company using turtle graphics
with python, create a fake logo for a company using turtle graphics
Assignment Write a program using turtle graphics which writes your initials, or any other three unique...
Assignment Write a program using turtle graphics which writes your initials, or any other three unique letters, to the display. Look to your program for lab 1 for reminders of how to use turtle graphics. Functions that must be written: def drawLetter (x, y, letterColor): Write three functions, one for three unique letters. Personally, I would write drawA, drawR, and drawS. Each function must draw that letter to the screen. The x and y values determine the upper left-hand location...
Write a function that plots the following trajectory equations using python turtle graphics. x = v*sin(A)*t...
Write a function that plots the following trajectory equations using python turtle graphics. x = v*sin(A)*t y = v*cos(A)*t -.5*(9.8)*t**2 Loop through t starting at 0 and increment by .1 until y<=0. (hint, while loop) Experiment with values of velocity V (1 to 20) and angle A (0 to 90) that gives you a good plot that does not go off the screen. Position the start of the plot at the left bottom of the screen
c++ class Topics Branches if statement if/else statement Description Write a program that will determine whether...
c++ class Topics Branches if statement if/else statement Description Write a program that will determine whether the user passed or failed a test. The program will ask the user to input the following: Maximum Test Score - the maximum total scores in the test. Percent Pass Score - the minimum percent scores required to pass the test. User Test Score - the actual scores obtained by the user in the test. From the above input values, the program will compute...
Write a function named cup that uses a turtle parameter t to draw a cup consisting...
Write a function named cup that uses a turtle parameter t to draw a cup consisting of three sides of a square. Your function should not change the position or orientation of t before drawing the first side of the cup. The turtle t that is passed to cup may initially be either up or down and may be at any location on the screen and in any orientation. After drawing a side, the turtle t should turn left. When...
3. (Even or Odd) Write method IsEven that uses the remainder operator (%) to determine whether...
3. (Even or Odd) Write method IsEven that uses the remainder operator (%) to determine whether an integer is even. The method should take an integer argument and return true if the integer is even and false otherwise. Incorporate this method into an application that inputs a sequence of integers (one at time) and determines whether each is even or odd. (C# please)
Use the truth-tree decision procedure (relying on Proof Tools or pen/pencil and paper) to determine whether...
Use the truth-tree decision procedure (relying on Proof Tools or pen/pencil and paper) to determine whether P→Q,Q⊨P is deductively valid.
Use Turtle graphics to draw your first name or your nickname if over 6 letters.           Just...
Use Turtle graphics to draw your first name or your nickname if over 6 letters.           Just initials of your first & last name is OK if you add another feature such as color. My initials are J.S but I don't know how to color them. Here is my code: Python program to print nick name if a name is greater than 6 character or initials if the color if given """ import turtle as T fName, lName = input('Enter name:...
How to make a python program that imports only turtle and math library where I can...
How to make a python program that imports only turtle and math library where I can click once on the screen to set the center of the square, move the mouse to define the edge-length of the square; click a second time to draw the square with the defined edge-length and center point?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT