Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Exercise Example 48

Python Exercise Example 48

Python 100 Examples Python 100 Examples

**Problem:** Number comparison.

**Program analysis:** None

Program source code:

Example

#!/usr/bin/python

-- coding: UTF-8 --

 

if

name

==

'main'

:

    i

=

10

    j

=

20

   

if

i

j:

       

print

(

'%d is greater than %d'

%

(

i

,

j

)

)

   

elif

i

==

j:

       

print

(

'%d is equal to %d'

%

(

i

,

j

)

)

   

elif

i

<

j:

       

print

(

'%d is less than %d'

%

(

i

,

j

)

)

   

else

:

       

print

(

'Unknown'

)

The output of the above example is:


10 小于 20

Python 100 Examples Python 100 Examples