CONDITIONAL STATEMENTS IN PYTHON

 CONDITIONAL STATEMENTS

IN PYTHON

Peter Larsson-Green

J?nk?ping University

Autumn 2018

CONDITIONAL STATEMENTS

Enter a number: 12

Enter a number: -12

That is a positive number!

That is a negative number!

BOOLEANS

? Used to represent something's correctness.

? Possible values: True and False.

Examples

True

True

¡ú True

False

False

¡ú False

RELATIONAL EXPRESSIONS

Syntax:

How it is computed

1. Evaluate .

2. Evaluate .

3. Apply on

the computed values.

Examples

3 < 5

3< 5 ¡ú 3 < 5

¡ú 3 < 5 ¡ú True

3 > 5

3> 5 ¡ú 3 > 5

¡ú 3 > 5 ¡ú False

3 == 2

3 == 2 ¡ú 3 == 2

¡ú

3 == 2

¡ú False

3 != 2

3 != 2 ¡ú 3 != 2

¡ú

3 != 2

¡ú True

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download