Python ch 4

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is a single alternative decision structure?

A decision structure that provides a single alternative path of execution. If the condition that is being tested is true, the program takes the alternative path.

How does a dual alternative decision structure work?

A dual alternative decision structure has two possible paths of execution; one path is taken if a condition is true, and the other path is taken if the condition is false.

What is a control structure?

A logical design that controls the order in which a set of statements execute

What is a flag variable?

A variable that signals when some condition exists in the program

What is a Boolean expression?

An expression that can be evaluated as either true or false

A(n) __________ expression has a value of either true or false.

Boolean

T/F A program can be made of only one type of control structure. You cannot combine structures.

F

T/F A single alternative decision structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.

F

T/F You can write any program using only sequence structures.

F

What is a decision structure?

It is a program structure that can execute a set of statements only under certain circumstances.

What is a compound Boolean expression?

It is an expression that is created by using a logical operator to combine two Boolean subexpressions.

Explain how short-circuit evaluation works with the and and or operators.

The and operator: If the expression on the left side of the and operator is false, the expression on the right side will not be checked. The or operator: If the expression on the left side of the or operator is true, the expression on the right side will not be checked.

What values can you assign to a bool variable?

True or False

When you write an if-else statement, under what circumstances do the statements that appear after the else clause execute?

When the condition is false

What types of relationships between values can you test with relational operators?

You can determine whether one value is greater than, less than, greater than or equal to, less than or equal to, equal to, or not equal to another value.

A compound Boolean expression created with the __________ operator is true only if both of its subexpressions are true.

and

A __________ structure can execute a set of statements only under certain circumstances.

decision

A(n) _________ structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.

dual alternative decision

A compound Boolean expression created with the _________ operator is true if either of its subexpressions is true.

either

A ___________ is a Boolean variable that signals when some condition exists in the program.

flag

You use a(n) __________ statement to write a single alternative decision structure.

if

What statement do you use in Python to write a dual alternative decision structure?

if-else

You use a(n) __________ statement to write a dual alternative decision structure.

if-else

and, or, and not are __________ operators.

logical

The ___________ operator takes a Boolean expression as its operand and reverses its logical value.

not

The symbols >, <, and == are all __________ operators.

relational

A __________ structure provides one alternative path of execution.

single alternative decision

T/F a compound Boolean expression created with the AND operator is true only when both subexpressions are true

t

T/F a decision structure can be nested inside another decision structure

t


Set pelajaran terkait

Chapter 17: Inflation, Unemployment, and Federal Reserve Policy

View Set

Chapter 10 Flexibility, Empowerment, and Partnership

View Set

Life 5 (11, 13 & 28) Fixed & Variable Contracts - including retirement

View Set

Questions and Answers from ALL of the Canvas Tests

View Set

OB Chapt 23 Quiz Newborn With Special Needs Quiz Questions

View Set

Lesson 5 - World War I and Post War Culture

View Set

NUTR 223 (UNR) NC Connect: High Protein Diet

View Set