you need to construct the command string with the values of b0, b1 and b2
>>> b0 = hex(12*12)[2:4]
>>> b1 = hex(5*12)[2:4]
>>> b2 = hex(100+27)[2:4]
>>> cmd = ' '.join(["amidi -p hw:1,0 -S", b0, b1, b2])
>>> cmd
'amidi -p hw:1,0 -S 90 3c 7f'
>>> cmd = f"amidi -p hw:1,0 -S {b0} {b1} {b2}"
>>> cmd
'amidi -p hw:1,0 -S 90 3c 7f'
>>> b0 = 0x90
>>> b1 = 0x3c
>>> b2 = 0x7f
>>> cmd = f"amidi -p hw:1,0 -S {b0:x} {b1:x} {b2:x}"
>>> cmd
'amidi -p hw:1,0 -S 90 3c 7f'
>>>
also note you don't need to convert the result from hex() to str, it's already str.
by the way it's better to use
subprocess module, e.g.
subprocess.run()
, as mentioned in the docs for os.system():
Quote:The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using this function. See the Replacing Older Functions with the subprocess Module section in the subprocess documentation for some helpful recipes.