Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Loops and Variables

Readings

The readings for this week cover three topics. First, we will learn a bit more about strings and about the print() function, which outputs strings. We’ve been using both in class already. Second, we’ll learn about two kinds of loops – while loops and for loops. And third, we’ll learn a bit about using random numbers in Python.

Strings and Print()

Loops

Randomness

Optional: Recursion

For those of you who are more computationally curious, a topic that is related to loops is recursion. Recursion is conceptually elegant; the idea is that a function calls itself over and over on incrementally modified data until it reaches some sort of base state. It’s something CS and math folks might wax poetically about (myself included! Sorry!). However, it comes with some interesting drawbacks. This reading is totally optional and solely for the curious student’s edification. It may inspire you, though, as you get closer to your final project…

Summary

For the summary this week, focus on loops and randomness. Think about similar things you have encountered before.

Summary prompt: How would you describe loops and randomness in your own words, and what do you think each thing might be used for in programs?

Question

As per usual, your question can be one of three types:

  • Confusion: what didn’t you understand in the readings?
  • Curiousity: what do you want to know more about?
  • Connection: how does this topic connect to your own experiences?

Submit your summary+question on D2L under Quizzes before class starts on Thursday.