Python3 Lesson 03
Python3 Lesson 03
www.sixthresearcher.com
@SixthResearcher
Alvaro Sebastián Yagüe www.sixthresearcher.com @SixthResearcher
Data comparison: boolean expressions
A boolean expression is a comparison between two data values and returns True
or False. True and False values are from another data type: boolean type.
“True”
“False”
A boolean expression is a comparison between two data values and returns True
or False. True and False values are from another data type: boolean type.
x == y x is equal than y
x != y x is different than y
x<y x is lower than y
x>y x is greater than y
x <= y x is lower or equal than y
x >= y x is greater or equal than y
x == y x is equal than y
x != y x is different than y
x<y x is lower than y
x>y x is greater than y
x <= y x is lower or equal than y
x >= y x is greater or equal than y
“and” “or”
A B A and B == 1 A or B == 1
1 1
1 0
0 1
0 0
“and” “or”
A B A and B == 1 A or B == 1
1 1 1 1
1 0 0 1
0 1 0 1
0 0 0 0
if <condition> :
<code1>
else:
<code2>
Code must
be indented
4 spaces
if <condition1> :
<code1>
else if <condition2> :
<code2>
else if <condition3> :
<code3>
else if <condition4> :
<code4>
else:
<code5>
if <value> in <list>:
Write a Python code to tell the hour in English or Polish formal way.
A little help…
else if…
else if…
else …