Please (re)search before posting/asking.
Things like this have already been explained multiple times.

Yes, avast can and does protect you from certain ransomware.