Python Exercise Example1
# Python2.x Python Exercise Example 1
[ Python 100 Examples](#)
**Question:** There are four numbers: 1, 2, 3, 4. How many different three-digit numbers can be formed without repeating digits? What are they?
**Program Analysis:** The numbers that can be filled in the hundreds, tens, and units places are all 1, 2, 3, and 4. Form all permutations and then remove the permutations that do not meet the conditions.
Program source code:
## Example
#!/usr/bin/python# -*- coding: UTF-8 -*-for i in range(1,5): for j in range(1,5): for k in range(1,5): if(i != k)and(i != j)and(j != k): print(i,j,k)
The output result of the above example is:
1 2 31
YouTip