Physical Review B 57, 4872 [1998]) Energetics and quantized conductance in jellium-modeled nanowires are investigated using the local-density-functionalbased shell correction method, extending our previous study of uniform-in-shape wires [C. Yannouleas and U. Landman, J. Phys. Chem. B 101, 5780 (1997)] to wires containing a variable-shaped constricted region. The energetics of the wire (sodium) as a function of the length of the volumeconserving, adiabatically shaped constriction, or equivalently its minimum width, leads to formation of self-selecting magic wire configurations, i.e., a discrete configurational sequence of enhanced stability, originating from quantization of the electronic spectrum, namely, formation of transverse subbands due to the reduced lateral dimensions of the wire. These subbands are the analogs of shells in finite-size, zero-dimensional fermionic systems, such as metal clusters, atomic nuclei, and 3 He clusters, where magic numbers are known to occur. These variations in the energy result in oscillations in the force required to elongate the wire and are directly correlated with the stepwise variations of the conductance of the nanowire in units of 2e 2 /h. The oscillatory patterns in the energetics and forces, and the correlated stepwise variation in the conductance are shown, numerically and through a semiclassical analysis, to be dominated by the quantized spectrum of the transverse states at the narrowmost part of the constriction in the wire.