Lecture Date: Wednesday, February 3
We’ll start by finishing up with the tree drawing with the turtle from last class.
Now that we are through the break-neck pace of trying out a lot of stuff with turtle, we’re going to slow down and go step-by-step and see how we can put programs together.
Today, we’ll focus on input and output with a program.
Let’s first start by discussing literals. A literal is a value that appears in a program that is what it is. For instance, if I say:
then “Hello World!” is a literal. It is the actual value of the thing it represents. In this case, we would call this a string. You can print any literal to the screen using the print method as shown above.
When we look at string literals, notice how it is surrounded by quotation marks. We’ll examine that a bit more in class.
Next, we’ll discuss variables and value assignment with the equals sign. What makes a good variable name? What can variables hold? Can they hold different types of items? We’ll touch on dynamic vs. static typing. Then we’ll discuss how to print them along with how to combine the printing of multiple items.
How do we get input from the user? Well, with the input command! We’ll do some more examples here and do some basic arithmetic using Python.
The information for today’s lecture comes from Chapter 2 of the Gaddis book.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46