WEEK01: intro to python, unix, cs21
-----------------------------------
 W: data types, variables, input/output

Announcements:
  - Lab 0 (due this Friday)
  - Lab 1 (due Tuesday)
  - ninja session tonight (our Ninjas = Justin, Molly)
  - need to know vim for Friday's class
  - don't forget using unix 
  - try update21

DATA TYPES: string, int, float
  - what they are:
        strings: "hello" "jeff" "This is FUN!!"
        integers: 5 360 -21
        floating point numbers: 3.14159  -6.2  800.0
  - things you can do with them (+, -, *, etc)
  - type('a'), type(21), type(3.141)
  - simple functions:
       type('hello') 
       int(5.0)
       int('5')
       float(5)
       str(5)  
       int(3.141)
       print "hello"

VARIABLES: place to store a value
  - rules for names
  - why do we use them?
  - examples:
       x = 5
       y = "hello"
       name = "Jeff Knerr"
       z = 3.141 * x
  - the equals sign here is the ASSIGNMENT operator


INPUT vs RAWINPUT
  - input, do something, output
  - input     (set equal to)
      num = input("please enter a number: ")
  - raw_input (string)
      name = raw_input("please enter your name: ")

PRINTING/OUTPUT:

  - use commas to print different types all on one line:

age = 45
name = "Jeff"
print name, "is", age, "years old"

  - or convert everything to a string and use + operator

print name + " is " + str(age) + " years old"


YOUR TURN: write a program to do this...

please enter your name and the year you were born...
your full name: jeff knerr
year you were born: 1965

Hello, jeff knerr
You are 44 years old!


  - think first!!! (don't just start typing)
  - write it out on paper first!! (don't just start typing)
  - say hello to your neighbor first!! (don't just start typing)
  - talk it over with your neighbor first!! (don't just start typing)


IF YOU HAVE TIME:
  - what happens when you enter nonsense values for your
    name and age (ex: enter your age for your name and vice versa)
  - try using vim to enter your program in a hello.py file
  - what happens when you try these?
  >>> 4 + 5 * 2
  >>> (4 + 5) * 2
  >>> 5 * 2 + 4
  >>> 5 * (2 + 4)

IF YOU DON'T HAVE TIME:
  - you are welcome to look at or copy my inclass programs:

        cp  /home/jk/inclass/firstprog.py  jeff-firstprog.py