Iteration Revisited

Logistics

  • Due: Tuesday, May 22nd no later than 5pm.
  • Submission instructions: complete the assigned number of activities in each of the assigned subsections of Chapter 8. You do not need to submit anything to Brightspace.
  • Deadline reminder: once this deadline passes, Runestone Interactive will no longer allow you to collect points for completing the activities.

Key ideas

From chapter 8:

  • for loop
  • Know how to use range
  • Know how to iterate over a string (e.g. "Bozeman High") or a list (e.g. [1, "Potato", 2, "Potato"])
  • while loop
  • Know how to nest one loop inside of another

Assignment

Grading - 10 points

  • 10 points - the required number of activities were completed for each subsection before the deadline.

Grading turnaround

This reading assignment will be graded with scores in Brightspace by office hours the following class day.

Optional activities

Activity 1

Write a Python program that generates a random number between 1 and 10. The program should repeatedly ask the user to guess what the number is until the user guesses correctly. When the user guesses correctly, the program should print a message that shows how many tries it took. For example, the message might be Congratulations! That took 6 guesses.

Activity 2

Write a Python program that asks the user to enter two integers: one for the number of rows and one for the number of columns. The program should then produce a text-based drawing where each position in the drawing is randomly determined with equal probability to be either a * or a -. For example, with 4 rows and 6 columns, the drawing might look like this:

**-*-*
--**--
-*--*-
---*-*