2) Write a Python program that draw simple lollipop (a line and few circles, the line should attach to the circles, just as regular lollipop, you decide the colors), just as we make a "dart" for assignment. You can use the same idea when we make "target" by making few circles with different colors, and using mouse click get 2 points to draw a line.
See sample program from Zelle textbook, chapter 4, click.pyw and triangle.pyw. Or see assignment archery.pyw.
Make sure to save this program inside the folder, where the graphics.py is saved, since we need to import graphics.py on top of the program.
I am putting 4 codes here with little variations. You can use the one which suits you the best or you can edit them to meet your requirement,
[1]
import turtle
t=turtle.Turtle()
t.penup()
flag=0
#the initial radius of the circle will be 100 which will keep on
decreasing by
#20 after each iteration, there will be total 5 iterations.
for i in range(100, 1, -20):
t.right(90) # Face South
t.forward(i) # Move one radius
t.right(270) # Back to start heading
t.pendown() # Put the pen back down
# choosing two random colors
if(flag==0):
t.fillcolor('pink')
flag=1
else:
t.fillcolor('red')
flag=0
t.begin_fill()
t.circle(i)
t.end_fill()
#t.circle(i) # Draw a circle
t.penup() # Pen up while we go home
t.home()
t.pendown()
t.pensize("10")
t.pencolor('blue')
t.right(90)
t.forward(250)
OUTPUT
[2]
import turtle
t=turtle.Turtle()
t.penup()
flag=0
#the initial radius of the circle will be 100 which will keep on
decreasing by
#20 after each iteration, there will be total 5 iterations.
for i in range(100, 1, -20):
t.right(90) # Face South
t.forward(i) # Move one radius
t.right(270) # Back to start heading
t.pendown() # Put the pen back down
# choosing two random colors
if(flag==0):
t.fillcolor('pink')
flag=1
else:
t.fillcolor('red')
flag=0
t.begin_fill()
t.circle(i)
t.end_fill()
#t.circle(i) # Draw a circle
t.penup() # Pen up while we go home
t.home()
t.right(90)
t.forward(100)
t.pendown()
t.pensize("10")
t.pencolor('blue')
t.forward(250)
OUTPUT
[3]
import turtle
t=turtle.Turtle()
t.penup()
#array of some random colors, as we will be drawing 5 circles so
i am using 5
# different colors in the array
a=["pink","purple","red","yellow","green"]
c=0
#the initial radius of the circle will be 100 which will keep on
decreasing by
#20 after each iteration, there will be total 5 iterations.
for i in range(100, 1, -20):
t.right(90) # Face South
t.forward(i) # Move one radius
t.right(270) # Back to start heading
t.pendown() # Put the pen back down
#choosing colors from the array
t.fillcolor(a[c])
c+=1 # for next index
t.begin_fill()
t.circle(i)
t.end_fill()
#t.circle(i) # Draw a circle
t.penup() # Pen up while we go home
t.home()
t.right(90)
t.forward(100)
t.pendown()
t.pensize("10")
t.pencolor('blue')
t.forward(250)
OUTPUT
2) Write a Python program that draw simple lollipop (a line and few circles, the line should atta...
Java Programing. Using NetBean Write a program to draw a line connecting two circles. These two circles can be dragged by mouse. And when circles are dragged, the line should be adjusted so that it still connect these two circles (binding property)
Python3 : question about object-oriented programming, Please write program in the template(critter.py),specific information is on the graphs the missing words in the 4th line are 'To save an attribute, attach it to this self keyword' W11 - Critters Implement the Critter class. Each critter C has attributes species, size, and age The constructor accepts arguments for the attributes above, in the order above. You can expect size and age to be numeric values Each critter C has a can_eat) method,...
Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...
If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own. INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, the...
please use python and provide run result, thank you! click on pic to make it bigger For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...
Java How to Program, Early Objects ISBN-13: 9780133813432 Project Name: C2800_Proj1_RaceGame Source File Name: (Submit zip of these) RaceGame.java (contains main) RaceCar.java RaceGame is a text based car racing game. The user is car #1 and the computer is car #2. A car is drawn using 2 lines. The number on the first line is 1 for the user and 2 for the computer. __/1\__ -O---O- When the car has moved down the track, print underscore’s on the second line...
1 Overview For this assignment you are required to write a Java program that plays (n, k)-tic-tac-toe; (n, k)-tic- tac-toe is played on a board of size n x n and to win the game a player needs to put k symbols on adjacent positions of the same row, column, or diagonal. The program will play against a human opponent. You will be given code for displaying the gameboard on the screen. 2 The Algorithm for Playing (n, k)-Tic-Tac-Toe The...
python 11.8 Multiple committees The eventual goal of this assignment is to compute the total number of ways of forming a collection of committees from an academic department of n professors. The first task is to write a function called committee to compute the number of ways of forming a single committee with members from a collection of n people. This is the same as compușing the number of ways of choosing r people out of n to sit at...
For this assignment, you will write a program to work with Huffman encoding. Huffman code is an optimal prefix code, which means no code is the prefix of another code. Most of the code is included. You will need to extend the code to complete three additional methods. In particular, code to actually build the Huffman tree is provided. It uses a data file containing the frequency of occurrence of characters. You will write the following three methods in the...
The first script is validate.sh. This is a simple form validation script that will be used to verify the inputs given. Normally, this would be done to validate input from a website or another program before entry into a database or other record storage. In this case, we will keep it simple and only focus on the input validation step. In particular, the script should prompt the user for four values: first name, last name, zip code, and email address....