Quiz3-DecisionStructures&BooleanLogic Flashcards

1
Q

In many languages == operator determines whether one variable has the same value as another variable. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The OR operator will evaluate to True only if both subexpressions are also True (T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In an expression with an OR operator, it does not matter which subexpression is true for the compound expression to be true. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A nested decision structure can be used to test more than one condition. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A nested decision structure can achieve the same logic as a case structure. (T/F)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The first line of a case structure starts with the word CASE, followed by the test expression. (T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

A decision structure will produce unpredictable results if the programmer does not use proper indentation in the pseudocode.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

An If-Then-Else statement must be used to write a single alternative decision structure.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The short-circuit evaluation is always performed with all expressions that contain any logical operators.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Decision structures and selection structures are completely different.(T/F)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The following statement will evaluate to True: (T/F)

(5 > 6) OR (12 < 14)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The following statement will evaluate to True: (T/F)

(5 > 6) AND (12 < 14)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In a flowchart, the _________ symbol indicates that some condition must be tested.

A

diamond

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What type of operator determines whether a specific relationship exists between two values?

A) relational

B) Boolean

C) Mathmatical

A

A) relational

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which operator is used in most languages to test if two operands DO NOT have the exact same value?

A

!=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A case structure is a _________ alternative decision structure.

A

Multiple alternative decision structure

17
Q

Which of the following is NOT a logical operator?

A) AND

B) OR

C) NOT

D) All are logical operators

A

D) All are logical operators

18
Q

Which of the following is NOT a logical operator?

A) <>

B) OR

C) AND

A

A) <>

19
Q

The ________ operator is a unary operator, which means it works with only one operand.

A

NOT

20
Q

If an expression is FALSE, the __________ operator will return TRUE.

A

NOT

21
Q

Which two logical operators perform short-circuit evaluation?

A

AND and OR

22
Q

In many languages, the case structure is called a ___________ statement.

A

Switch

23
Q

What would be displayed if the following pseudocode was coded and executed, with salary = 400?

If salary > 400 Then
Set bonus = 10
Set salary = salary + bonus
End If
Display Salary

A

400

24
Q

What would be displayed if the following pseudocode was coded and executed, with salary = 400?

If salary > 400 Then
Set bonus = 10
Set salary = salary + bonus
Else
Set salary = salary + salary*.20
End If
Display Salary

A

480
Set salary = 400 + (400.20)
400
.20 =80
400+80=480

25
Q

What would be displayed if the following pseudocode was coded and executed?

Declare String pet1 = “puppy”
Declare String pet2 = “kitten”
If pet1 == pet2 Then
Display “These animals are the same.”
Else
Display “These animals are different.”
End if

A

These animals are different.

26
Q

What would be displayed if the following pseudocode was coded and executed?

Declare String pet1 = “puppy”
Declare String pet2 = “kitten”
If pet1 > pet2 Then
Display “These animals are the same.”
Else
Display “These animals are different.”
End if

A

These animals are the same

p has a higher digit value than k based on how the programming HL stores characters. letters closest to A are less then letters closer to Z.

27
Q

What does the following expression evaluate to, given that
a = 3 and b = 6

(a == b) OR (b > a)

A

True

28
Q

What does the following expression evaluate to, given that
a = 3 and b = 6?

(a != b) AND (b > a)

A

True

29
Q

Which of the following expressions would check if a number, x, is between 90 and 100 inclusive?

A) x >= 90 OR x <= 100
B) x >= 90 AND x <= 100
C) x > 90 OR x < 100

A

B) x >= 90 AND x <= 100

30
Q

Which of the following expressions would check if a number, x, is outside range 90 - 100, inclusive (i.e, either less than 90 or greater than 100)?

A) x < 90 OR x > 100
B) x < 90 AND x > 100

A

A) x < 90 OR x > 100

31
Q

In the following pseudocode was coded and run, what would display, given that rate = 8?

Select rate
Case 10:
Display “A”
Case 9:
Case 8:
Display “B”
Case 7:
Case 6:
Display “C”
Default:
Display “Rating not possible.”
End Select

A

B

32
Q

If the following pseudocode was coded and run, what would display, given that rate = 9?

Select rate
Case 10:
Display “A”
Case 9:
Case 8:
Display “B”
Case 7:
Case 6:
Display “C”
Default:
Display “Rating not possible.”
End Select

A

B

33
Q

Given the following pseudocode, what would display if this pseudocode was coded and executed, given that
examGrade = 93
homeworkGrade = 87

If examGrade >= 90 AND homeWorkGrade >= 90 Then
Display “You are doing very well!”
Else If examGrade < 90 AND homeworkGrade >= 90 Tjem
Display “Study harder for the next exam.”
Else If the examGrade >= 90 AND homeworkGrade >= 90 Then
Display “See me for help with homework.”
Else
Display “Let’s talk about your grades.”
End If

A

See me for help with homework.

34
Q

Given the following pseudocode, what would display if this pseudocode was coded and executed, given that
examGrade = 73
homeworkGrade = 67

If examGrade >= 90 AND homeWorkGrade >= 90 Then
Display “You are doing very well!”
Else If examGrade < 90 AND homeworkGrade >= 90 Tjem
Display “Study harder for the next exam.”
Else If the examGrade >= 90 AND homeworkGrade >= 90 Then
Display “See me for help with homework.”
Else
Display “Let’s talk about your grades.”
End If

A

Let’s talk about your grades.