A virus is a self-replicating program that attaches itself to a host file or program. It can spread by copying itself and infecting other files or programs on the same computer or network. Viruses often require user interaction or the execution of an infected file to propagate.
A worm is a standalone program that can replicate itself and spread over a network without the need for user interaction. Worms typically exploit vulnerabilities in operating systems, network protocols, or applications to gain unauthorized access to computers or servers.