Question: The following code contains 5 errors. Identify the line number where the error occurs and provide a brief explanation of how to fix it .

The following code contains 5 errors. Identify the line number where the error occurs and provide a brief explanation of how to fix it. You do not need to add any additional lines or provide updated code.
from tkinter import Tk
from time import sleep
from random import randint as rand
window =Tk()
window.title("The window")
canvas = Canvas (window, width =400, height =400,bg= black")
num_squares = input("How many squares?")
square =[]
colour =["red", "yellow", "green", "blue"]
for i in range(num_squares):
c_col = rand (0,3)
x=rand(10,300)
y=rand(10,300)
xy=(x,y,x+10,y+10)
square.append(canvas.create_rectangle (:(xy,fill=colour[ccol])}
canvas.pack
x=[1]** num_squares
y=[1]** num_squares
while True:
for i in range(num_squares):
pos = canvas.coords(square[i])
if pos [3]>400 or pos [1]0 :
y[i]=-y[i]
if pos [0]0 or pos [2]>400:
x[i]=-x[i]
for j in range(num_squares)
if i=j : continue
pos 2= canvas.coords (square [j])
if pos[0] pos2[2] and pos[2]> pos2[0] and pos[1] pos2[3] and pos[3]> pos2[1]:
y[i]=-y[i]
x[i]=-x[i]
y[j]=-y[j]
x[j]=-x[j]
canvas,move(square [i],x[i],y[i]
sleep(0.002)
window. update()
window mainloop()
 The following code contains 5 errors. Identify the line number where

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!