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
t = codesters.Teacher()
get_temps = t.find_function("get_temp")
try:
tval1 = t.find_block('def')[0][1]
except:
tval1 = "DNE"
try:
tval2 = t.get_indent_at_line(get_temps[1][0])
except:
tval2 = "DNE"
t1 = TestObjective()
t1.add_success('interval' in tval1, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add an interval event?")
t1.add_failure('interval' not in tval1, "Make sure you added an Interval Event from Stage Events.")
t2 = TestObjective()
t2.add_success(tval2 == 4, "Great job!")
t2.add_failure(tval2 == 0, "Oops! Did you indent your second .get_temp() command 4 spaces?")
t2.add_failure(tval2 == "DNE", "Did you drag in Temperature?")
tester = TestManager()
tester.add_test_list([t1, t2])
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)