Will password protecting a drive prevent ransomware encryptions and other virus infections?

Will password protecting a drive prevent ransomware encryptions and other virus infections?

Not if it is unlocked…