A lock is a mechanical or electronic device designed to secure doors, containers, or other objects by restricting access to authorized individuals. Locks typically consist of two main components: a locking mechanism and a key or code for operation. Mechanical locks often use a cylinder and pin system, while modern electronic locks may use keypads, biometric sensors, or remote access technology. Locks are widely used for safety, privacy, and protection of valuable items, ensuring unauthorized access is prevented.