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

Language: Python For this problem, we have 3 balls of different weights. Your jo

ID: 3865788 • Letter: L

Question

Language: Python

For this problem, we have 3 balls of different weights. Your job is to write a program that allows the user to place the balls on either side of a scale and reports which side of the scale is heavier The left sc le is heavier. Figure 2: An example wih all balls currently on the left-hand scale Here is a description of how your program should look Use a 400x30O canvas size Colour half of the screen white and the other half black. Each half of the screen represents one side of a scale Display 3 balls on the canvas. Each ball has a different weight (1kg, 2kg and 3kg). Each ball should be a different colour, and heavier balls should be bigger Display at all times on the canvas a message indicating whether the scale is balanced, or if not, which side is heavier, based on the position of the balls Here is a description of how your program should behave . Initially, the balls can be anywhere on the screen. In the example above, they are all on the left-hand side of the scale When the user presses '1: The 1kg ball should be moved to the location of the mouse When the user presses '2': The 2kg ball should be moved to the location of the mouse When the user presses '3': The 3kg ball should be moved to the location of the mouse Of course, the message concerning which side of the scale is heavier should be kept up to date as the balls move Here are some suggestions for how to design your program, especially with regard to the Model-View- Controller design pattern. . You will want to use at least 6 global variables in your program: these are the current x and y coor- dinates for each of the three balls. You may wish to use another 3 global variables for the weight of each ball as well, although since the weights do not change, this is not strictly necessary

Explanation / Answer

Algorithm :


Firt of all, we need to know by how much a ball is different from the other balls.

Take 1 ball from each shoot ball and put all of them in the scale and note the weight.

It should be 12 * 500 Rs = 6000 Rs

diff = (6000Rs - mesuredWeight) , this is fault wight in a ball from the faulty machine (we dont know yet which machine )


identify the the faulty machine

- take 1 ball from the shoot ball 1
- take 2 ball from the shoot ball 2
- take 3 ball from the shoot ball 3
.
.
.
.
- take 12 ball from the shoot ball 12

The total is 1 + 2+ 3 + ........+ 12 = 12*11/2 = 66 balls

the total weight should be 66 * 500 Rs = 33000 Rs expected weight if there is no faulted machine

Now pout the 66 balls in the scale and note the weight totFaultyWeith.

totalDiff = 33000 - totFaultyWeith

if totalDiff = diff ==> only one ball is faulty and means the first machine is faulty
if totalDiff = 2*diff ==> 2 balls are faulty and means the second machine is faulty
if totalDiff = 3*diff ==> 3 balls are faulty and means the third machine is faulty
.
.
.
.
.
if totalDiff = 12*diff ==> 12 balls are faulty and means the 12d machine is faulty

Answer : 2 weighting are required if we don't know by how much a ball is fault
1 weighting is required if we know by how much the ball is faulty