Re: Need help on a project To :"Create a class called BankAccount with the following parameters "
bu i have come up with a solution, that will work but encounter a problem in the set, giving set not manipulated correctly: def manipulate_data(kind, data): if kind == 'list': return list(data)[::-1] elif kind == 'set': return set(data) elif kind == 'dictionary': return dict.keys(data) manipulate_data("list", range(1,6)) manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"}) manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, "grapes": 45}) the thing now is the function to use in adding "ANDELA", "TIA", "AFRICA" pls 4give my use of language -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help on a project To :"Create a class called BankAccount with the following parameters "
wow thats true the code did not work -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help on a project To :"Create a class called BankAccount with the following parameters "
def manipulate_data(kind, data): if kind == 'list': return list(data)[::-1] elif kind == 'set': return set(data) elif kind == 'dictionary': return dict.keys(data) manipulate_data("list", range(1,6)) manipulate_data("set", {"a", "b", "c", "d", "e",}) manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, "grapes": 45}) just use a function to add "ANDELA", "TIA", "AFRICA" to the set, the u are don -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help on a project To :"Create a class called BankAccount with the following parameters "
thanks everyone, though it was very tough, but i thank GOD On Mon, Dec 28, 2015 at 11:29 PM, Cameron Simpson <c...@zip.com.au> wrote: > On 28Dec2015 01:34, Prince Udoka <princeud...@gmail.com> wrote: > >> bu i have come up with a solution, that will work but encounter a problem >> in the set, giving set not manipulated correctly: >> >> def manipulate_data(kind, data): >>if kind == 'list': >>return list(data)[::-1] >>elif kind == 'set': >>return set(data) >>elif kind == 'dictionary': >>return dict.keys(data) >> manipulate_data("list", range(1,6)) >> manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA", >> "AFRICA"}) >> manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, >> "grapes": 45}) >> >> the thing now is the function to use in adding "ANDELA", "TIA", "AFRICA" >> pls 4give my use of language >> > > You are very close. Let me remind you of the original task text: > > add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the > resulting set > > Your previous attempt (with hardwired values inside the function) actually > had code to do it. > > While you have pulled out all the hardwired values from the function > (good) and put them in the external calls, note that the task explicitly > says "add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set". So _those_ > values _are_ supposed to be hardwired inside the function - they are a > fixed part of the task. So move them back in, as in your previous attempt. > > There is some ambiguity in that part of the question: should you return a > _new_ set consistint of the original set plus the three new values, or > simply add the three values to the original set? Your prior code modified > the original set, which may fit the task specification. > > However, it is a common design objective that functions do not, > _normally_, modify their arguments. So, consider this code: > > set1 = {"a", "b", "c", "d", "e"} > set2 = manipulate_data("set", set1) > > After running this, set2 should look like this: > > {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"} > > (in some order -- sets are not ordered). However, what about set1? In your > current code, set1 is modified, so it will be the same. But you can imagine > that it would be more useful for the caller if set1 were unchanged. > > In python, the convention is usually that if a function returns the new > value then it should not modify the original. So you should probably > construct a copy of the original set and modify that: > > data = set(data) > ... add the new values ... > return data > > Cheers, > Cameron Simpson <c...@zip.com.au> > -- https://mail.python.org/mailman/listinfo/python-list
Re: Need help on a project To :"Create a class called BankAccount with the following parameters "
thanks mr cameron simpson, finally at i got the solution, God bless you: def manipulate_data(kind, data): if kind == 'list': for data in [1, 2, 3, 4, 5]: return data.reverse() elif kind == 'set': for data in {"a", "b", "c", "d", "e"}: data.add("ANDELA") data.add("TIA") data.add("AFRICA") return data elif kind == 'dictionary': for data in {"apples": 23, "oranges": 15, "mangoes": 3, "grape": 45}: return data.key() -- https://mail.python.org/mailman/listinfo/python-list
Re: please can i get help on this problem
sir does this make sense: def manipulate_data(item, fruits): if item == ["apples", "oranges", "mangoes", "grapes"]: for fruits in reversed(item): return item elif item == {"apples", "oranges", "mangoes", "grapes"}: for fruits in item: fruits.append("ANDELA", "TIA", "AFRICA") return item if item == {"apples": 23, "oranges": 15, "mangoes": 3, "grapes": 45}: return dict.keys() -- https://mail.python.org/mailman/listinfo/python-list
please can i get help on this problem
Create a function manipulate_data that does the following Accepts as the first parameter a string specifying the data structure to be used "list", "set" or "dictionary" Accepts as the second parameter the data to be manipulated based on the data structure specified e.g [1, 4, 9, 16, 25] for a list data structure Based off the first parameter return the reverse of a list or add items `"ANDELA"`, `"TIA"` and `"AFRICA"` to the set and return the resulting set return the keys of a dictionary. here is my work, but i dont know what i ave done wrong: def manipulate_data(list_data, set_data): if list_data == ["apples", "orange", "mangoes"]: for set_data in reversed(set_data): return set_data elif manipulate_data(list_data == {"apples", "orange", "mangoes"}): list_data.append("ANDELA", "TIA", "AFRICA") for set_data in list_data: return set_data if manipulate_data(list_data == {"apples": 23, "oranges": 15, "mangoes": 3, "grapes": 45}): return list_data.keys() -- https://mail.python.org/mailman/listinfo/python-list
Re: please can i get help on this problem
gud day sir, please i have an assignment, nd i am just 2weeks in python; i tried the code i uploaded but its nt working plz help, i need guidiance -- https://mail.python.org/mailman/listinfo/python-list