e a Python Program that will shuffle a string and compute its randomness score. The us ng and the number of times they want to shuffle it, and your program is to determine the omness score of each shuffle. Below are the specifics: Your program will first ask the user for a string as well as the number of times they wi ne string. Next, your program will make its first shuffle. This will be done by converting your in ato a list of its characters, and then inputting that list into the shuffle function. Your program will th

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
3 - Assignment
Write a Python Program that will shuffle a string and compute its randomness score. The user will input
a string and the number of times they want to shuffle it, and your program is to determine the
randomness score of each shuffle. Below are the specifics:
• Your program will first ask the user for a string as well as the number of times they wish to shuffle
the string.
• Next, your program will make its first shuffle. This will be done by converting your input string
into a list of its characters, and then inputting that list into the shuffle function.
• Your program will then convert the shuffled list of characters into a string form and print out the
string form.
• Your program will then compute a randomness score based on the differences in ordinal
values between respective positions in the initial string and shuffled string. It will then print
out that randomness score.
• Your program will then shuffle the list of characters again and repeat the process.
Transcribed Image Text:3 - Assignment Write a Python Program that will shuffle a string and compute its randomness score. The user will input a string and the number of times they want to shuffle it, and your program is to determine the randomness score of each shuffle. Below are the specifics: • Your program will first ask the user for a string as well as the number of times they wish to shuffle the string. • Next, your program will make its first shuffle. This will be done by converting your input string into a list of its characters, and then inputting that list into the shuffle function. • Your program will then convert the shuffled list of characters into a string form and print out the string form. • Your program will then compute a randomness score based on the differences in ordinal values between respective positions in the initial string and shuffled string. It will then print out that randomness score. • Your program will then shuffle the list of characters again and repeat the process.
3.1- The Randomness Score
As stated above, the main task of this program is to compute a randomness score based on how different
the inputted string is after being shuffled. To do this, you will implement the following:
• Your calculation will start with the first character of the initial string and the shuffled string.
• You will take the difference between the ordinal value of each character and add that value to
your final score.
• You will then move to the next character and repeat the process until you have gone
through each entire string.
For example, say we input the string "Kevin" and it shuffles into "vKnei". We would then do the
following calculation:
K
75
118
43
K
101
75
26
In
118 110
8
105 101
4.
110 105
Note that when we take the difference between ordinal values, we convert it to its absolute value to
make sure it always stays positive. This means that the total randomness score is 43+26+8+4+5-86.
2
Transcribed Image Text:3.1- The Randomness Score As stated above, the main task of this program is to compute a randomness score based on how different the inputted string is after being shuffled. To do this, you will implement the following: • Your calculation will start with the first character of the initial string and the shuffled string. • You will take the difference between the ordinal value of each character and add that value to your final score. • You will then move to the next character and repeat the process until you have gone through each entire string. For example, say we input the string "Kevin" and it shuffles into "vKnei". We would then do the following calculation: K 75 118 43 K 101 75 26 In 118 110 8 105 101 4. 110 105 Note that when we take the difference between ordinal values, we convert it to its absolute value to make sure it always stays positive. This means that the total randomness score is 43+26+8+4+5-86. 2
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education