6.11. Write Code QuestionsΒΆ

Warning

Be careful not to create infinite loops, as they will cause the page to freeze.

  1. Fix the 5 errors in the code below to print a countdown of the numbers from 10 to 0, including 0.

    Fix the 5 errors in the code below to print a countdown of the numbers from 10 to 0, including 0.

  2. The following code will loop way too many times. Change one line to make the loop only have five iterations.

  3. Make 5 changes to the code below to correctly print a count up from -10 to 0, including 0.

  4. Finish lines 1 and 5 so that the following code correctly prints every integer from -5 to -1, including -1.

  5. Complete the code on lines 4 and 6 so that it prints the number 6.

  6. The code below is supposed to print an estimate of the square root of a number, but the indention is wrong on 4 lines. Fix these errors to find the estimate.

  7. This function currently takes a start and stop argument and uses a for loop to find the sum of all the numbers between them (inclusive). Change the for loop to a while loop while still using the same parameters.

  8. The program below is supposed to print the times tables from 1 to 3, but there are 5 errors. Fix the errors.

  9. The following code prints the times tables for 1 to 3 using two for loops. Rewrite the program to use a while and a for loop instead.

  10. Rewrite the following code to use a while loop instead of a for loop.

You have attempted of activities on this page