Write python code using a while loop and prompt the user

Assignment Help Python Programming
Reference no: EM132355029

Assignment

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. a 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 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 {'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 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 stringsList

• 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

Reference no: EM132355029

Questions Cloud

How did the organization of ap nichols : How did the organization of A.P Nichols changed its structure to achieve its goals? Explain
How can the organization of ap nichol be described as : How can the organization of A.P Nichol's be described as? Why? Explain.
How much did the price of the candy bar change : Over the same period, the CPI rose from 150 to 300. Adjusted for overall inflation, how much did the price of the candy bar change?
Real interest rate on loan higher : Then inflation turns out to be higher than they both expected. Is the real interest rate on this loan higher or lower than expected?
Write python code using a while loop and prompt the user : 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.
Describe the system development life cycle : ICT103 - Introduction to Data Communications - Murdoch University - analyse and design a booking system that should be able to perform tasks like adding
Display the contents of the list using a for loop : A program that populates a list of 8 car manufacturers. You can have the user populate the list or have it predefined. displays the contents of the list.
Write a program that calculates the occupancy rate for hotel : Write a program that calculates the occupancy rate for a hotel. The program should start by asking the user how many floors the hotel has.
Create an application that displays the number of millimeter : Create an application that displays the number of millimeters that the ocean will have risen each year for the next 25 years.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd