Professional Documents
Culture Documents
Programming
Chapter 1
Course Materials
Unless otherwise noted, the content of this course material is licensed under a Creative
Commons Attribution 3.0 License.
http://creativecommons.org/licenses/by/3.0/.
Copyright 2010- Charles Severance
Couse materials link: http://www.pythonlearn.com/book.php
http://www.pythonlearn.com/install.php
tp://www.pythonlearn.com/install.php
Summary
This is a quick overview of Chapter 1
We will revisit these concepts throughout the course
Focus on the big picture
Why be a programer?
What
programmers
see
Make our
own life
easier
Programmer
Make
users life
easier
Programmi
ng
language
User
Hardware Architecture
http://upload.wikimedia.org/wikipedia/commons/3/3d/RaspberryPi.jpg
Software
Input
and
Output
Devices
Central
Processin
g
Unit
Main
Memory
What
Next?
Generic
Computer
Secondary
Memory
Definitions
Central Processing Unit: Runs the Program - The CPU is
always wondering what to do next? Not the brains
exactly - very dumb but very very fast
What
Next?
Software
Input
and
Output
Devices
What
Next?
Central
Processin
g
Unit
if x< 3:
print
Main
Memory
Generic
Computer
Secondary
Memory
Talk to Computer
Machine
Language
01001001000101001
01000100010001000
00100010000001001
0001000111000
Tedious and
difficult
Hardware
dependent
Python as a Language
Talking to Python
Syntax
Symbolic expressions
Semanti
cs
Meanings
Errors
Syntax Errors: When you are speaking gibberish &*9$
%6&gfdg4%%X
Errors
Logic Errors: Drink the water then open the bottle.
Elements of Python
Vocabulary / Words - Variables and Reserved words
(Chapter 2)
Reserved Words
Chapter 2
Sentences or Lines
x=2
x=x+2
print x
Variable
Operator
Assignment Statement
Assignment with expression
Print statement
Constant
Reserved Word
Type in your
python
installation
directory
Type in your
.py file
directory
Sequential Steps
print x
Give x an initial
value of 1
Print x value
x=x+1
Increase x by 1
print x
x=1
x=1
print x
x= x+1
print x
Chapter 2
Conditional Steps
x=5
Yes
X < 10 ?
print
'Smaller'
Yes
X > 20 ?
print 'Bigger'
x = int(raw_input("please
input x:"))
if x<10:
print "Smaller"
elif x>20:
print "Bigger"
else:
print "Finish"
print 'Finish'
Chapter 3
n=5
No
n>0?
Repeated Steps
Yes
n=5
print n
n = n -1
print
'Blastoff'
Chapter 5
while (n>0):
print n
n = n-1
else:
print "Blastoff!"
Loops (repeated steps) have iteration
variables that change each time through a
loop. Often these iteration variables go
through a sequence of numbers.
Why Python?
A Cool name?
Job Prospects
Average Salary for Skill: Python
Job
Software Developer
Data Scientist
$95,929
Data Analyst
$64,576
Software Engineer
$81,610
From Google
Job Prospects
Easy to Learn
C++
Java
public class Test {
public static void main(String args[]) {
for( int i = 1; i < 11; i ++)
{
System.out.println(value of i is:+i); }
}}
{
cout << "value of i is:" << i << endl;
}
Return 0; }
Python
for i in range(0, 10):
print "value of i is:%i"%i