05 - Python Introduction
05 - Python Introduction
– Program
– Interactive
– Script
• Interactive
– You type directly to Python one line at a
time and it responds
• Script
– You enter a sequence of statements (lines)
into a file using a text editor and tell Python
to execute the statements in the file
x=2
Program:
Output:
print x x=2
print(x) 2
x=x+2 4
x=x+2 print(x)
print x
print
'Smaller' Program: Output:
x=5 Smaller
Yes if x < 10: Finis
X > 20 ? print('Smaller’)
if x > 20:
print print('Bigger‘)
'Bigger' print( 'Finish‘)
print 'Finish'
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.