how to run my python code on google cloud without fear of getting disconnected - an absolute beginner?
There are several options to keep your session running on the host machine even if it's disconnected, see for instance this: https://www.tecmint.com/keep-remote-ssh-sessions-running-after-disconnection/

Personally I use the screen command because I'm familiar with it but I think tmux is more recent.