Python (four-digit number can be different from each other with no repeat of generating three-digit numbers, to achieve the command prompt)

How many other with no repeat of three-digit numbers can generate four numbers:

"" "
There are four numbers 1,2,3,4
find how many other with no repeat of three-digit numbers that can generate four numbers
" ""

count = 0

for i in range(1,5):
    for j in range(1,5):
        for k in range(1,5):
            if i != j and j != k and k != i:
                print(i * 100 + j * 10 + k)
                count +=1

print("生成%d个无重复数字的三位数" %count)

Here Insert Picture Description

Implement the command prompt:

#实现命令行提示符
import os
for i in range(1000):
    cmd = input('[kiosk@test ~]$ ')
    if cmd:
        if cmd == 'exit':
            break
        else:
            print('run %s' %(cmd))
            os.system(cmd)
    else:
        continue

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/bmengmeng/article/details/93999433