Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use py only Complete the get_unique_words ( ) function that takes a single string parameter called text. This string contains words separated by a single

use py only

image text in transcribedimage text in transcribedimage text in transcribed
Complete the get_unique_words ( ) function that takes a single string parameter called text. This string contains words separated by a single space character. Some words will end with punctuation. You can assume that text will contain at least 1 word, and that the only punctuation used will be: , . ! ? ; The function should convert all the alphabetical characters in text to lowercase. The function should then return a list of all the unique words in text sorted alphabetically. Words that end in punctuation should have that punctuation removed. Some examples of the function being called are shown below. For example: Test Result text = "The quick brown fox jumps over the lazy dog!" The unique words are: ['brown', 'dog', 'fox', 'jumps', 'lazy', 'over', 'quick', 'the' ] print ("The unique words are:", get_unique_words(text) ) text = "Around the world, around the world." The unique words are: ['around', ' the', 'world' ] print ("The unique words are:", get_unique_words(text) ) text = "Spanish bombs, yo te quiero infinito. Yo te quiero, oh mi corazon." The unique words are: ['bombs', 'corazon', 'infinito', 'mi', 'oh', 'quiero', 'spanish', 'te', 'yo' ] print ("The unique words are:", get_unique_words (text) )Complete the add_adjacent_list_values ( ) function that takes a list of numerical values as a parameter named numbers_list. If the list has 2 or more elements, then each element of the list is updated so that it is equal to the sum of itself and the next element. In other words, the first element will be updated so that it has the value of the sum of the first and second elements. The second element will be updated so that it has the value of the sum of the second and third elements and so on. The last element of the list is updated, so that it has the value of the sum of itself and the original value of the first element. If the list has less than 2 elements, it remains unchanged. Note, that the function does not return a new list - the parameter list is modified within the function only. Some examples of the function being called are shown below. For example: Test Result numbers_list = [1, 2, 3 , 4, 5] Before: [1, 2, 3, 4, 5] print ("Before:", numbers_list) After: [3, 5, 7, 9, 6] add_adjacent_list_values (numbers_list) print ("After:", numbers_list) numbers_list = [2.5, 3] Before: [2.5, 3] print ("Before:", numbers_list) After: [5.5, 5.5] add_adjacent_list_values (numbers_list) print ("After:", numbers_list) numbers_list = Before: print ("Before:", numbers_list) After: add_adjacent_list_values (numbers_list) print ("After:", numbers_list)Define the get_fail_pass_ave rage( ) function which is passed a list of integers called number_list as a parameter where each integer represents a mark out of 100. The function returns a Python list made up of the average of all the marks which are less than 50, followed by the average of all the marks which are 50 or more (both averages are rounded to the nearest whole number). If there are no fail marks then the average fail mark should be set to 1 and if there are no pass marks then the average pass mark should be set to -1. Some examples of the function being called are shown below. For example: m print(get_fail_pass_average([63, 65, 331)) [33, 64] print(get_fail_pass_averagel[63, 62, 100, 1001)) print(get_fail_pass_averagel[33, 42, 20, 101)) [26, -1]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions