Presentation on theme: "Logical Operators Operators that can be used to create complex Boolean expressions and or not."— Presentation transcript:1 Show
2 Logical Operators Operators that can be used to create complex Boolean expressions and or not 3 The and
Operator Takes two Boolean expressions as operands
4 The or Operator Takes two Boolean expressions as operands
5 The not Operator Takes one Boolean expressions as operand and reverses its logical value Sometimes it may be necessary to place parentheses around an expression to clarify what you
are applying the not operator to Truth table for the not operator Value of the Expression Expression false true 6 Modified Loan Qualifier Program (and)
7 Modified Loan Qualifier Program (or)
8 Modified Loan Qualifier Program (or) 9 Checking Numeric Ranges
with Logical Operators
10 Boolean Variables Can be assigned to only one of two values, True or False Represented by bool data type Commonly used as
flags Signals when some condition exists in a program Flag set to False condition does not exist Flag set to True condition exists 11 Boolean Variable Examples 12 Determining the
State of the Turtle
13 Determining Turtle’s Heading 14 Determining If Pen is Down 15 Determining If Turtle Is Visible 16 Determining Pen and Fill Color
17 Determining the State of the Turtle 18 Determining Pen Size When you call
turtle.pensize() without passing an argument, the function returns the pen's current size as a string. Example of calling the function in an if statement: if turtle.pensize() < 3: turtle.pensize(3) 19 Determining Speed of Turtle
20 Hit The Target Example Type in an angle to point the turtle to hit the square
in the upper right Type in a force from 1 to 10 to reach the square Target is hit when inside the square Can a nested decision structure achieve the same logic as a case structure?A nested decision structure can achieve the same logic as a case structure. Correct! The first line of the case structure starts with the word CASE followed by the test expression. The If-Then-Else statement can be used to simplify a complex nested decision structure.
Can a nested decision structure be used to test more than one condition?The correct answer is true.
Both nested decision and case structure used to test multiple conditions. The individual can achieve the same result by applying the same logic with the help of a nested decision structure or a case structure.
What is a nested decision?The nesting of decision structures allows a program to sequentially determine the current state of a problem component under investigation. One might find an analogy to this process in games like "20 questions", where a person attempts to guess what another has in mind by asking a series of yes/no questions.
Which structure is a logical design that controls the order in which a set of statements executes control sequence module terminal none of these?A control structure is a logical design that controls the order in which a set of statements execute.
|