Question
Hi,
How can do number 2? It says that I have to draw RANDOM number of circle IN A SPECIFIC LOCATION from upper left corner to bottom right corner using python TKINTER.
Thank you

LAM THIEU LUONG Draw Design Layout References Mailings Review View Help p Search 8 Shan Description of Problem: should be men
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#draw.py

from tkinter import *
from random import randint
tk=Tk()
#canvas object
canvas = Canvas(tk, width = 400, height =400)
canvas.pack()
x = 5
y = 5
#get random number .
len = randint(20,100)
#till bottom right corner
for count in range(0,len):
   color = ""
   #assign 3 colors consequentyl
   if(count % 3 == 0):
       color = "red"
       r = 25
   elif(count % 3 == 1):
       color = "green"
       r = 15
   elif(count % 3 == 2):
       color ="blue";
       r = 10
   #create oval at given position
   canvas.create_oval(x, y, x+r, y+r,fill=color)
   count +=1
   x += r
   y += r
tk.mainloop()

tkdraw.py 1 from tkinter import 2 from random import randint tk Tk 3 #canvas object Canvas (tk, width 5 400, height =400) canva

Add a comment
Know the answer?
Add Answer to:
Hi, How can do number 2? It says that I have to draw RANDOM number of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hi y’all this is python 3.7 I am new so please explain how code works Untitled...

    Hi y’all this is python 3.7 I am new so please explain how code works Untitled - Notepad File Edit Format View Help #3.4.3. study the following program, and then reorganize it with a #main function that calls one or more other functions. #Your main function should be very short: create a turtle, #call your functions, and then wait for a mouse click. #Document your program with appropriate doc strings and comments. #import turtle #george turtle . Turtle() #george ....

  • Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu:...

    Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu: Enter Circle Enter Rectangle Remove Shape Draw Shapes Exit Circles – User inputs position, radius, and color. The position is the CENTER of the circle Rectangles – User inputs position, height, width, color. The position is the lower left-hand corner Colors – Allow red, yellow, blue, and green only Remove – Show the number of items in the list and let the user enter...

  • Hi, can you help me add these requirements in my Turtle python program. The program is...

    Hi, can you help me add these requirements in my Turtle python program. The program is supposed to run an Olympics skating game. The program is below the requirements. Thanks Requirements -Your race will be random generated so each time there is a possibility that a different winner. -Have a countdown of “READY” “SET” “GO” appear on the screen and then the turtles take off. -Have the program tell the winner[s]. -Award Medals. -User may guess who will win. -Allow...

  • Java program GCompound Practice Exercise CS141 Assignment Write a class that represents a digital snowman. Your...

    Java program GCompound Practice Exercise CS141 Assignment Write a class that represents a digital snowman. Your class should follow these guidelines: 1. Store the following private class variables bodyColor of type Color b. int x, int y for the upper left corner Graphics g. a. C. 2. Create two different constructor methods a. A (int x, int y, Graphics myG) parameter constructor that makes the snowman a light gray color by default and makes x and y the upper left...

  • Assignment Λ You shall write a Java program that accepts 5 command-line arguments and generates an image of a Sierpinski triangle, as a 24- bit RGB PNG image file. Specifications The command-line arg...

    Assignment Λ You shall write a Java program that accepts 5 command-line arguments and generates an image of a Sierpinski triangle, as a 24- bit RGB PNG image file. Specifications The command-line arguments shall consist of the following 1. The width (in pixels) of the image, as a positive decimal integer 2. The height (in pixels) of the image, as a positive decimal integer 3. The minimum area (in pixels) that a triangle must have in order to be drawn,...

  • A specific question I have on this project is how do I make the stars all...

    A specific question I have on this project is how do I make the stars all align into making a box. Whenever I post this question the stars on the right edge go in towards the item of the shopping list. I need the starts to create a a box around the shopping items. Instructions: Using Python write a program that allows a user to create and use a shopping list. Your program will display a menu of options to...

  • Part I: Background When a ray of light strikes a smooth surface, it can either reflect,...

    Part I: Background When a ray of light strikes a smooth surface, it can either reflect, such as with a mirror, or it can both reflect and refract, such as with glass. In this make-up lab activity, we shall look at both situations. This make-up lab shall try to replicate the lab from your lab manual as best possible. Be sure to read the "Discussion" in your regular lab manual. You will be using the Bending Light simulation. Part II:...

  • I have this problem for a final thats in my book thats i'm stuck on ....

    I have this problem for a final thats in my book thats i'm stuck on . Any help would be really appreciated. Design and code a Swing GUI to translate text that is input in English into Pig Latin. You can assume that the sentence contains no punctuation. The rules for Pig Latin are as follows: ⦁ For words that begin with consonants, move the leading consonant to the end of the word and add “ay.” For example, “ball” becomes...

  • Hi I have a problem with number 5, it involves gel analysis results. There are 2 parts, a,b,c. For A Im sure you need to make a graph with distance in (cm) on the vertical axis and log10 bp on the hor...

    Hi I have a problem with number 5, it involves gel analysis results. There are 2 parts, a,b,c. For A Im sure you need to make a graph with distance in (cm) on the vertical axis and log10 bp on the horitzontal. I need help figuring out where to start and what to do. Please help! The following question will provide practice in interpreting and analyzing gel results You obtained the DNA electrophoresis gel below. Three samples of lambda phage...

  • Game Description: Most of you have played a very interesting game “Snake” on your old Nokia...

    Game Description: Most of you have played a very interesting game “Snake” on your old Nokia phones (Black & White). Now it is your time to create it with more interesting colors and features. When the game is started a snake is controlled by up, down, left and right keys to eat food which appears on random locations. By eating food snake’s length increases one unit and player’s score increases by 5 points. Food disappears after 15 seconds and appears...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT