Solution Manual for Starting Out with Python, Global Edition, 4th Edition
Preview Extract
Chapter 2
Multiple Choice
1.
c
2.
b
3.
d
4.
b
5.
a
6.
c
7.
a
8.
b
9.
d
10.
a
11.
b
12.
d
13.
b
14.
a
15.
a
16.
c
17.
a
18.
b
19.
a
20.
b
21.
b
22.
b
True or False
1.
False
2.
True
3.
False
4.
True
5.
False
Short Answer
1
Interview the customer
2.
Pseudocode, an informal language with no syntax rules, is intended to establish and
communicate the design of a program. Actual code must adhere to the syntax of the
language it is written in, and is used to implement a program.
3.
(1) Input is received.
(2) Some process is performed on the input.
(3) Output is produced.
4.
Variable names must adhere to the naming rules of the language, such as not being a
key word of the language, beginning with a letter, and not containing a space. Variable
names should preferably reflect the nature of the data that they reference to make the
variableโs purpose clear.
5.
Floating point division returns a floating point number that may include fractions.
Integer division returns an integer and ignores any fractional part of the division result.
6.
A magic number is an unexplained value that appears in a program’s code. Magic
numbers can be problematic, for a number of reasons. First, it can be difficult for
someone reading the code to determine the purpose of the number. Second, if the magic
number is used in multiple places in the program, it can take painstaking effort to change
the number in each location, should the need arise. Third, you take the risk of making a
typographical mistake each time you type the magic number in the program’s code.
7.
The named constant makes the program more self-explanatory. In a math statement, it is
evident that PI represents the value of pi. Another advantage to using the named
constant is that widespread changes can easily be made to the program. Letโs say the
value of pi appears in several different statements throughout the program. If you need
to change the number of decimal places of precision used with the number, the
initialization value in the declaration of the named constant is the only value that needs
to be modified. For example, to use only two decimal places of precision, the declaration
can be changed to:
PI = 3.14
The new value of 3.14 will then be used in each statement that includes the PI constant.
Another advantage to using the named constant is that it helps to prevent the
typographical errors that are common when using magic numbers. For example, if you
accidentally type 31.4159 instead of 3.14159 in a math statement, the program will
calculate the wrong value. However, if you misspell PI, the Python interpreter will
display a message indicating that the name is not defined.
Algorithm Workbench
1.
age = int(input(‘Enter your age: ‘))
2.
color = input(‘Enter your favorite color: ‘)
3.
a.
b.
c.
d.
b = a + 2
a = b * 4
b = a / 3.14
a = b โ 8
4.
a.
b.
c.
d.
12
4
2
6
e.
2
5.
product = 10 * 15
6.
due = total โ down_payment
7.
total = subtotal * 0.15
8.
11
9.
5
10.
print(format(sales, ‘.2f))
11.
print(format(number, ‘,.1f’))
12.
$X
O
X
O
X
O
X
O
X
$
13.
turtle.circle(75)
14.
turtle.fillcolor(‘blue’)
turtle.begin_fill()
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.end_fill()
15.
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.penup()
turtle.left(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(30)
turtle.setheading(0)
turtle.pendown()
turtle.fillcolor(‘red’)
turtle.begin_fill()
turtle.circle(80)
turtle.end_fill()
Document Preview (4 of 1508 Pages)
User generated content is uploaded by users for the purposes of learning and should be used following SchloarOn's honor code & terms of service.
You are viewing preview pages of the document. Purchase to get full access instantly.
-37%
Solution Manual for Starting Out with Python, Global Edition, 4th Edition
$18.99 $29.99Save:$11.00(37%)
24/7 Live Chat
Instant Download
100% Confidential
Store
Alexander Robinson
0 (0 Reviews)
Best Selling
The World Of Customer Service, 3rd Edition Test Bank
$18.99 $29.99Save:$11.00(37%)
Chemistry: Principles And Reactions, 7th Edition Test Bank
$18.99 $29.99Save:$11.00(37%)
Test Bank for Hospitality Facilities Management and Design, 4th Edition
$18.99 $29.99Save:$11.00(37%)
Solution Manual for Designing the User Interface: Strategies for Effective Human-Computer Interaction, 6th Edition
$18.99 $29.99Save:$11.00(37%)
Data Structures and Other Objects Using C++ 4th Edition Solution Manual
$18.99 $29.99Save:$11.00(37%)
2023-2024 ATI Pediatrics Proctored Exam with Answers (139 Solved Questions)
$18.99 $29.99Save:$11.00(37%)