Computer Science Pathway, Mrs. Williams



CS Principles Python FOR/WHILE Loops Test Review SheetDirections: Use the For/While loop PowerPoint, and CodeHS to complete the review questions below.T or F: The statements in the body of a for loop are indentedT or F: When the step value in a range function is a negative value, the sequence of numbers are in ascending orderWhen looping, each repetition of the action is known as a pass or a(n) ____________.In python, a ____ ends the loop headerList 6 common Boolean comparison operators: __________________________Predict the output for the following program:for i in range (5): print (i) output: _________________________ 7. Predict the output for the following program: for j in range (2,9,3): print(j)output: _________________________ 8. Predict the output for the following program: sum=0for counter in range (10, 3, -2): sum += counter print(counter) output: _________________________ 9. Create a for loop that sums the values from 1 to 20 10. Use a while loop to print the numbers from 1 to 3011. Predict the output for the following program:i = 5while i > 0: print("hello") i -= 1output: ________________________Study Tips:?Write a for loop that will print output and give the sum of numbers?Write a while loop that will give complete an action while the condition is being met.?Explain when to use a for loop vs a while loop ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download