The python code below to find the number of r-permutations when repetition is not allowed and r-combinations when repetition is not allowed of a set with n elements. Write the algorithm and draw the flowchart based on the code. import itertools from itertools import combinations from itertools import permutations def rSubset(arr,r): return list(combinations(arr,r)) def rPermutations(arr,r): return list(permutations(arr,r)) if __name__=="__main__": lst=[] n=int(input("Enter n :")) for i in range (0,n): ele=int(input("n elements :")) lst.append(ele) print (lst) r=int(input("Enter r : ")) combinationsl=list(itertools.combinations(lst,r)) print("Combinations : ",combinationsl) permutationsl=list(itertools.permutations(lst,r)) print("Permutations : ",permutationsl)
The python code below to find the number of r-permutations when repetition is not allowed and r-combinations when repetition is not allowed of a set with n elements. Write the
import itertools
from itertools import combinations
from itertools import permutations
def rSubset(arr,r):
return list(combinations(arr,r))
def rPermutations(arr,r):
return list(permutations(arr,r))
if __name__=="__main__":
lst=[]
n=int(input("Enter n :"))
for i in range (0,n):
ele=int(input("n elements :"))
lst.append(ele)
print (lst)
r=int(input("Enter r : "))
combinationsl=list(itertools.combinations(lst,r))
print("Combinations : ",combinationsl)
permutationsl=list(itertools.permutations(lst,r))
print("Permutations : ",permutationsl)
Step by step
Solved in 2 steps with 1 images