PLEASE TRANSLATE THESE MEANING INTO THE PYTHON CODE,WRITE PYTHON CODE ON COMPUTE
ID: 3739611 • Letter: P
Question
PLEASE TRANSLATE THESE MEANING INTO THE PYTHON CODE,WRITE PYTHON CODE ON COMPUTER PLEASE THANK YOU
import random
#set nine counters for the nine regions
C1 = 0
C2 = 0
C3 = 0
C4 = 0
B1 = 0
B2 = 0
B3 = 0
B4 = 0
O = 0
for robots in range (0,100):#Robots
initialize x,y inside the box (at least one unit away from boundary/corner)
randomly move the robot
for 1000 steps:
if not corner and not border:
choose from two possible options
if option 1: #50% for biased direction
Keep moving in the direction it was moving in the previous step
elif option 2:#remaining 50% for the 3 directions
move the robot randomly in one of the three remaining directions
elif boundaries:
randomly move out of three options
The options will depend on which boundary you are in
elif corners:
randomly move out of two options
The options will depend on which corner you are in
#Keep track of what region the robot is.
if x <= 5 and y >= 15:#C1
C1 = C1 + 1
elif x >= 15 and y >= 15:#C2
C2 = C2 + 1
elif x >= 15 and y <= 5:#C3
C3 = C3 + 1
elif x <= 5 and y <= 5:#C4
C4 = C4 + 1
elif (15<=y<=20) and (5<=x<=15):#B1
B1 = B1 + 1
elif (15<=x<=20) and (5<=y<=15):#B2
B2 = B2 + 1
elif y <= 5 and (5<=x<=15):#B3
B3 = B3 + 1
elif x <= 5 and (5<=y<=15):#B4
B4 = B4 + 1
elif 5 <= x <= 15 and 5 <= y <= 15:#O
O = O + 1
#print the average
print("Average Time Robot Spend in C1 : " + str(C1/100))
Explanation / Answer
Kindly, explain the conditions in more details so that I can update the code according to your requirements.
CODE
===================
import random
#set nine counters for the nine regions
C1 = 0
C2 = 0
C3 = 0
C4 = 0
B1 = 0
B2 = 0
B3 = 0
B4 = 0
O = 0
for robots in range (0,100):#Robots
x = 1
y = 1
for step in range(0, 1000):
if x != 0 or y != 0:
# please explain clearly what needs to be done in this case
elif x == 0 or y == 0:
# please explain clearly what needs to be done in this case
elif x == 0 and y == 0:
`# please explain clearly what needs to be done in this case
#Keep track of what region the robot is.
if x <= 5 and y >= 15:#C1
C1 = C1 + 1
elif x >= 15 and y >= 15:#C2
C2 = C2 + 1
elif x >= 15 and y <= 5:#C3
C3 = C3 + 1
elif x <= 5 and y <= 5:#C4
C4 = C4 + 1
elif (15<=y<=20) and (5<=x<=15):#B1
B1 = B1 + 1
elif (15<=x<=20) and (5<=y<=15):#B2
B2 = B2 + 1
elif y <= 5 and (5<=x<=15):#B3
B3 = B3 + 1
elif x <= 5 and (5<=y<=15):#B4
B4 = B4 + 1
elif 5 <= x <= 15 and 5 <= y <= 15:#O
O = O + 1
#print the average
print("Average Time Robot Spend in C1 : " + str(C1/100))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.