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:

What is programming?

Understand the "big picture" of the tools we are using in class. You should be able to understand the difference between Python the language, and the Python interpreter, and a Python program. Feel comfortable with terms like source code.

What a program looks like.
You should be experimenting and getting comfortable with:
  • Writing very short Python programs.
  • Writing print statements that print arbitrary text to the screen.
  • Writing comments or docstrings to explain your programs.
Variables, input, output, assignment.
By the end of the week, you should be experimenting with:
  • Defining variables using assignment statements
  • Keeping track of the changing values of a variable during the execution of a program
  • Printing a mix of variables and literals
  • Using input to assign values to variables
  • Combining these elements to write programs, given an English description of what the program should do.

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.

What is programming?
What a program looks like.
Variables, input, putput, assignment.
  • Zelle, Sections 2.1–2.5

Some people like more traditional text books. Zelle refers to: John Zelle, Python Programming: An Introduction to Computer Science, 2nd edition. This book is available at the library and is a pretty good supplemental text for our course.


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.

animal = 'Duck'
print(animal, animal)
print(animal, "DuckDuck", animal)
print("Goose")

Exercise 2

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

def main():
    refrain = "Happy Birthday to you"
    print(refrain, refrain, "Happy Birthday, Dear Snoopy", refrain, sep="!\n")
    
main()

Exercise 3

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

Your favorite tree: Elm
Your favorite food: Pizza
Do you want to eat Pizza in a Elm tree with me?
Here is a sample answer, when you think you have solved it. (Don't cheat yourself and look early).