10k-ohm resistor in chapter 2 of arduino projects book

No, there is No voltage on an input pin that is not connected to something. It only takes .000001Amp (1 microAmp, 1 uA) to change that input pin, so the merest of electrical disturbance can make it swing high & low - like the natural electrical field of a human body.
The 10K resistor draws any current that might be collected down to Ground.

A better way to connect an input is to use internal pullup resistor, and wire the switch to connect the pin to Gnd when pressed.
2 benefits - no extra resistor is needed - and you can't accidentally short 5V out to something.

pinMode (pinX, INPUT_PULLUP);
or
pinMode (pinX, INPUT);
digitalWrite (pinX, HIGH); // enable pullup resistor

then
if (digitalRead(pinX) == LOW){
// switch is pressed, do something
}
else {
// action to take if switch is not pressed
}

See also 14.2.6 in the '328P datasheet:
14.2.6 Unconnected Pins
If some pins are unused, it is recommended to ensure that these pins have a defined level. Even though most of
the digital inputs are disabled in the deep sleep modes as described above, floating inputs should be avoided to
reduce current consumption in all other modes where the digital inputs are enabled (Reset, Active mode and Idle
mode).
The simplest method to ensure a defined level of an unused pin, is to enable the internal pull-up. In this case, the
pull-up will be disabled during reset. If low power consumption during reset is important, it is recommended to use
an external pull-up or pull-down. Connecting unused pins directly to VCC or GND is not recommended, since this
may cause excessive currents if the pin is accidentally configured as an output.