M5 Post - While Loops

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

count = 1 while count >= 1: print("loop") count +=1 What is the output from running the above code most like?

"loop" (infinite times)

x = 0 while True: if x < 10: print('run forever') x += 1 else: break What is the output from running the above code most like?

"run forever" (10 times)

time = 3 while True: print('time is', time) if time == 3: time = 4 else: break What is the output from running the above code most like?

"time is 3" & "time is 4"

What will be displayed by the following code? count = 0 while count < 5: print("Hello", end = " ") count +=1

Hello Hello Hello Hello Hello

Which of the following statements is true?

Python variables are case sensitive

while 3 < 5: is a forever loop just like while True is

True

while True: will loop forever but can be interrupted using the Python keyword "break" inside the loop.

True

answer = "" while answer.isalpha() == False: answer = input("enter last name: ") When will it exit the while loop?

When only letters are entered at the input prompt

The keyword that interrupts the loop is ____.

break

In a loop, a(n) ____, which is either true or false, determines whether the computer will execute the loop again.

condition

A(n) ____-controlled loop requires that you initialize a variable before the loop.

counter

Which is not a possible "infinity/infinite" loop?

while 0 > 1:

An infinite loop is a loop:

whose condition is always true.


Set pelajaran terkait

Chapter 32-Pediatric Emergencies

View Set

Chapter 7: Business Torts and product liability

View Set

Dual Credit Microbiology Final: Chapters 1-10

View Set

Cambridge Vocabulary For IELTS Unit 6, Effective communication

View Set

Accounting 1 - Ch 5 & 6: Journalizing and Posting

View Set

Chapters 1-4 Quiz Questions Network+

View Set