Learn Python the Hard Way Exercise 32-33: For loops, lists, and while loops.

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

How would you print out a list (called numbers) in list format?

print(numbers)

What would a for loop of for i in range(1, 3): print(i) output and why?

1, 2 because python is exclusive, not inclusive unless specified

What are the general rules for while loops?

1. In general, try and use a for loop 2. Make sure that you have a false condition 3. When in doubt print the test variable at the top/bottom of the loop

What can we add to lists?

Chars, strings, or numbers

What's the difference between a for loop and a while loop?

a for loop can only iterate over a specific collection of things, a while loop can do any kind of looping you want.

How do we adding numbers 0 - 5 to the empty list elements?

for i in range(0, 6): elements.append(i)


Kaugnay na mga set ng pag-aaral

Chapter 17: The Cardiovascular System

View Set

Ch 7- Business Strategy: Innovation and Entrepreneurship

View Set

Final Back of Book Questions: Astha (258-268), Ashley (269-279), Aarti (280-290)

View Set

Chapter 11 - Network Performance and Recovery

View Set