Py4e: Chapter 5

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

Which reserved word indicates the start of an "indefinite" loop in Python?

while

What does the continue statement do?

Jumps to the "top" of the loop and starts the next iteration

What will the following code print out? smallest_so_far = -1 for the_num in [9, 41, 12, 3, 74, 15] : if the_num < smallest_so_far : smallest_so_far = the_num print(smallest_so_far)

-1

What does the following Python program print out? tot = 0 for i in [5, 4, 3, 2, 1] : tot = tot + 1 print(tot)

5

What does the break statement do?

Exits the currently executing loop

What is a good description of the following bit of Python code? zork = 0 for thing in [9, 41, 12, 3, 74, 15] : zork = zork + thing print('After', zork)

Sum all the elements of a list

What is wrong with this Python loop: n = 5 while n > 0 : print(n) print('All done')

This loop will run forever

What is the iteration variable in the following Python code: friends = ['Joseph', 'Glenn', 'Sally'] for friend in friends : print('Happy New Year:', friend) print('Done!')

friend

What is a good statement to describe the is operator as used in the following if statement: if smallest is None : smallest = value

not Looks up 'None' in the smallest variable if it is a string orifThe if statement is a syntax error

How many times will the body of the following loop be executed? n = 0 while n > 0 : print('Lather') print('Rinse') print('Dry off!')

not this is an indefinite loop


Set pelajaran terkait

4 - (Questions) Life Insurance Policies - Provisions, Options and Riders

View Set

digestive system (extra questions)

View Set

Peds Exam 3- Intracranial Regulation

View Set

INEQUALITY THEOREM IN ONE TRIANGLE PART 2

View Set

Chapter 10: Fitness Goal Setting and Leadership

View Set

LWTech Psychology 100 Test 3 Review

View Set