Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Note: Create a Python module called LoopsLab to illustrate the solutions to the following problems. Each problem may or may not build on the problem

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Note: Create a Python module called LoopsLab to illustrate the solutions to the following problems. Each problem may or may not build on the problem before it. 1. Create an empty list object called stringsList. .Write Python code using a while loop and prompt the user to input a string. . Add that string to the stringsList variable and prompt the user again to input another string. Check to see if the value of the string is 'EXIT, and if it is, exit out of the while loop. o The check for the string 'EXIT should not be case sensitive. Output the stringsList variable to the screen 2. Create an empty dictionary object called stringsDictionary. Write Python code that will iterate through the string values in the stringsList variable using a while loop. . This script should calculate the average length of all the strings in the list and store the .Also, at each iteration, store the string from the list in the dictionary object as the key, and . After the execution of the loop, output the computed average length of the strings stored . Output the stringsDictionary variable to the screen calculated value in a variable called avgStrlen. store the length of that string as an integer into the dictionary as the value. in the list to the screen. 3. .Write Python code that will iterate through the stringsDictionary based on the keys in that dictionary using a for loop. This script should sum up the integer values in the dictionary and store the result in the variable sumStrValues At each iteration of the for loop, use another for loop to iterate though the stringsList object to find the value in the list that matches the key in the dictionary .When found, append the value in the dictionary at the current iteration to the value in the list After the execution of the loop, output the computed sum of the values stored in the dictionary to the screen. Output the stringsList variable to the screen 4. Write Python code that will iterate through the stringsList using a while loop. At each iteration in the list, use a for loop to iterate through each character of that string and convert it to its associated decimal value. Sum the decimal values, and replace the current string value in the stringsList with the computed sum of the decimal values as a string. Output the stringsList variable to the screen 5. Create an empty dictionary object called reversedStringsDictionary .Write Python code that will iterate through the stringsDictionary based on the keys in that dictionary using a for loop. .This script should reverse the key stored in the dictionary (i.e. Instead of having f'str':3 as the dictionary, the end result would be f'rts':3) and store the reversed key with the same value into the reversedStringsDictionary Clear the original stringsDictionary and update it with the data from the reversedStringsDictionary variable .The original key:value pairs should not be in the dictionary anymore. Only the key:value pairs with the reversed keys should be in the dictionary. .Output the stringsDictionary variable to the screen 6. Create an empty list object called remainderList. .Write Python code that will iterate through the stringsDictionary in alphabetical order based on the keys in that dictionary using a for loop. .At each iteration of the for loop, use another for loop to iterate though the stringsList .The for loop should sum the integer values of the strings in the stringsLst After computing the sum, compute the remainder after dividing the computed sum by the current iteration's dictionary's value Append the computed remainder to the stringList object .Output the stringsList variable to the screen

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions