Deck 5: Working With Loops

Full screen (f)
exit full mode
Question
Ruby provides a number of different loop methods belonging to different classes. These methods simplify loop construction and help to eliminate the chance of errors that can happen when working with language looping constructs.
Use Space or
up arrow
down arrow
to flip the card.
Question
Loops can be used to collect and process an unlimited amount of user input.
Question
Loop modifiers are perfect for situations where you need to repeat the execution of multiple statements.
Question
One limitation of loops is that they are not well suited to the development of scripts that need to be replayed over and over again.
Question
Loops help reduce the size of scripts making them easier to develop and maintain.
Question
The while modifier evaluates a Boolean expression and then conditionally executes the statement to which is has been appended as long as that condition remains true.
Question
When combined with conditional logic, loops provide the basis for developing the programming logic needed to process and validate user input.
Question
Loops provide you with the ability to repeat a set of statements over and over again as many times as necessary to perform a particular task.
Question
Loop modifiers are expressions appended to the end of Ruby statements, which are then repeatedly executed until a specified condition is met.
Question
An array is an indexed collection of items stored as a list.
Question
A feature unique to the for…in loop is that it is built to automatically repeat once for every element stored in an array.
Question
The until modifier repeatedly executes the statement to which it has been appended for as long as a specified condition remains true.
Question
Loop methods are language commands that are part of the set of built-in Ruby language constructions.
Question
The while loop is a loop that executes as long as a tested condition continues to evaluate as false.
Question
Language constructs are a category of loop that is associated with specific objects.
Question
The loop method is designed to be executed a given number of times.
Question
Using a minimum amount of code, loops facilitate the development of scripts that can process huge amounts of data. However, the cost of this processing efficiency comes at a price in terms of additional code statements.
Question
When working with the while or until loops, the do or : are mutually exclusive and can be omitted if the loop is spread out over more than one line.
Question
The while loop is specifically designed to facilitate the process of arrays
Question
A loop modifier is an expression added to the end of another Ruby statement that causes the execution of that statement as a loop.
Question
The each method is a very commonly used looping method. This method is supported by a number of different Ruby classes, including all of the following except ____.

A) The Array class
B) The Dir class
C) The String class
D) The Range class
Question
The retry method facilitates which of the following actions?

A) Terminates the execution of a loop
B) Repeats the current loop execution without evaluating the condition or iterating
C) Stops the current iteration of the loop and immediately begins a new iteration
D) Restarts the loop from the beginning, resetting the value of the iterator
Question
The times method is used to execute ____.

A) A code block a specific number of times
B) An individual code statement once for each item stored in an array
C) A code block for as long as a specified condition evaluates as true
D) None of the above
Question
The redo method facilitates which of the following actions?

A) Terminates the execution of a loop.
B) Repeats the current loop execution without evaluating the condition or iterating.
C) Stops the current iteration of the loop and immediately begins a new iteration.
D) Restarts the loop from the beginning, resetting the value of the iterator.
Question
The downto method iterates a predetermined number of times, starting at a specified integer value and counting down to whatever integer value is passed to it.
Question
The each method automatically iterates once for each item stored in the array.
Question
The for...in loop is designed to process collections of data, including:

A) Arrays
B) Ranges
C) Both A and B
D) Neither A or B
Question
The until loop is the opposite of the while loop. Instead of looping while a tested expression remains true, the until loop executes until ____.

A) The tested condition becomes true
B) The tested condition becomes false
C) The end of an array is reached
D) None of the above
Question
The step method is used to set up loops that execute a predefined number of times.
Question
Which of the following is true regarding the while or until loops?

A) It is the programmer's responsibility to specify a variable that will be used to control how many times the loop iterates.
B) It is the programmer's responsibility to determine how many times the loop repeats.
C) It is the programmer's responsibility to supply an expression for tracking the last element processed in the array and to increment its value at the end of each execution of the loop.
D) All of the above
Question
Ruby's built-in language looping constructions include which of the following?

A) while
B) until
C) for
D) All of the above
Question
Loops allow for the development of programming logic that can perform all of the following except ____.

A) Be repeatedly executed
B) Use a minimum number of controlling statements to control the execution of embedded statements
C) Analyze input and determine its validity
D) All of the above
Question
Ruby range operator ( .. ) provides the ability to do which of the following?

A) Generate a random number within a specified range
B) Display a range of consecutive letters or numbers
C) Iterate over a specified range of values
D) None of the above
Question
A loop is a collection of statements that ____.

