Unit 1: Values, Variables, Operators/Operands, Function calls

Before we begin…

Please work through the quiz that follows every video or batch of videos. You will receive feedback in an e-mail, along with explanations. The explanations are a work in progress, so please be patient and feel free to ask me or a TA questions about anything that was not clear. If you do not receive a feedback e-mail, you either misspelled your e-mail address when you entered it into the quiz or there is a problem with the automated system. If you suspect that there is a problem with the system, please let me know.

If you scroll down this page a little you will notice a form embedded in the page titled Computer Science Quiz 0. Now have a close look at the first few questions. There is a little asterisk (*) at the end of every required question in all of the quizzes. This is sometimes confusing because the asterisk is a special symbol in many programming languages (including Python). Just remember that in these quizzes, an asterisk at the end of a question is not part of the question. It just means that you can not submit the form unless you answer that question.

Eventually, you will begin working on programming assignments. Before you type a single line of code, be sure to first read the directions carefully. If you have any questions about the directions, including why I am asking you to do something a certain way (a different approach may seem more natural to you), it is your responsibility to ask questions. Please ask me or a TA about anything at any time. If you do not understand the vocabulary or the concept, please ask before you put time into a project that I might have to ask you to redo a different way.

Ok, now for the first quiz (Which is labeled Quiz 0)!

Quiz 0

Introduction: What is programming?

This video introduces the idea that a program is a set of instructions that a machine carries out. The notion of a programming language is introduced. All programming languages consist of similar basic building blocks and these building blocks are discussed.

###########  Lesson 1:   #################

Quiz 1

Exrcise 1.1:

  1. Install IDLE: Go to https://www.python.org/downloads/ and install version 2.7.8 of Python. This will also install IDLE. If you’re unsure of what to download (what is compatible with your machine), don’t hesitate to ask!
  2. Play around with the python shell (I call it the interpreter in the video). Try doing addition, subtraction, multiplication and division. Notice anything funny?
  3. Create a new folder on your machine and title it something like “Python Programs”. Use IDLE to make a new file (got to File->New File) and create a “Hello World” program like you saw in the video. Modify the program so that it prints a different message.

Lesson 2: Building blocks and kinds of errors.

Lesson 3:   Types and more bugs.

Note: At about minute 13 in the video I begin to discuss a counter-intuitive behavior in Python; Commas appear to make numbers behave in strange ways. I state in the video that these values are actually called “lists” in Python. I misspoke.

Those values that I typed into the interpreter in the video are called “tuples”, not “lists”! There is a very important difference… But it will not matter for several more lessons. And it will not affect any relevant answers in the lesson 3 quiz.

 

Exercise 1.2:

  1. Use the python shell (interpreter) to determine the types of the following values or expressions.
    • (2,3,4)
    • [2,3,4]
    • “wombat”
    • (“wombat”,”wombat”)
    • {}
    • 1/2
    • 1.0/2
    • 2**3
    • True
    • True or False

 Lesson 4:  Variables, assignment, state diagrams and keywords.

 

Lesson 5: The comparison operator, booleans, a sneak peak at string concatenation.

 

 

Lesson 6: Operators, operands and string concatenation.

 

Lesson 7: Script Mode

 

Exercise 1.3

  • Download the file by clicking on the link below and save it to the folder where you work on python projects. 

oilChangeCalculator

  •  Now unzip the file and open the resulting ‘.py’ or text file through IDLE.
  • Work through the exercise and show it to me when you have finished.

 

Lesson 8: How to write notes to yourself and others in a program. Comments

 

No quiz on this one. Just remember that the pound sign (#) creates comments and so do triple quotation marks (remember to close them).

 

Lesson 9: What does Strongbad the Burnanator have to do with programming? Abstraction. That’s what.

Exercise 1.4

  • Download the file by clicking on the link below and save it to the folder where you work on python projects. 

functionsPractice

  •  Now unzip the file and open the resulting ‘.py’ or text file through IDLE.
  • Work through the exercise and show it to me when you have finished.

Lesson 10: Getting user input.

A better, safer way to get user input.

Correction for the following video:

At 10:32 in the video, I refer to the value “43” as an integer but I should have said string. Again, “43” , with the quotes is a string, because python recognizes anything in quotes as a string.