Tuesday, February 3, 2015

Chapter 8 : Review Question

Q6 : What is unusual about Python’s design of compound statements?
A : Python uses indentation to specify compound statements. For example,
if x > y :
x = y
print “case 1″
equally indent statements are grouped as one compound statement.

Q7 : Under what circumstances must an F# selector have an else clause?
A : If the expression returns a value, it must have an else clause.

Q8 : What are the common solutions to the nesting problem for two-way selectors?
A : The common solution is to force an alternative semantics, by using compound statements.

Q9 : What are the design issues for multiple-selection statements?
A :
-What is the form and type of the control statement?
-How are the selectable segments specified?
-Is execution flow through the structure restricted to include just a single selectable segment?
-How are case values specified?
-What is done about unrepresented expression values?

Q10 : Between what two language characteristics is a trade-off made when deciding whether more than one selectable segment is executed in one execution of a multiple selection statement?
A : In Ada, the choice lists of the case statement must be exhaustive, so that there can be no unrepresented values in the control expression. In C++, unrepresented values can be caught at run time with the default selector. If there is no default, an unrepresented value causes the whole statement to be skipped.

No comments:

Post a Comment