WARNING: This program has a bug, which means we need to fix it!
RULE: Programs run in order from top to bottom. We need to create a variable before we can use it!
Click Run and read the error message.
Debug the program so that it draws a circle using the variable my_color.
Hint: Move the circle after the variable.
,
Submitted!
circle = codesters.Circle(0, 0, 150, my_color)
my_color = "purple"
t = codesters.Teacher()
try:
params = t.get_parameters_for_function('Circle')
tval_1 = 0
# you need to iterate through each sublist in the list
# this will count the number of times the variable x is used in Square commands
for sublist in params:
if sublist[3] == "my_color":
tval_1 += 1
except:
tval_1 = "DNE"
try:
params = t.get_parameters_for_function('Circle')
tval_2 = 0
for sublist in params:
if sublist[3] == "purple":
tval_2 += 1
except:
tval_2 = "DNE"
tester = TestManager()
t1 = TestObjective()
t1.add_failure(tval_2 > 0, "Make sure you use the variable name and not the value.")
t1.add_success(tval_1 == 1, "Great job debugging the program!")
t1.add_failure(tval_1 == 0, "Did you use a variable for the color of the circle?")
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
Try the following steps to connect to your Micro:bit:
1. You may need to reload this page and try your program again.
2. Try disconnecting and reconnecting your Micro:bit. Then reload the page and run your program again.
3. If you are still having problems your Micro:bit may have an old
firmware version that is incompatible with Codesters.
To update the firmware follow these instructions from Micro:bit
Are you already running a Codesters project in another tab or window?
Micro:bit can only connect to one web page at a time.
Try stopping other Codesters projects or closing
other tabs or windows that may be using your Micro:bit.
If that doesn't fix the problem try disconnecting your Micro:bit,
reloading this page, and reconnecting your Micro:bit.