0

How do you create a code for Acronyms and one for box of numbers, with arrays? In python

trying to help out a friend

4th May 2018, 7:38 AM
Amadeus
Amadeus - avatar
17 Answers
+ 1
Hello Amadeus, In order for us to help you, can you be more specific an tell us: 1. what the code for Acronyms do exactly? 2. what the code for box of number do?
4th May 2018, 9:09 AM
Ulisses Cruz
Ulisses Cruz - avatar
0
it involves writing a program called acronym.py, to obtain an acronym from a given sentence. Taking the first letter of each and every significant word, besides useless ones like "the", "and". The program should begin by prompting the user to enter a list of words to be ignored, and then it should ask the user, the sentence the acronym should be generated from.
4th May 2018, 10:38 AM
Amadeus
Amadeus - avatar
0
Louis that does everything i said?
4th May 2018, 11:01 AM
Amadeus
Amadeus - avatar
0
Amadeus I want to help you create the code yourself instead of just doing it for you. I believe that way you benefit more. So to start you should gather the informations you have: 1. An Acronym usually is just the first letters of a sentence. (as 'world wide web' => WWW) 1.1 This means you need to split the sentence or string in it's words and than get the first letter of each word. 1.2 capitalize each letter. 2. There are some words you want to skip. (as 'the world and wide web' => WWW) 2.1 as you loop through the words you should also have a list of words to skip. Here is how I would do it: 1. create a variable to hold the acronym; 2. get the words to skip and save them in a list; 3. get the sentence or string; 4. split the sentence in it's words and turn it into a list; 5. loop through the new list of words you got in point 4; 6. create an if statement inside the loop to skip the words in the list of point 2; 7. in each iteration grab the first character in the words, capitalize it and add it to the variable that holds the acronym; 8. print out the acronym outside the loop; Let me know if you have any doubt.
4th May 2018, 11:03 AM
Ulisses Cruz
Ulisses Cruz - avatar
0
Ulisses Cruz, I'm not the one making it '^^, it's for my friend
4th May 2018, 11:10 AM
Amadeus
Amadeus - avatar
0
Well, Amadeus, if it is for a friend help him do it, but don't do it for him. I believe that's what a friend should do. ; - )
4th May 2018, 11:13 AM
Ulisses Cruz
Ulisses Cruz - avatar
0
yeah I get that, thanks for the help, i sent her your instructions. could you look at another question?
4th May 2018, 11:15 AM
Amadeus
Amadeus - avatar
0
Yes, what question?
4th May 2018, 11:16 AM
Ulisses Cruz
Ulisses Cruz - avatar
0
Amadeus Is that the code for a game?
4th May 2018, 11:52 AM
Ulisses Cruz
Ulisses Cruz - avatar
0
making a box of numbers i guess
4th May 2018, 11:55 AM
Amadeus
Amadeus - avatar
0
wish i could send you the pdfs
4th May 2018, 11:57 AM
Amadeus
Amadeus - avatar
0
Yes. It would be useful. Because there are still missing data. For example, what is grid? Is it an array? EDITED: I mean the parameter passed in to the functions.
4th May 2018, 12:01 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
I'm not sure, was hoping you'd understand
4th May 2018, 12:02 PM
Amadeus
Amadeus - avatar
0
Ok, I think I understand it know. It is an array. The first function receives the array and initializes it with all zeros the secont prints it out with formating and all. But the othersm let me believe that this is a game. If there is a 0 value in the grid or two adjacent values are equal you lose. the next funtion calculates when you win. the next returns a copy of the grid. and the last do as its name says.
4th May 2018, 12:41 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
I guess that if I want to help without creating the code for you I have to tell you the main concepts. I think the main thing is the structure of the array.
4th May 2018, 12:43 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
hmm i see
4th May 2018, 12:46 PM
Amadeus
Amadeus - avatar
- 1
write a module of utility functions called util.py for manipulating 2-dimensional arrays of size 4x4. The functions needed are: def create underscore grid(grid): """create a 4x4 array of zeroes within grid""" def print underscore grid (grid): """print out a 4x4 grid in 5-width columns within a box""" def check underscore lost (grid): """return True if there are no 0 values and there are no adjacent values that are equal; otherwise False""" def check underscore won (grid): """return True if a value >=32 is found in the grid; otherwise False""" def copy underscore grid (grid): """return a copy of the given grid""" def grid underscore equal1 (grid1, grid2): """check if 2 grids are equal - return boolean value""" these functions are using docstrings. then use the testutil.py test program to test your functions. This program takes a single integer input value and runs the corresponding test on your module
4th May 2018, 11:39 AM
Amadeus
Amadeus - avatar