microbit = codesters.Microbit()
microbit.show_string("hello")
data = microbit.get_temp()
microbit.show_number(data)
data_list = []
time_list = []
my_display = codesters.ScatterPlot(time_list, data_list)
time = 0
def interval():
data = microbit.get_temp()
data_list.append(data)
global time
time_list.append(time)
my_display.update(time_list, data_list)
time += 1
stage.event_interval(interval, 1)
t = codesters.Teacher()
set_titles = t.find_function("set_title")
try:
tval1 = set_titles[0][1].lower().replace(" ", "")
tval2 = t.get_indent_at_line(set_titles[0][0])
except:
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success("timevs.temperature" in tval1 and tval2 == 4, "Great job!")
t1.add_failure("my_data" in tval1, "Did you change the title of your scatter plot?")
t1.add_failure(tval1 == "DNE", "Did you drag in Set Title?")
t1.add_failure(tval2 != 4, "Oops! Make sure you indented your .set_title() command 4 spaces inside your interval event!")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)