## Lab03c Python programming III import rone, sys #### Tuples #### ##a = 4 ##b = 5 ##c = 6 ##q = (a, b, c) ##(q1, q2, q3) = q ##q1 ##q2 ##q3 ## ## ##def foo(x, y): ## t1 = x + y ## t2 = x - y ## t = (t1, t2) ## return t ## ##def use_foo(x, y) ## val = foo(x, y) ## print val ## ## (val1, val2) = val ## print val1, val2 ## ##use_foo(2, 1) ## ## ## ## #### Lists #### ## ##a = 1 ##b = 2 ##c = 3 ##this = True ##that = False ## ##print a, b, c ## ##l = [a, b, c] ## ##print l ## ##print l[0] ##print l[1] ## ## ##this = True ##that = False ## ##l.append(this) ##l.append(that) ## ##print l ## ## ##l = [1, 23, 5, 13, 12] ##sum = 0 ##for x in l: ## print x ## sum = sum + x ##print sum ## ## ## ## ## #### Execution Time #### ## ##import sys ##sys.time() ## ##wait for a bit ##sys.time() ## ## ## moves forward for the argument time ## arguments: time ## return: nothing ##def move_forward(time): ## time_start = sys.time() ## time_end = time_start + time ## while sys.time() < time_end: ## rone.motor_set_pwm('l', 65) ## rone.motor_set_pwm('r', 65) ## print sys.time() ## ## wait a bit before checking again ## sys.sleep(10) ## rone.motor_set_pwm('l', 0) ## rone.motor_set_pwm('r', 0) ## ##move_forward(1000) print('All done')