Search Header Logo

Lesson 5 While Loops

Computers

6th - 8th Grade

Used 35+ times

Lesson 5 While Loops
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

12 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When is the best time to use a while loop in your code?

A. When you know exactly how many times you need the loop to repeat
B. When you have random elements in your puzzle with a repeating pattern
C. There are no identifiable patterns in a puzzle and you need simple commands
D. Whenever you are going to use a function in your coding solution

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

2. What is the difference between a while loop and a for loop?

A. For loops can use conditional statements and while loops cannot
B. While loops repeat a set number of times and for loops repeat until their condition    is false
C. For loops repeat a set number of times and while loops repeat until their condition is   false
D. For loops can be used in a function and while loops cannot

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a correct example of a while loop?

A. for i in 1…4 {   turnLeft()   moveForward()   toggleSwitch()   }
B. while isOnClosedSwitch {   toggleSwitch()   turnLeft()   moveForward()   }
D. if isOnClosedSwitch {   toggleSwitch()   turnLeft()   moveForward()
C. while i in 1…4 {   toggleSwitch()   turnLeft()   moveForward()   }

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is true about using a while loop in your code?

A. while loops can only have one condition [no additional conditions can be added]
 B. while loops stop running after their condition is false [Boolean]
C. while loops stop running after they repeat the number of times you assigned
 D. while loops are not as efficient as for loops

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a correct example of a while loop inside of a function?

A. func while switchAndToggle {   if isOnGem {     collectGem()   moveForward()   }   }
B. while switchAndToggle {   if isOnGem {   collectGem()   moveForward()   }   }
C. func switchAndToggle {   if isOnGem {   collectGem()   moveForward()   }   }
D. func collectAndMoveForward {   while isOnGem {   collectGem()   moveForward()   }   }

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How is a for loop more controlled than a while loop?

A. A for loop only repeats the number of times you tell it to
B. A for loop can be used inside of a function
C. A for loop can be repeated as many times as you use it in code
D. A for loop can contain more commands than a while loop

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a correct example of a for loop?

A. while for i in 1…4 {   moveForward()   collectGem()   }
B. func for i in 1…4 {   moveForward()   collectGem()   }
C. for i in 1…4 {   moveForward()   collectGem()   }
D. while isOnGem {   moveForward()   collectGem()   }

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers