0% found this document useful (0 votes)
2 views8 pages

Chapter 2 Python Boolean - If-Else Condition

The document outlines a process for withdrawing money from an ATM, detailing steps such as inserting a card and entering a password. It also introduces programming concepts like Boolean values, if/else statements, and loops, with examples in Python. The content emphasizes the importance of condition evaluation in programming logic.

Uploaded by

jamesm
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)
2 views8 pages

Chapter 2 Python Boolean - If-Else Condition

The document outlines a process for withdrawing money from an ATM, detailing steps such as inserting a card and entering a password. It also introduces programming concepts like Boolean values, if/else statements, and loops, with examples in Python. The content emphasizes the importance of condition evaluation in programming logic.

Uploaded by

jamesm
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

Withdraw money from ATM

Start

Insert card here

Show(write password)

Enter password

Wrong
password

Is password
correct?

Get money End


1
Insert card here

Show(write password)

Enter password Wrong password

Is password
Get money correct?

2
Repetition (loops)
and Selection (if/else)

3
Boolean Values
■ In programming you often need to know if an expression
is True or False.
■ You can evaluate any expression in Python, and get one of two
answers, True or False.
■ When you compare two values, the expression is evaluated and
Python returns the Boolean answer:
■ Operators:
>
==
<
■ Example:
print(10 > 9)
print(10 == 9)
print(10 < 9)

4
if
■ if statement: Executes a group of statements only if a certain
condition is true. Otherwise, the statements are skipped.
■ Syntax:
if condition:
statements

■ Example:
gpa = 3.4
if gpa > 2.0:
print "Your application is accepted."

5
If/else condition
■ Example:
a = 200
b = 33
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")

■ Example 2:
var1 = int(input(“Enter the first number : ”)
var2 = int(input(“Enter the second number : ”)

if var1 > var2:


print(“var 1 value is - ”, var1, - is greater than var2 value “, var2)
else:
print(“var 2 value is - ”, var2, - is greater than var1 value “, var1)

6
Withdraw money from ATM
Start

Insert card here

Show(write password)

Enter password

Wrong
password

Is password
correct?

Get money End


7
Insert card here

Show(write password)

Enter password Wrong password

Is password
Get money correct?

You might also like