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

For python 3.4 My code is not working :( Create the following graphics dice prog

ID: 3846283 • Letter: F

Question

For python 3.4

My code is not working :(

Create the following graphics dice program. Dice Total Exit The user will be "throwing" 5 dice. They will "throw" each of the 5 dice by clicking on their respective outlined areas. You will then need to generate a number between 1-6 for each click/throw and display that dice side in the clicked outlined area. After each click/throw the new running total will appear below the dice. After all the dice have been clicked/thrown you will display a message below the dice total remarking on how lucky they are. Have an Exit button the user can click to exit the program. You can assume that the dice are clicked/thrown in order of 1 to 5. This program does not allow a second click/throw on a dice. If the user clicks outside of the dice outlines nothing should happen, no dice display, no error message. You need to create and use a function that is called with every dice click/throw. You need to create and use a function that generates the random dice number Ba between 1-6. This program draws that dice in the appropriate outlined area. You can do this by calling another function or functions.

Explanation / Answer

#Code has been modified for proper functioning

from graphics import *
import random

def intrandom():
   intNum = random.randint(1,6)
   return intNum

#to draw the dots inside dice
def dot(win,x1,y1):
   intNum = intrandom() #get the random number between 1 to 6
   dot.counter += intNum
  

   if intNum == 1:
   #draw 1 dot
       circDot4 = Circle(Point(50+x1,50+y1),5) #add x1 and y1 to the point co-ordinates to draw the dots inside the clicked box
       circDot4.setFill('black')
       circDot4.draw(win)
      
   if intNum == 2:
  
       circDot2 = Circle(Point(25+x1,50+y1),5)#add x1 and y1 to the point co-ordinates to draw the dots inside the clicked box
       circDot2.setFill('black')
       circDot2.draw(win)
       circDot2 = Circle(Point(75+x1,50+y1),5)
       circDot2.setFill('black')
       circDot2.draw(win)
       #circDot6 = dot.clone()
       #circDot6.move(50,0)
       #circDot6.draw(win)
      
   if intNum == 3:
  
       circDot3 = Circle(Point(25+x1,75+y1),5)#add x1 and y1 to the point co-ordinates to draw the dots inside the clicked box
       circDot3.setFill('black')
       circDot3.draw(win)
       circDot4 = Circle(Point(50+x1,50+y1),5)
       circDot4.setFill('black')
       circDot4.draw(win)
       circDot5 = Circle(Point(75+x1,25+y1),5)
       circDot5.setFill('black')
       circDot5.draw(win)
      
   if intNum == 4:
  
       circDot1 = Circle(Point(25+x1,25+y1),5)#add x1 and y1 to the point co-ordinates to draw the dots inside the clicked box
       circDot1.setFill('black')
       circDot1.draw(win)
       circDot3 = Circle(Point(25+x1,75+y1),5)
       circDot3.setFill('black')
       circDot3.draw(win)
       circDot5 = Circle(Point(75+x1,25+y1),5)
       circDot5.setFill('black')
       circDot5.draw(win)
       circDot7 = Circle(Point(75+x1,75+y1),5)
       circDot7.setFill('black')
       circDot7.draw(win)
      
   if intNum == 5:
  
       circDot1 = Circle(Point(25+x1,25+y1),5)#add x1 and y1 to the point co-ordinates to draw the dots inside the clicked box
       circDot1.setFill('black')
       circDot1.draw(win)
       circDot3 = Circle(Point(25+x1,75+y1),5)
       circDot3.setFill('black')
       circDot3.draw(win)
       circDot5 = Circle(Point(75+x1,25+y1),5)
       circDot5.setFill('black')
       circDot5.draw(win)
       circDot7 = Circle(Point(75+x1,75+y1),5)
       circDot7.setFill('black')
       circDot7.draw(win)
       circDot4 = Circle(Point(50+x1,50+y1),5)
       circDot4.setFill('black')
       circDot4.draw(win)
      
   if intNum == 6:
  
       circDot1 = Circle(Point(25+x1,25+y1),5)#add x1 and y1 to the point co-ordinates to draw the dots inside the clicked box
       circDot1.setFill('black')
       circDot1.draw(win)
       circDot3 = Circle(Point(25+x1,75+y1),5)
       circDot3.setFill('black')
       circDot3.draw(win)
       circDot5 = Circle(Point(75+x1,25+y1),5)
       circDot5.setFill('black')
       circDot5.draw(win)
       circDot7 = Circle(Point(75+x1,75+y1),5)
       circDot7.setFill('black')
       circDot7.draw(win)
       circDot4 = Circle(Point(50+x1,25+y1),5)
       circDot4.setFill('black')
       circDot4.draw(win)
       circDot2 = Circle(Point(50+x1,75+y1),5)
       circDot2.setFill('black')
       circDot2.draw(win)
       #circDot6 = dot.clone()
       #circDot6.move(50,0)
       #circDot6.draw(win)
dot.counter = 0       #counter to calculate the total
def dice(win,x1,y1,x2,y2):
   sqrDice = Rectangle(Point(x1,y1), Point(x2,y2))
   sqrDice.setFill('snow')
   sqrDice.setOutline('snow')
   sqrDice.draw(win)
   dot(win,x1,y1) #pass (x1,y1) co-ordinates of the dice to draw the dots inside the particlar dice, else dot will be overwritten in same place
  
def main():
   win = GraphWin('Dice', 650,400)
   win.setBackground('khaki')
  
   blnRun = True
   #draw dice1
   Box1 = Rectangle(Point(25,25), Point(125,125))
   Box1.setFill('white')
   Box1.draw(win)
   #draw dice2
   Box2 = Rectangle(Point(150,25), Point(250,125))
   Box2.setFill('white')
   Box2.draw(win)
   #draw dice3
   Box3 = Rectangle(Point(275,25), Point(375,125))
   Box3.setFill('white')
   Box3.draw(win)
   #draw dice 4
   Box4 = Rectangle(Point(400,25), Point(500,125))
   Box4.setFill('white')
   Box4.draw(win)
   #draw dice5
   Box5 = Rectangle(Point(525,25), Point(625,125))
   Box5.setFill('white')
   Box5.draw(win)
  
   while blnRun == True:
   #get x and y co-ordinates of the click
       Clickxy = win.getMouse()
       xPoint = Clickxy.getX()
       yPoint = Clickxy.getY()
      
       #if they are clicked within the button call the dice function
       if(xPoint > 25 and xPoint < 125 and yPoint > 25 and yPoint < 125):
           dice(win,25,25,125,125) #pass x and y co-ordinates of the dice
       elif(xPoint > 150 and xPoint < 250 and yPoint > 25 and yPoint < 125):
           dice(win,150,25,250,125)
       elif(xPoint > 275 and xPoint < 375 and yPoint > 25 and yPoint < 125):
           dice(win,275,25,375,125)
       elif(xPoint > 400 and xPoint < 500 and yPoint > 25 and yPoint < 125):
           dice(win,400,25,500,125)
       elif(xPoint > 525 and xPoint < 625 and yPoint > 25 and yPoint < 125):
           dice(win,525,25,625,125)
       else:
           Text(Point(200,325),"Click on die").draw(win)
       Text(Point(50,300),"Dice Total").draw(win)
      
main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote