1 / 13

To Start

To Start. Create C:100 folder. Right Click. To Start. Create a short cut to Python 2.7 Another version Python 3.2, but use 2.7. Python27. Figure 1.3. Much of programming is about naming. We name our data Data: The “ numbers ” we manipulate We call our names for data variables

leigh
Download Presentation

To Start

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. To Start • Create C:\100 folder Right Click

  2. To Start • Create a short cut to Python 2.7 • Another version Python 3.2, but use 2.7 Python27

  3. Figure 1.3

  4. Much of programming is about naming • We name our data • Data: The “numbers” we manipulate • We call our names for data variables • We implement algorithms (recipes), and call them functions • Quality of names determined much as in Philosophy or Math • Enough words to describe what you need to describe • Understandable

  5. Variables • Name a value and re-use it • >>> x = 2*8 • >>> x/2 • >>> x • Whenever a variable name appears, it is substituted by its value • A variable name can be reused, redefined

  6. Naming Convention for both Variables and Functions • MUST start with a letter followed by alphanumeric • aVar, cs100, … • CASE matters • ‘Print’ is not the same as ‘print’ • ‘makePicture’ is not the same as ‘makepicture’, nor as ‘Makepicture’ • Multi-word name • First letter is capitalized • Convention, not absolute rule • Use sensible, meaningful name

  7. Figure 1.5 • Name Space == Class

  8. Figure 1.6

  9. Figure 1.7

  10. Python Overview • Data Objects: int, float • Operators • Expressions • Naming • Assignment Statements (variables, names) • Python Interpreter (read, evaluate, print)

  11. turtle module • Simple graphics programming • Abstraction • Fun and easy

  12. Import turtle module • >>> import turtle • Turtle attributes • Position, heading (direction), color, tail position • >>> myT = turtle.Turtle() • With myT • myT.forward(100), myT.backward(100) • myT.right(90), myT.left(45) • myT.goto(-200,90), myT.circle(50), myT.color(“red”) • myT.up(), myT.down() • myT.write(“Hello!”) • http://www.eg.bucknell.edu/~hyde/Python3/TurtleDirections.html

  13. Figure 1.9

More Related