It depends on the size of the individual snake. A yearling could be 400 grams or 1200 grams... it all depends. How big is your snake?
I keep my ball pythons over 500 grams in 41qt adult size tubs. I think it would be fine to keep them in a 40 gallon as long as you have appropriate hides and cover. Black out 3 sides of the enclosure and offer at minimum 2 hides - though more would be better.
Sent from my SAMSUNG-SM-N920A using Tapatalk