2026–2027 – Complete Solutions & Answer Guide
All chapters covered
© 2024 Cengage. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible
f f f f f f f f f f f f f f f f f f
1
website, in whole or in part.
f f f f f
,SolutionandAnswerGuideForAll Chapters f f f f f f
LAMBERT, FUNDAMENTALS OF PYTHON: FIRST PROGRAMS, 3E, CY24, 9780357881019; CHAPTER 1,
F F F F F F F F F F
INTRODUCTION
F
TABLE OF CONTENTS F F
Exercise Solutions ........................................................................................................................................ 1
f
Exercise 1.1................................................................................................................................................ 1
f
Exercise 1.2................................................................................................................................................ 2
f
Exercise 1.3................................................................................................................................................ 3
f
Review Questions Answers .......................................................................................................................... 4
f f
Programming Exercises Solutions ............................................................................................................... 8
f f
Debugging Exercises Solutions .................................................................................................................... 8
f f
EXERCISE SOLUTIONS F
EXERCISE 1.1 F
1. List three common types of computing agents.
f f f f f f
Solution:
Human beings, desktop computers, cell phones f f f f f
2. Write an algorithm that describes the second part of the process of making change (counting out the coins and
f f f f f f f f f f f f f f f f f f
bills).
f
Solution:
There are various ways to do this, but here is one:
f f f f f f f f f f
Repeat
Select the largest unit of money that is less than or equal to the remaining change
f f f f f f f f f f f f f f f
Subtract this unit from the remaining change
f f f f f f f
Until the remaining change is 0 f f f f f
The collection of units selected represent the change
f f f f f f f
3. Write an algorithm that describes a common task, such as baking a cake.
f f f f f f f f f f f f
© 2024 Cengage. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible
f f f f f f f f f f f f f f f f f f
2
website, in whole or in part.
f f f f f
, Solution:
There are various ways to do this, but here is one:
f f f f f f f f f f
Preheat an oven to 375 degrees f f f f f
Add 1 cup of water and 1 egg to a mixing bowl
f f f f f f f f f f f
Beat the liquid mixture in the bowl until the ingredients are blended Add the
f f f f f f f f f f f f f
contents of a boxed cake mix to the mixing bowl
f f f f f f f f f f
Beat the mixture in the bowl until the ingredients are blended
f f f f f f f f f f
Pour the contents of the mixing bowl into a lightly greased cake pan Bake
f f f f f f f f f f f f f
the cake in the oven for 45 minutes
f f f f f f f f
4. Describe an instruction that is not well defined and thus could not be included as a step in an algorithm. Give
f f f f f f f f f f f f f f f f f f f f
an example of such an instruction.
f f f f f f
Solution:
Attempting to divide a number by 0 f f f f f f
5. In what sense is a laptop computer a general-purpose problem-solving machine?
f f f f f f f f f f
Solution:
A laptop computer is a general-purpose problem-solving machine because it is programmable and can solve any
f f f f f f f f f f f f f f f
problem for which there is an algorithm.
f f f f f f f
6. List four devices that use computers and describe the information that they process. (Hint: Think of the inputs
f f f f f f f f f f f f f f f f f
and outputs of the devices.)
f f f f f
Solution:
Digitalcamera—images, musicplayer—sound,cellphone—text, ATM—numbers
f f f f f f
EXERCISE 1.2 F
1. List two examples of input devices and two examples of output devices.
f f f f f f f f f f f
Solution:
Input devices—keyboard and mouse, output devices—monitor and speakers
f f f f f f f
2. What does the central processing unit (CPU) do?
f f f f f f f
Solution:
The CPU fetches, decodes, and executes instructions.
f f f f f f
3. Howis information represented in hardware memory?
f f f f f f
Solution:
Information is represented using binary notation, which in hardware is a pattern of voltage levels. f f f f f f f f f f f f f f
© 2024 Cengage. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible
f f f f f f f f f f f f f f f f f f
3
website, in whole or in part.
f f f f f
, 4. What is the difference between a terminal-based interface and a graphical user interface?
f f f f f f f f f f f f
Solution:
A terminal-based interface supports only the input and output of text with a keyboard and monitor. A graphical
f f f f f f f f f f f f f f f f f
user interface supports the output of images and the manipulation of them with a pointing device, the mouse.
f f f f f f f f f f f f f f f f f f
5. What role do translators play in the programming process?
f f f f f f f f
Solution:
A translator converts a program written in a high-level language (human readable and writable) to an equivalent
f f f f f f f f f f f f f f f f
program in a low-level language (machine readable and executable).
f f f f f f f f f
EXERCISE 1.3 F
1. Describe what happens when the programmer enters the string "Greetings!" in the Python shell.
f f f f f f f f f f f f f
Solution:
Python reads the string "Greetings!", evaluates it, and displays this string (including single quotes) in the
f f f f f f f f f f f f f f f
shell.
f
2. Write a line of code that prompts the user for their name and saves the user’s input in a variable called
f f f f f f f f f f f f f f f f f f f f
name.
Solution:
name= input("Enter your name: ")
f f f f f
3. What is a Python script?
f f f f
Solution:
A Python script is a complete Python program that can be run from a computer’s operating system.
f f f f f f f f f f f f f f f f
4. Explain what goes on behind the scenes when your computer runs a Python program.
f f f f f f f f f f f f f
Solution:
If the program has not already been translated, Python’s compiler translates it to byte code. The Python virtual
f f f f f f f f f f f f f f f f f
machine then executes this code.
f f f f f
© 2024 Cengage. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible
f f f f f f f f f f f f f f f f f f
4
website, in whole or in part.
f f f f f