Question

Random permutation alphabet Write a Python procedure, randomPermAlphabet(msg), that produces a random permutation of the alphabet...

Random permutation alphabet

Write a Python procedure, randomPermAlphabet(msg), that produces a random permutation of the alphabet string. This procedure will be useful in future exercises involving substitution ciphers.

(HINT) The job can be simplified enormously by using the numpy.random.permutationfunction of the NumPy. (https://docs.scipy.org/doc/numpy-1.3.x/reference/generated/numpy.random.permutation.htm

Homework Answers

Answer #1

import random

def randomPermAlphabet(msg):

#using sample to shuffle

return ''.join(random.sample(msg,len(msg)))

print(randomPermAlphabet("Uday"))

print(randomPermAlphabet("Hello213"))

print(randomPermAlphabet("uday123Kumar"))

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions