CodeHs Unit 5

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

How many lines will this program print? while True: print("hi")

an infinite number of lines

If I am using the following condition in my program: while True: which keyword should I use to make sure I don't create an infinite loop?

break

Which of the following best describes the purpose of a for loop?

A for loop is for doing something a fixed number of times.

Which Python keyword skips back to the beginning of a loop?

continue

Which of the following does not properly nest control structures?

count = 10 for i in range(3): if count > 0: print(i) else: print(count)

Which of the following programs prints ten lines?

for i in range(10): print("hi")

Which of the following for loops would print the following numbers? 3 5 7 9

for i in range(3, 10, 2): print(i)

Three of the for loops below will provide identical values for i. Which for loop will provide values that do not match the others?

for i in range(5, 0, 1):

Which of the following for loops would print the following numbers? 0 1 2 3 4 5

for i in range(6): print(i)

What does the following program print? for i in range(2): for j in range(2): print(i + j)

0 1 1 2

What is the value of num when this loop completes? num = 0 for i in range(2, 8, 2): num = num + i

12

How many lines will this program print? x = 10 while x > 0: print(x) x = x - 3

4

Which of the following for loops will give the same values for i as the loop below? for i in range(10):

for i in range(0, 10):


Set pelajaran terkait

Nursing Management: Patients With Endocrine Disorders

View Set

Primerica: life insurance basics

View Set

GSCI-037-S003: Eighth-Grade Science, Part 2 (Online) Review Quiz 1 and Review Quiz 2

View Set

Biology 1610 Final Exam Test Prep

View Set

Sociology - Aging and the Elderly - Chpt 14 - Exam 3

View Set

Personal Finance Chptr 1+2 ( time value of money, liquidity, financial planning)

View Set

Puritan and Revolutionary Literature Quiz AP Lang

View Set