Python Practice Example 48
Title: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 equals %d' % (i,j))
elif i < j:
print ('%d is less than %d' % (i,j))
else:
print ('Unknown')
# -*- 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 equals %d' % (i,j))
elif i < j:
print ('%d is less than %d' % (i,j))
else:
print ('Unknown')
The output result of the above example is:
10 小于 20Other extensions
Python 100 Examples