Checkpoints Chapter 2
Checkpoints Chapter 2
Ans: An informal language that has no syntax rules and is not meant
to be
compiled or executed. Instead, programmers use pseudocode to
create
models, or “mock-ups,” of programs.
Ans: A diagram that graphically depicts the steps that take place in
a program.
2.11 Which of the following are illegal variable names in Python, and why?
x
99bottles
july2009
theSalesFigureForFiscalYear
r&d
grade_report
2.12 Is the variable name Sales the same as sales? Why or why not?
2.17 You need the user of a program to enter a customer’s last name. Write a
statement
that prompts the user to enter this data and assigns the input to a variable.
2.18 You need the user of a program to enter the amount of sales for the
week. Write a
statement that prompts the user to enter this data and assigns the input to a
variable.
2.19 Complete the following table by writing the value of each expression in
the Value
Expressions Values column:
6+3*5 21
12 / 2 − 4 2
9 + 14 * 2 − 6 31
(6 + 2) * 3 24
14 / (11 − 4) 2
9 + 12 * (8 − 3) 69
2.20 What value will be assigned to result after the following statement
executes?
result = 9 // 2
Ans: 4
2.21 What value will be assigned to result after the following statement
executes?
result = 9 % 2
Ans: 1
Ans: If you do not want the print function to start a new line of
output when it
finishes displaying its output, you can pass the special argument
end = ' '
to the function.
2.23 How can you change the character that is automatically displayed
between
multiple items that are passed to the print function?
Ans: You can pass the argument sep= to the print function,
specifying the
desired character.
2.24 What is the '\n' escape character?
2.25 What does the + operator do when it is used with two strings?
Ans: 65.43
Ans: 987,654.13
2.28 What are three advantages of using named constants?