I don't know if this is the correct form
num=8
num2=10
num=subprocess.check_output("num/2", shell=True)
num2=subprocess.check_output("num2+7", shell=True)
'num/2' is just the string "num/2". If you want it to be the variable num, you need to interpolate it, e.g., with an f-string f'{num}/2'.
Also if you're trying to use bash for division, you'll have to add double parentheses for arithmetic expansion:
>>> num = 8
>>> subprocess.check_output(f'echo $(( {num}/2 ))', shell=True)
b'4\n'
Python first interpolates {num} into 8, and then sends echo $(( 8/2 )) to shell.
subprocess.check_output("{}/2".format(num), shell=True)