def commands_arduino(a,b): # a: command, b: times
# # Old - '%04d' % (42,)
# # New - '{:04d}'.format(42)
# # Output - 0042
commands = "".join(a for i in range(b))
if a == 'a': # left
result = 'a{:03d}'.format(round((5.625 * b)))
elif a == 'd': # right
result = 'd{:03d}'.format(round((5.625 * b)))
elif a == 'w': # forward
result = 'w{:03d}'.format(round(0.53125 * b))
elif a == 'x': # backward
result = 'x{:03d}'.format(round(0.53125 * b))
else:
result = 'quit'
return commands, result
What do you put in commands
in the above code?
I would appreciate it if you could tell me exactly what a{:03d}
means and what format
means!
© 2024 OneMinuteCode. All rights reserved.