Nutrition by the numbers?

I'm a newbie and suppose this question has been asked before. How does one know how much to eat by the numbers? Say a person swims four miles a week, lifts weights and rides bike. Would it be safe to assume they could eat 4000 calories a day? I'm trying to take a scientific approach to my training but often feel I don't under stand the basics.  As a side note I'm one year cancer free and have worked very hard to get my weight down and strength back. Getting back into swimming has been the single best thing I've done for my recovery. Started swimming again 01/04/24 and am going to swim a 2.4 mile open Water event in July. Any advice from you would be greatly appreciated

Thanks

Charlie