A) Facilitate the processing of large text files
B) Facilitate the collection of unlimited amounts of user input
C) Provide the ability to develop scripts that can repeat the execution of any number of commands.
D) All of the above
Question
The next method facilitates which of the following actions?

A) Terminates the execution of a loop.
B) Repeats the current loop execution without evaluating the condition or iterating
C) Stops the current iteration of the loop and immediately begins a new iteration.
D) Restarts the loop from the beginning, resetting the value of the iterator.
Question
Ruby provides you with access to many different types of loops, which can be organized broadly as ____.

A) Language constructs
B) Modifiers
C) Methods
D) All of the above
Question
Which of the following is not a loop modifier supported by Ruby?

A) while
B) each
C) until
D) None of the above
Question
An iterator is a variable used to process the contents of a list of items.
Question
The upto method is provided by the String class.
Question
A(n) ____ loop is a loop that is set up so it never stops executing, unnecessarily using computer resources.

A) Iterative
B) Executive
C) Endless
D) Closed
Question
Which of the following loops supports two distinct forms of syntax?

A) while
B) until
C) loop
D) None of the above
Question
Ruby provides programmers with a number of different ways of altering a loop's execution, including all of the following methods except ____.

A) break
B) redo
C) redo
D) retry
Question
The ____ method stops the current iteration of the loop and immediately begins a new iteration. However, before the new iteration occurs, the loop condition is evaluated.

A) next
B) after
C) before
D) None of the above
Question
The break method facilitates which of the following actions?

A) Terminates the execution of a loop.
B) Repeats the current loop execution without evaluating the condition or iterating.
C) Stops the current iteration of the loop and immediately begins a new iteration.
D) Restarts the loop from the beginning, resetting the value of the iterator.
Question
The ____ method forces a loop to repeat only after evaluating its condition and without iterating.

A) next
B) after
C) before
D) None of the above
Question
Ruby supports different categories of loops, including which of the following?

A) Language constructs
B) Modifiers
C) Methods
D) All of the above
Question
Loops created using the ____ method run forever unless you provide a way to terminate them.

A) while
B) downto
C) loop
D) None of the above
Question
The break command provides the ability to ____.

A) Terminate the execution of a loop at any time.
B) Temporarily pause script execution
C) Place a script in debug mode
D) None of the above
Question
The loop method belongs to the ____.

A) Kernel class
B) Integer class
C) Array class
D) None of the above
Question
The step method works with which of the following classes?

A) The Float and Integer classes.
B) The String and Kernal classes.
C) The Array and Dir classes
D) The Range class
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Working With Loops
1
Ruby provides a number of different loop methods belonging to different classes. These methods simplify loop construction and help to eliminate the chance of errors that can happen when working with language looping constructs.
True
2
Loops can be used to collect and process an unlimited amount of user input.
True
3
Loop modifiers are perfect for situations where you need to repeat the execution of multiple statements.
False
4
One limitation of loops is that they are not well suited to the development of scripts that need to be replayed over and over again.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
Loops help reduce the size of scripts making them easier to develop and maintain.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
The while modifier evaluates a Boolean expression and then conditionally executes the statement to which is has been appended as long as that condition remains true.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
When combined with conditional logic, loops provide the basis for developing the programming logic needed to process and validate user input.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
Loops provide you with the ability to repeat a set of statements over and over again as many times as necessary to perform a particular task.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
Loop modifiers are expressions appended to the end of Ruby statements, which are then repeatedly executed until a specified condition is met.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
An array is an indexed collection of items stored as a list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
A feature unique to the for…in loop is that it is built to automatically repeat once for every element stored in an array.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
The until modifier repeatedly executes the statement to which it has been appended for as long as a specified condition remains true.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
Loop methods are language commands that are part of the set of built-in Ruby language constructions.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
The while loop is a loop that executes as long as a tested condition continues to evaluate as false.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
Language constructs are a category of loop that is associated with specific objects.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
The loop method is designed to be executed a given number of times.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
Using a minimum amount of code, loops facilitate the development of scripts that can process huge amounts of data. However, the cost of this processing efficiency comes at a price in terms of additional code statements.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
When working with the while or until loops, the do or : are mutually exclusive and can be omitted if the loop is spread out over more than one line.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
The while loop is specifically designed to facilitate the process of arrays
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
A loop modifier is an expression added to the end of another Ruby statement that causes the execution of that statement as a loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
The each method is a very commonly used looping method. This method is supported by a number of different Ruby classes, including all of the following except ____.

A) The Array class
B) The Dir class
C) The String class
D) The Range class
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
The retry method facilitates which of the following actions?

