subject

Translate the following pseudocode for randomly permuting the characters in a string into a Python Program.

Read a word.
Repeat len(word) times
Pick a random position i in the word, but not the last position.
Pick a random position j> i in the word.
Swap the letters at positions j and i
Print the word.

To swap the letters, construct substrings and then replace the string like so:

first + wordj] +middle+ wordli] last

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:00
Robots with telescoping arms are sometimes used to perform tasks (e.g., welding or placing screws) where access may be difficult for other robotic types. during a test run, a robot arm is programmed to extend according to the relationship r = 3 + 0.5cos(4θ) and the arm rotates according to the relationship θ=−π4t2+πt , where r is in feet, θ is in radians, and t is in seconds. use a computer program to plot the path of tip a in x and y coordinates for 0 ≤ t ≤ 4s.
Answers: 2
question
Computers and Technology, 22.06.2019 08:00
Two technicians are discussing the common u-joint. technician a says its input and output speeds should be equal. technician b says that it normally has two yokes. which technician is correct?
Answers: 1
question
Computers and Technology, 23.06.2019 10:30
How would you categorize the software that runs on mobile devices? break down these apps into at least three basic categories and give an example of each.
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
Perform an online search about the booting process of a computer and list all the steps
Answers: 2
You know the right answer?
Translate the following pseudocode for randomly permuting the characters in a string into a Python P...
Questions
question
Mathematics, 21.10.2020 02:01
question
Mathematics, 21.10.2020 02:01
question
History, 21.10.2020 02:01
question
English, 21.10.2020 02:01
question
Mathematics, 21.10.2020 02:01
question
English, 21.10.2020 02:01
Questions on the website: 13722363