4.1 A decision structure allows a program to perform actions only under certain conditions – also known as selection structures. In its simplest form a specific action is performed only if a certain condition exists. If the condition does not exist the action is not performed. Single alternative decision structure – because it provides only one alternative path of execution. If the condition In the diamond symbol is true we take the alternative path. Otherwise we exit the structure. Writing a Decision Structure in Pseudocode If condition Then Statement Statement Statement End If Boolean Expressions and Relational Operators Show
Checkpoint Dual alternative decision structure – has two possible paths of execution – one path is taken if a condition is true and other path is taken if the condition is false. Checkpoint 4.3 Comparing Strings Checkpoint 4.4 Nested Decision Structures The If-Then-Else If Statement Insert as many Else If clauses as necessary Checkpoint This preview shows page 1 - 4 out of 25 pages. Checkpoint Questions4.1 What is a control structure? Get answer to your question and much more 4.2 What is a decision structure? Get answer to your question and much more 4.3 What is a single alternative decision structure? Get answer to your question and much more 4.4 What is a Boolean expression? Get answer to your question and much more 4.5 What types of relationships between values can you test with relational operators? Get answer to your question and much more 4.7 Write a pseudocodeIf-Thenstatement that assigns 0.2 tocommissionifsalesis greater thanor equal to 10,000. Get answer to your question and much more Display “Commission has been applied” Get answer to your question and much more 4.8 How does a dual alternative decision structure work? Get answer to your question and much more 4.9 What statement do you use in pseudocode to write a dual alternative decision structure? Get answer to your question and much more 4.10 When you write anIf-Then-Elsestatement, under what circumstances do the statements thatappear betweenElseandEnd Ifexecute? Get answer to your question and much more 4.11 If the following pseudocode were an actual program, what would it display?Program:If “z” < “a” ThenDisplay “z is less than a.”ElseDisplay “z is not less than a.”End IfProgram Output:z is not less than a.4.12 If the following pseudocode were an actual program, what would it display?Program:Declare String s1 = “New York”Declare String s2 = “Boston”If s1 > s2 ThenDisplay s2Display s1ElseDisplay s1 Display s2End IfProgram Output:s1s24.13 How does a dual alternative decision structure work? Get answer to your question and much more 4.14 What statement do you use in pseudocode to write a dual alternative decision structure? Get answer to your question and much more 4.15 When you write anIf-Then-Elsestatement, under what circumstances do the statements thatappear between theElse Clauseand theEnd Ifclause execute? Upload your study docs or become a Course Hero member to access this document Upload your study docs or become a Course Hero member to access this document End of preview. Want to read all 25 pages? Upload your study docs or become a Course Hero member to access this document Tags Expression, relational operator, Switch statement Which structure determines the order in which a set of statements executes?A control structure is a logical design that controls the order in which a set of statements execute.
Which of the following is the correct If clause to use to determine whether choice is other than 10?Review of Python Chapter 2. What is the structure that causes a statement or a set of statements to execute repeatedly?A repetition structure causes a statement or set of statements to execute repeatedly. Repetition structures are used to perform the same task over and over. A condition-controlled loop uses a Boolean (true/false) condition to control the number of times that it repeats.
When you write an if then else statement Under what circumstances do the statements that appear between the else clause and the end if clause execute?In an If-Then-Else statement, the statements between Else and End If would execute only if the condition for the If portion did not evaluate as true. See the answer to 4.10 for examples.
|