A) Terminates the execution of a loop
B) Repeats the current loop execution without evaluating the condition or iterating
C) Stops the current iteration of the loop and immediately begins a new iteration
D) Restarts the loop from the beginning, resetting the value of the iterator
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
The times method is used to execute ____.

A) A code block a specific number of times
B) An individual code statement once for each item stored in an array
C) A code block for as long as a specified condition evaluates as true
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
The redo method facilitates which of the following actions?

A) Terminates the execution of a loop.
B) Repeats the current loop execution without evaluating the condition or iterating.
C) Stops the current iteration of the loop and immediately begins a new iteration.
D) Restarts the loop from the beginning, resetting the value of the iterator.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
The downto method iterates a predetermined number of times, starting at a specified integer value and counting down to whatever integer value is passed to it.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
The each method automatically iterates once for each item stored in the array.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
The for...in loop is designed to process collections of data, including:

A) Arrays
B) Ranges
C) Both A and B
D) Neither A or B
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
The until loop is the opposite of the while loop. Instead of looping while a tested expression remains true, the until loop executes until ____.

A) The tested condition becomes true
B) The tested condition becomes false
C) The end of an array is reached
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
The step method is used to set up loops that execute a predefined number of times.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following is true regarding the while or until loops?

A) It is the programmer's responsibility to specify a variable that will be used to control how many times the loop iterates.
B) It is the programmer's responsibility to determine how many times the loop repeats.
C) It is the programmer's responsibility to supply an expression for tracking the last element processed in the array and to increment its value at the end of each execution of the loop.
D) All of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
Ruby's built-in language looping constructions include which of the following?

A) while
B) until
C) for
D) All of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
Loops allow for the development of programming logic that can perform all of the following except ____.

A) Be repeatedly executed
B) Use a minimum number of controlling statements to control the execution of embedded statements
C) Analyze input and determine its validity
D) All of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
Ruby range operator ( .. ) provides the ability to do which of the following?

A) Generate a random number within a specified range
B) Display a range of consecutive letters or numbers
C) Iterate over a specified range of values
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
A loop is a collection of statements that ____.

A) Facilitate the processing of large text files
B) Facilitate the collection of unlimited amounts of user input
C) Provide the ability to develop scripts that can repeat the execution of any number of commands.
D) All of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
The next method facilitates which of the following actions?

A) Terminates the execution of a loop.
B) Repeats the current loop execution without evaluating the condition or iterating
C) Stops the current iteration of the loop and immediately begins a new iteration.
D) Restarts the loop from the beginning, resetting the value of the iterator.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
Ruby provides you with access to many different types of loops, which can be organized broadly as ____.

A) Language constructs
B) Modifiers
C) Methods
D) All of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
Which of the following is not a loop modifier supported by Ruby?

A) while
B) each
C) until
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
An iterator is a variable used to process the contents of a list of items.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
The upto method is provided by the String class.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
A(n) ____ loop is a loop that is set up so it never stops executing, unnecessarily using computer resources.

A) Iterative
B) Executive
C) Endless
D) Closed
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
Which of the following loops supports two distinct forms of syntax?

A) while
B) until
C) loop
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
Ruby provides programmers with a number of different ways of altering a loop's execution, including all of the following methods except ____.

A) break
B) redo
C) redo
D) retry
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
The ____ method stops the current iteration of the loop and immediately begins a new iteration. However, before the new iteration occurs, the loop condition is evaluated.

A) next
B) after
C) before
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
The break method facilitates which of the following actions?

A) Terminates the execution of a loop.
B) Repeats the current loop execution without evaluating the condition or iterating.
C) Stops the current iteration of the loop and immediately begins a new iteration.
D) Restarts the loop from the beginning, resetting the value of the iterator.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
The ____ method forces a loop to repeat only after evaluating its condition and without iterating.

A) next
B) after
C) before
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
Ruby supports different categories of loops, including which of the following?

A) Language constructs
B) Modifiers
C) Methods
D) All of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
Loops created using the ____ method run forever unless you provide a way to terminate them.

A) while
B) downto
C) loop
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
The break command provides the ability to ____.

A) Terminate the execution of a loop at any time.
B) Temporarily pause script execution
C) Place a script in debug mode
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
The loop method belongs to the ____.

A) Kernel class
B) Integer class
C) Array class
D) None of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
The step method works with which of the following classes?

A) The Float and Integer classes.
B) The String and Kernal classes.
C) The Array and Dir classes
D) The Range class
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.