Lesson 3
Lesson 3
O D U
M
� 1. T
D
G
E
NDE he stu
RNIN dent
COM
unde are ab
rstan le to
cond d the
itiona conce
INTE
l state pt of
ment
LEA
OUT
� 2. T
s
he stu
cond dent
itiona can a
progr l in s pply
amm olvin
ing p g
roble
ms
Are y
ou re
ady f
PHA or
S E II
I?
� LET
S ST
ART
;)
� What are the 7 operators in
IEW
python?
REV
� Arithmetic operators
� Assignment operators
� Comparison operators
� Logical operators
� Identity operators
� Membership operators
� TH
E SE
STR LEC
T
MAKUCTUR ION
STAT ONAL
NTS
ING E - D
ON)
STA E
TEM CISION
EME � Decis
ENT
ECTI depen ion makin
DITI
NTS
ON)
n -
neste -e l s e (if e then (if),
d if s
pytho tatem lse), and
EME
ECTI three n languag ent. In
DITI
nt.
CON
� if-e
lse
� If-e
lif-el
se (ne
sted i
f)
� IF S
TAT
� If - EME
NT
ENT
is mo
of De st bas
cision ic sta
statem maki teme
M e n n t
to ex nt. It tell g
ATE
ecute s to p
code a cert rogra
only ain p m
cond if par art of
ition ticula
� One is tru r
IF ST
e.
-way
selec
tion
ENT
� Syn
M tax
If (co
ATE
ndition
):
>>sta
teme
nt
IF ST
IF ST
ATE
M ENT
� Exa
� a=1
mple
ENT
0;
� if (a
M <10):
print
(“a is
ATE
less t
han
10“)
� Ou
IF ST
tput
� NO
THIN
G
� Exa
mple
� a=9
;
� if (
ENT
a<10
):
print
� if (
M (“a is
less t
han
ATE
a>10 10“)
):
print
(“a is
great
e
IF ST
r than
� Ou 10“)
tput
� a is
less t
han 1
0
� IF-
ELSE
� In g
SE
STA
NT
TEM
IF EL ENT
enera
EME execu l it ca
te on n be
statem e blo used
c k t o
e
block nt among of
s, in p
STAT
two
if and ython
e
in py lse are th language
thon e key
� Tw word
o-wa
y sele
ction
� Syn
tax
� if (c
SE
NT
IF EL ondit
ion):
EME State
ment
s
#if co
� else
nditio
n bec
omes
STAT
: true
State
ment
s
#if th
e con
dition
becom
es fal
se
IF EL
STAT SE
EME
NT
Exam
�
ple
time=
� 10
SE
if (tim
NT
e<12
IF EL print ):
EME � else:
("Go
od m
ornin
g“)
print
("Go
od af
STAT
ter n
oon“
)
� Ou
tput
� Go
od m
o rning
E
E
CTIC
RCIS
2. W
rite a
the u progr
ser to am th
obtai enter at ask
PRA
ns the numb s
EXE
user, numb ers 1-
then e r s f 12,
mont print rom t
h (IF the eq he
STAT uival
EME ent
NT)
E
E
CTIC
RCIS
3. Pro
gram
age o t
f the hat will a
if the user a ccept
PRA
user i nd de the
EXE
or no s a qu termi
t. (IF alifie ne
STAT – EL d voter
EME SE
NT)