Yes, you can execute your code without defining any function at the top but for that, you need to import the script as a module.
You just need to write the following mentioned code at the top of your code:-
import module;
module.main()
To know more about this you can have a look at the following video tutorial:-