Programs (Or Scripts) : - Print
Programs (Or Scripts) : - Print
(or
scripts)
While
we
can
type
expressions
directly
to
a
Python
interpreter
(for
example
using
an
interface
such
as
an
IDLE
shell),
in
general
we
will
want
to
include
statements
in
a
program
le
Execu@ng
an
expression
from
a
script
will
not
produce
any
output;
for
that
we
need
statements
(not
expressions),
such
as
print(ab)! print(3*3)!
Providing
input
If
we
are
going
to
write
programs
or
scripts,
we
will
need
a
way
to
incorporate
input
from
a
user.
We
use
the
Python
func@on
raw_input,
as
in:
>>> name = raw_input(Enter your name: )! Enter your name: Eric Grimson! >>> print(Are you + name + ?)! Are you Eric Grimson?!
Some
observa@ons
Comments
appear
aLer
a
#
These
are
very
valuable,
as
they
help
a
user
understand
decisions
the
programmer
has
made
in
crea@ng
the
program
Well
commented
code
should
be
very
readable
by
a
user
A straight line program simply executes each statement in order, with no varia@on in order Most programs require more sophis@cated ow control