Ask your own question, for FREE!
Mathematics 23 Online
OpenStudy (anonymous):

is anyone good in computer science please help me out with writing 3 codes pleasee

OpenStudy (anonymous):

i'm trying to learn python this summer... sorry, can't help... yet....

OpenStudy (anonymous):

if i give you a code would you be able to inrpret what it means because i am strictly all math and stats based student and this is my first computer class which is really confusing for me

OpenStudy (this):

what is the code?

OpenStudy (anonymous):

yeah... lessee it....

OpenStudy (anonymous):

it says the parameter name is convert_to_upper: (list of strs) -> NoneType and the description is Convert the strs in the given list to uppercase.

OpenStudy (this):

i have no idea sorry

OpenStudy (anonymous):

post it in computer science... i'm sure you'll get better response there...:) btw.... what language?

OpenStudy (anonymous):

and its in python but yeah i am for the past 2 days but no one is replying

OpenStudy (anonymous):

hmm... i guess i'll come up to that problem sometime to then...:(

OpenStudy (anonymous):

lol but yeah do you have any clue in this or noo

OpenStudy (anonymous):

no clu.... sorry...:(

OpenStudy (anonymous):

paste the code here

OpenStudy (anonymous):

it says the parameter name is convert_to_upper: (list of strs) -> NoneType and the description is Convert the strs in the given list to uppercase.

OpenStudy (anonymous):

based on the pseudo code you asked: it simply takes a list of characters such as a - z and converts them to upper case, so a would become A, b would become B

OpenStudy (anonymous):

yeah exactly

OpenStudy (anonymous):

yeah so what do you need to know exactly?

OpenStudy (anonymous):

how do i make this code run

OpenStudy (anonymous):

are you writing it or is it given

OpenStudy (anonymous):

like for this first code i did by my self and it said the parameter name is remove_vowels: (str) -> str and the description was Return a new str that is identical to the input str except that the vowels have been removed. Vowels are the letters a,e,i,o,u. We do not consider y a vowel. and then i wrote my code on wing vowels = 'aeiou' def remove_vowels(a): return ''.join(c for c in a if c not in vowels) and that worked and yeah i have to make it

OpenStudy (anonymous):

but i dont get how to do this code and this other one

OpenStudy (anonymous):

I work with java, apart from the syntax difference maybe I could help you out, since no one else knows python here. Try me!

OpenStudy (anonymous):

yes could you please help me out it would be really appreciatedd

OpenStudy (anonymous):

il try my best, post it here

OpenStudy (anonymous):

do you understand that code though? i need help on this code it says the parameter name is convert_to_upper: (list of strs) -> NoneType and the description is Convert the strs in the given list to uppercase.

OpenStudy (anonymous):

do you have to write this method?

OpenStudy (anonymous):

yess

OpenStudy (anonymous):

what is NoneType ? and does it return a string?

OpenStudy (anonymous):

no it is suppose to return a nonetype

OpenStudy (anonymous):

what is a nonetype?

OpenStudy (anonymous):

it returns nothing and just the capital letters

OpenStudy (anonymous):

oh i see, in java we would write it as convert_to_upper(list of strings) { strings.toUpperCase(); }

OpenStudy (anonymous):

what is your code?

OpenStudy (anonymous):

oo i dont know how to use python and needed someone to help me how to write it on that

OpenStudy (anonymous):

try something like this: >>> [x.lower() for x in ["A","B","C"]] ['a', 'b', 'c'] >>> [x.upper() for x in ["a","b","c"]] ['A', 'B', 'C']

OpenStudy (anonymous):

so: for item in L: item.upper()

OpenStudy (anonymous):

its not working my friendd

OpenStudy (anonymous):

go here, it shows you how to loop over the lists. http://effbot.org/zone/python-list.htm

OpenStudy (anonymous):

The reason javawarrior's code won't work is that strings are immutable; you can write over them, but you can't change them. So the line should say item = item.upper() instead of just item.upper().

OpenStudy (anonymous):

And don't forget to return L once you're done. Actually, javawarrior's first code would work as long as you return that list: def converter(string_list): return [s.upper() for s in string_list]

OpenStudy (anonymous):

hey @shandelman could you help me out with this code as well please?

OpenStudy (anonymous):

it says the parameter name is get_x_strs: (list) -> list of strs and the description is Given a list l, return a new list that contains only the elements of l that are strs that contain the character 'x'. Do not alter l.

OpenStudy (anonymous):

so what i did was first def get_x_strs (list_strings): return (x for s in list_strings) but it doesnt work

OpenStudy (anonymous):

Sure. The first thing I'll say is that, while a lot of functions can be written in Python in one line, they certainly don't HAVE to be, and they're often more easily understood and read if you can spread them out to multiple lines. For this problem, it might be best to reword it. You're given a list of strings, and what you need to do is walk through the list of strings, and for each string, you need to check if an 'x' is in it. If it is, you're going to add that string to a result list, and otherwise, you're just going to ignore it and keep going. So you're right in that a for loop will make your life easier. We also need some other list to stick all the words with x in them. So the general code will look like this: def get_x_strs(list_strings): results = [] # This is where our strings with 'x' will go for word in list_strings: if _________________: # Here, we want to check if the word contains an x. The 'in' keyword makes this pretty easy. _______________ #Here, we want to put the word into the results list. Again, the append() method is what is needed. return results See if you can fill in the rest yourself.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!