On Windows, it’s simple. WinKey + L is all you need to prevent unscrupulous people from taking over your computer when you’re away.
On a Mac, however, the lock feature is hidden within a utility called Keychain Access. Besides being able to lock your screen, Keychain also stores passwords that you use on the computer and online. To enable screen locking: