Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi ### Use Pyhton Code only ### Create a graphics window program that will displ

ID: 3776295 • Letter: H

Question

Hi ### Use Pyhton Code only ### Create a graphics window program that will display the 5 side of a dice. First: Just build it using one main function. Second: Create a function called dice() to give the white background. Third: Create another function called dot(). This function will draw all 5 dots. Forth: Change the order of the functions so that - From the main() function you call a dice() function to "build" the dice. To draw the dots you will then need to call a dot()function (see below first image).Call the dot() function 5 times from the dice() function rather than drawing 5 dots inside the dice() function

Explanation / Answer

For all parts you would need the library from http://mcsp.wartburg.edu/zelle/python/graphics.py

First Part: with only main function

def main():
  
w = GraphWin()
s1 = Rectangle(Point(140,140), Point(20,20))
s1.setFill("White")
s1.draw(w)
  
center = Point(120,120)
sd1 = Circle(center, 5)
sd1.setFill("Black")

center2 = Point(120,50)
sd2 = Circle(center2, 5)
sd2.setFill("Black")

center3 = Point(80,80)
sd3 = Circle(center3, 5)
sd3.setFill("Black")

center4 = Point(40,50)
sd4 = Circle(center4, 5)
sd4.setFill("Black")

center5 = Point(40,120)
sd5 = Circle(center5, 5)
sd5.setFill("Black")
  
sd1.draw(w)
sd2.draw(w)
sd3.draw(w)
sd4.draw(w)
sd5.draw(w)
  
main()

Second Part: with dot and dice function

from graphics import *
w = GraphWin()
def dot(c,d):
center = Point(c,d)
sd1 = Circle(center, 5)
sd1.setFill("Black")
sd1.draw(w)

def dice(a,b):
s1 = Rectangle(Point(a,a), Point(b,b))
s1.setFill("White")
s1.draw(w)
dot(120,120)
dot(120,50)
dot(80,80)
dot(40,50)
dot(40,120)
  
def main():
dice(140,20)