Question: 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

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 strings List

. 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.

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 calculated value in a variable called avgStrLen

Also, at each iteration, store the string from the list in the dictionary object as the key, and store the length of that string as an integer into the dictionary as the value.

After the execution of the loop, output the computed average length of the strings stored in the list to the screen.

Output the stringsDictionary variable to the screen

3. Write Python code that will iterate through the strings Dictionary 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 strings List 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 {'str':3} as the dictionary, the end result would be {'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 remainder List.

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 stringsList

After computing the sum, compute the remainder after dividing the computed sum by the

current iterations dictionarys value

Append the computed remainder to the stringList object

Output the stringsList variable to the screen

Note: Create a Python module called LoopsLab to illustrate the solutions to

Page of 3 ZOOM Example Output: -PROBLEM 1 Enter a string value to add to the 1ist of strings: Introduction Enter another string value to add to the list of strings: to Enter another string value to add to the list of strings: Python Enter another string value to add to the list of atringa: Programming Enter another string value to add to the list of strings: exiT stringsList: ['Introduction'to'Python', 'Programming PROBLEM The average string length is 7.75 stringsDictionary: \'Introduction': 12, Python': , 'Programming': 11, 'to': 2 The sum of the values in the dictionary is 31 stringsList: I'Introduction12'to2'Python6', 'Programingll' ---PROBLEM 4 stringsList: ['1381'277',696',1253' PROBLEM 5 stringsDictionary: nohtyP' 6, 'ot': 2, 'gnimmargorP 11, noitcudortnI 12) PROBLEM stringsList: ['1381',277',696'1253,'10, '',"10',0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!