Learning Objectives

Through readings, lecture and labs, it is expected that you are doing work and seeking help to keep pace with the below objectives:

Accumulator pattern
You should be able to:
  • Trace the execution of code that uses accumulation
  • Recognize simple examples of problems that use this pattern
  • Write code to solve these problems
Our graphics library
You should be comfortable with:
  • Writing programs that display a graphics window.
  • Drawing colored circles and rectangles in the graphics window.
  • Calculating the desired positions of circles and rectangles.
Conditionals (if statements)
You should be comfortable with:
  • Tracing the execution of programs using if, elif, else
  • Computing the values of Boolean expressions (expressions that evaluate to True or False).
  • Writing programs that use these constructs.

Required Reading


Supplemental Materials

We all need alternative presentations of the concepts from time to time. The following resources are optional. If something seems unclear after class, or the pratice questions seem hard for you, then explore these topics more using the resources below.

Accumulator pattern
Our graphics library
Conditionals (if statements)

Practice

For all these exercises, I recommend you try them on paper and then test them out with PythonTutor.

Exercise 1

Write what this code produces, exactly. Be very careful with whitespace and the newlines.

seaw = 'SeaWolves'
print('Go', seaw, end='!\n!')
print(seaw + ' Rock')

Exercise 2

Write what this code produces, exactly. Be very careful with whitespace and the newlines.

k = 0
for i in range (1 , 10, 2):
   print(i)
   k = k + i
print (k)

Exercise 3

Write a piece of code that produces the following input/output behavior. Text that is italics and underlined are user input.

Enter an integer: 100
Sum of squares of numbers 1--100 is: 338350
Here is a sample answer, when you think you have solved it. (Don't cheat yourself and look early).