Formulate a single python program that contains the following functions. Function 1: A function called frame_this
Fantastic news! We've Found the answer you've been seeking!
Question:
Function 1: A function called frame_this which takes a list of words as a parameter (list_of_words) and then prints those words inside a frame of asterisks (*). This function should not return anything, only print. Assume the maximum word length it will have is 5 letters, and ensure that the edges line up appropriately to make a straight line (note that even-lettered words may appear slightly off-center). For example, if it were passed the list of words 'Hello', 'World', 'in', 'a', 'Frame' it would print:
*********
* Hello *
* World *
* in *
* a *
* Frame *
*********
Important: no shortcuts (such as .center) - the purpose of this assignment is to think about how to add space to each side using what we have learned so far (consider calculating the spaces needed on each side based on the length of the word, and then using a loop to print the correct number of spaces).
Function 2: A function called get_average which takes a list of numbers (list_of_nums) and returns their average. Note that this function does not print anything, it only returns a number. Calculate the average as the sum of all items divided by the total number of items. The returned number should be rounded to the nearest whole number. For example, if passed the list 4,5,4,3 it would return the number 4.
Important: once again, you may not use any shortcuts (such as sum) - consider how you can use a loop to add all the items together to get the total and then divide the total by the number of items in the list.
Function 3: A function called draw_three which takes a list of cards (list_of_cards) and returns a list of the first three cards. Note that this function does not print anything, only returns a list of strings. Also note that it should handle any number of cards, not necessary a full deck, but you can safely assume it will be at least 3 cards. For example, if passed the list 'Ace of Hearts', 'Jack of Spades', '10 of Diamonds', 'Queen of Clubs', 'Ace of Clubs' the function would return ['Ace of Hearts', 'Jack of Spades', '10 of Diamonds'].
Function 4: A main function which contains three lists as follows:
List 1 called my_words that has these elements: 'Hello', 'apple', 'one'
List 2 called my_numbers that has these elements: 5, 6, 7, 9
List 3 called my_cards that has the elements: '2 of Hearts', '6 of Spades', 'Jack of Diamonds', 'Queen of Clubs', 'King of Clubs'
Your main function should call each of your other functions, as follows. Call frame_this and pass it the first list as an argument. Call get_average and pass it your second list as an argument, and print the returned value (either by calling your function from a print statement, or by storing the returned result and printing it). Call draw_three and pass it your third list as an argument, and print the returned list (either by calling your function from a print statement, or by storing the returned result and printing it).
Be sure to call your main function so that your program runs, using the standard python convention we have been using to start the main function. Also please be sure that all of your code is contained in either the main function or one of the 3 functions defined above (indentations are very important here).
Note that you are NOT taking any input. Your functions should be written so that they could handle different values being passed, but you should use the specific values provided above and your output should look exactly like this when you are finished:
*********
* Hello *
* apple *
* one *
*********
7
['2 of Hearts', '6 of Spades', 'Jack of Diamonds']
Related Book For
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young
Posted Date: