Question

Python 3 coding with AWS/Ide. Objective: The purpose of this lab is for you to become familiar with Python’s built-in te...

Python 3 coding with AWS/Ide.

Objective:

The purpose of this lab is for you to become familiar with Python’s built-in text container -- class str-- and lists containing multiple strings. One of the advantages of the str class is that, to the programmer, strings in your code may be treated in a manner that is similar to how numbers are treated. Just like ints, floats, a string object (i.e., variable) may be initialized with a literal value or the contents of another string object. String objects may also be added together (concatenation) and multiplied by an integer (replication). Strings may also be compared for “equality” and arranged into some order (e.g., alphabetical order, ordering by number of characters, etc.). Finally, strings may be placed in containers which can then be passed as arguments to functions for more complex manipulations.

Write an interactive Python program composed of several functions that manipulate strings in different ways. Your main() function prompts the user for a series of strings which are placed into a list container. The user should be able to input as many strings as they choose (i.e., a sentinel-controlled loop). Your main function will then pass this list of strings to a variety of functions for manipulation (see below).

The main logic of your program must be included within a loop that repeats until the user decides he/she does not want to continue processing lists of strings. The pseudo code for the body of your main() function might be something like this:

# Create the main function

def main():
    # declare any necessary variable(s)


    # // Loop: while the user wants to continue processing more lists of words
    #     
    #     // Loop: while the user want to enter more words (minimum of 8)
    #         // Prompt for, input and store a word (string) into a list
    #         // Pass the list of words to following functions, and perform the manipulations

    #         // to produce and return a new, modified, copy of the list.
    #         // NOTE: None of the following functions can change the list parameter it
    #         // receives – the manipulated items must be returned as a new list.
    #
      # // SortByIncreasingLength(…)
      # // SortByDecreasingLength(…)
      # // SortByTheMostVowels(…)
      # // SortByTheLeastVowels(…)
      # // CapitalizeEveryOtherCharacter(…)
      # // ReverseWordOrdering(…)
      # // FoldWordsOnMiddleOfList(…)
    #     // Display the contents of the modified lists of words
    #
    # // Ask if the user wants to process another list of words

Deliverable(s):

Your deliverable should be a Word document with screenshots showing the sample code you have created, and discuss the issues that you had for this project related to AWS and/or Python IDE and how you solved them.

Submit the program you develop including captured output. Also turn in screen captures from running your program inputting, as a minimum, three (3) sets word lists (no fewer than 8 words per list).

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Thanks for the question.

Here is the completed code for this problem.  Let me know if you have any doubts or if you need anything to change.

Thank You !!

================================================================================================


def SortByIncreasingLength(word_list):
    temp_word_list=[]
    for word in word_list:temp_word_list.append(word)
    return list(sorted(temp_word_list,key = lambda word:len(word),reverse=False))
def SortByDecreasingLength(word_list):
    temp_word_list=[]
    for word in word_list:temp_word_list.append(word)
    return list(sorted(temp_word_list,key = lambda word:len(word),reverse=True))
def SortByTheMostVowels(word_list):
    temp_word_list=[]
    for word in word_list:temp_word_list.append(word)
    return list(sorted(temp_word_list,key = lambda word:word.lower().count('a')+ \
        word.lower().count('e')+word.lower().count('i')+word.lower().count('o')+word.lower().count('u'),reverse=True))

def SortByTheLeastVowels(word_list):
    temp_word_list=[]
    for word in word_list:temp_word_list.append(word)
    return list(sorted(temp_word_list,key = lambda word:word.lower().count('a')+ \
        word.lower().count('e')+word.lower().count('i')+word.lower().count('o')+word.lower().count('u'),reverse=False))

def CapitalizeEveryOtherCharacter(word_list):
    temp_word_list = []
    for word in word_list: temp_word_list.append(''.join([word[i].lower() if i%2==0 else word[i].upper() for i in range(len(word))]))
    return temp_word_list

def ReverseWordOrdering(word_list):
    temp_word_list = []
    for word in word_list:
        word=[l for l in word]
        word.reverse()
        temp_word_list.append(''.join(word))
    return temp_word_list

def FoldWordsOnMiddleOfList(word_list):
    # not clear as how this works
    pass


def main():

    while True:
        word_list=[]
        while True:
            word=input('Enter a word (hit enter to stop): ')
            if word=='':break
            else:word_list.append(word)

        print('Here are your words: ',word_list)
        print('Sort By Increasing Length: ',SortByIncreasingLength(word_list))
        print('Sort By Decreasing Length: ', SortByDecreasingLength(word_list))
        print('Sort By Most Vowels : ', SortByTheMostVowels(word_list))
        print('Sort By Least Vowels : ', SortByTheLeastVowels(word_list))
        print('Capitalize Every Other Character: ',CapitalizeEveryOtherCharacter(word_list))
        print('Reverse Word Ordering: ',ReverseWordOrdering(word_list))
        print()
        again=input('Do you want to process another list of words (yes or no)? ')
        if again.lower()=='yes':continue
        else:break

main()

======================================================================================

thanks !

Add a comment
Know the answer?
Add Answer to:
Python 3 coding with AWS/Ide. Objective: The purpose of this lab is for you to become familiar with Python’s built-in te...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python 3 coding with AWS/IDLE. DDI&T a Python program to input, store, and process hourly temperatures for each hour...

    Python 3 coding with AWS/IDLE. DDI&T a Python program to input, store, and process hourly temperatures for each hour of the day (i.e., 24 temperatures). Your program should be divided logically into the following parts: In function main() declare an empty List container:          HourlyTemperatures = []     Pass the empty HourlyTemperatures list to a function, GetTemperatures(HourlyTemperatures)          This function must interactively prompt for and input temperatures for each of the 24 hours in a day (0 through 23). For each temperature that...

  • Program must be in Python 3. Write a program that prompts the user to enter two...

    Program must be in Python 3. Write a program that prompts the user to enter two strings and then displays a message indicating whether or not the first string starts with the second string. Your program must satisfy the following requirements. 1. Your program must include a function called myStartsWith that takes two string parameters. This function returns True if the rst string starts with the second string and returns False otherwise. 2. Your program must include a main function...

  • Write a program IN PYTHON that checks the spelling of all words in a file. It...

    Write a program IN PYTHON that checks the spelling of all words in a file. It should read each word of a file and check whether it is contained in a word list. A word list available below, called words.txt. The program should print out all words that it cannot find in the word list. Requirements Your program should implement the follow functions: main() The main function should prompt the user for a path to the dictionary file and a...

  • Hi, I need some help finishing the last part of this Python 1 code. The last...

    Hi, I need some help finishing the last part of this Python 1 code. The last few functions are incomplete. Thank you. The instructions were: The program has three functions in it. I’ve written all of break_into_list_of_words()--DO NOT CHANGE THIS ONE. All it does is break the very long poem into a list of individual words. Some of what it's doing will not make much sense to you until we get to the strings chapter, and that's fine--that's part of...

  • C++ Lab 1. Read in the contents of a text file up to a maximum of...

    C++ Lab 1. Read in the contents of a text file up to a maximum of 1024 words – you create your own input. When reading the file contents, you can discard words that are single characters to avoid symbols, special characters, etc. 2. Sort the words read in ascending order in an array (you are not allowed to use Vectors) using the Selection Sort algorithm implemented in its own function. 3. Search any item input by user in your...

  • IN PYTHON CODE Question #1 Write a function capital that has one argument: strlist that is...

    IN PYTHON CODE Question #1 Write a function capital that has one argument: strlist that is a list of non-empty strings. If each string in the list starts with a capital letter, then the function should return the value True. If some string in the list does not start with a capital letter, then the function should return the value False You may use any of the string functions that are available in Python in your solution, so you might...

  • Python 3.7 Coding assignment This Program should first tell users that this is a word analysis...

    Python 3.7 Coding assignment This Program should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file....

  • ** Language Used : Python ** PART 2 : Create a list of unique words This...

    ** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...

  • PLEASE DO THIS IN PYTHON!! 1.) Goal: Become familiar with The Python Interpreter and IDLE. Use...

    PLEASE DO THIS IN PYTHON!! 1.) Goal: Become familiar with The Python Interpreter and IDLE. Use IDLE to type, compile, and run (execute) the following programs. Name and save each program using the class name. Save all programs in one folder, call it Lab1-Practices. Save all programs for future reference as they illustrate some programming features and syntax that you may use in other labs and assignments. ================================== Program CountDown.py =================================== # Program CountDown.py # Demonstrate how to print to...

  • 6.6 Warm up: Parsing strings (Python 3) (1) Prompt the user for a string that contains...

    6.6 Warm up: Parsing strings (Python 3) (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT