0% found this document useful (0 votes)
5 views17 pages

Lesson 3

The document discusses various programming concepts in Python, focusing on conditional statements such as 'if', 'else', and 'elif'. It explains the syntax and provides examples to illustrate how these statements control the flow of a program based on certain conditions. Additionally, it outlines different types of operators in Python, including arithmetic and logical operators.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views17 pages

Lesson 3

The document discusses various programming concepts in Python, focusing on conditional statements such as 'if', 'else', and 'elif'. It explains the syntax and provides examples to illustrate how these statements control the flow of a program based on certain conditions. Additionally, it outlines different types of operators in Python, including arithmetic and logical operators.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

L E 6

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

need ding on g statem


is dec to be exe the cond ent is
� ided cuted ition b
by co or no lock
(SEL
CON

If the n dition t whic


c
statem ondition . h
if con ent bloc is "true"
statemdition is k will be
execu ent bloc "false" t execute
ted. k wil hen d,
l not
be
� In t
his se
discu ction
w
STAT ONAL ss
if-the about if are
e

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

maki types of d e there are


� if
ng sta ecisio
teme n
(SEL

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)

You might also like