“Permutasi di Python” Kode Jawaban

Semua permutasi Python

import itertools
print(list(itertools.permutations([1,2,3])))
Smiling Sable

Permutasi Python

import itertools

a = [1, 2, 3]
n = 3

perm_iterator = itertools.permutations(a, n)

for item in perm_iterator:
    print(item)
Kodi4444

Menggunakan fungsi permutasi Python pada string

from itertools import permutations 
string="SOFT"
a=permutations(string) 
for i in list(a): 
   # join all the letters of the list to make a string 
   print("".join(i))
Outrageous Ostrich

Semua permutasi Python


import itertools
list(itertools.permutations([1, 2, 3]))

Cautious Cod

Python Semua permutasi string

>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms
Worrisome Wallaby

Permutasi di Python

T=[i for i in range(8)]
for i in range(8):
             print("T[",i,"]= ",end="")
             T[i]=int(input())
print("Tableau avant permutation")
print(T)
k=7
for i in range(4):
             X=T[i]
             T[i]=T[k]
             T[k]=X
             k=k-1
print("Tableau après permutation")
print(T)
Exuberant Earthworm

Jawaban yang mirip dengan “Permutasi di Python”

Pertanyaan yang mirip dengan “Permutasi di Python”

Lebih banyak jawaban terkait untuk “Permutasi di Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya