COMPUTER SCIENCE

Computer - Universal Machine (in contrast to ATM or Gas pump)
Tasks performed under control of a program.

What is Computer Science?
not the study of computers.
Djikstra - computers are to computer science as telescopes are to
astronomy.
Computers are capable of carrying out "processes" that we describe
in programs. Processes - Algorithms.
CS is the study of "What processes can we describe?"
or "What can be computed?"
Design a Algorithm - Analysis of Algorithms - Experimentation

Hardware:
Input CPU+Memory Output
                 Secondary Memory (disk...)

Programming languages
  machine-level
  assembly-level
  high-level
    imperative
    declarative, functional, object-oriented
    scripting language
    compiled vs interpreted vs byte-code

source code - COMPILER - machine code - inputs - RUN outputs
source code, inputs - INTERPRETER - outputs
    
Python programming language
---------------------------

print "Hello, World!"

print 2+3

print "2+3 = ", 2+3

def hello():
  print "Hello"
  print "Computers are fun"

hello()

def greet(person):
  print "Hello", person
  print "How are you?"

greet("John")

greet("Emily")

---------------------------------------------------------
# File: chaos.py
# A simple program illustrating chaotic behavior.

def main():
    print "This program illustrates a chaotic function"
    x = input("Enter a number between 0 and 1: ")
    for i in range(10):
        x = 3.9 * x * (1 - x)
        print x

main()
---------------------------------------------------------

import chaos
or
chaos.main()

IDLE (Integrated Development L Environment) - Eric Idle (Monty Python)

# convert.py
#      A program to convert Celsius temps to Fahrenheit
# by: Susan Computewell

def main():
    celsius = input("What is the Celsius temperature? ")
    fahrenheit = (9.0 / 5.0) * celsius + 32
    print "The temperature is", fahrenheit, "degrees Fahrenheit."

main()

Names/identifiers, expressions, output statements, assignment statement
(identifiers: begin with _ or letter followerd by _, digit, letter)
keywords: and, if, for, ...

# avg2.py
#   A simple program to average two exam scores.  
#   Illustrates use of multiple input.

def main():
    print "This program computes the average of two exam scores."
    print

    score1, score2 = input("Enter two scores separated by a comma: ")
    average = (score1 + score2) / 2.0

    print "The average of the scores is:", average

main()

# futval.py
#    A program to compute the value of an investment
#    carried 10 years into the future


def main():
    print "This program calculates the future value"
    print "of a 10 year investment."

    principal = input("Enter the initial principal: ")
    apr = input("Enter the annualized interest rate: ")

    for i in range(10):
        principal = principal * (1 + apr)

    print "The value in 10 years is:", principal

main()