Python:
Write a function named "sort_by_length" that takes a list/array of strings as a parameter and sorts the strings by their length
def sort_by_length(strings):
strings.sort(key=lambda x: len(x))
strings = ['hi', 'hello', 'a', 'how', 'are', 'you?']
print("original list:", strings)
sort_by_length(strings)
print("sorted list:", strings)
Python: Write a function named "sort_by_length" that takes a list/array of strings as a parameter and...
JavaScript Write a function named "sort_by_length" that takes a list/array of strings as a parameter and sorts the strings by their length
Python: Write a function named "sort_by_average_rating" that takes a list/array of key-value stores as a parameter where each key-value store has keys "ratings", "budget", and "box_office" where budget and box_office are integers and ratings is a list of integers. Sort the input based on the average of the values in "ratings"
Write a method named avgLength which takes an array of Strings as an input parameter and returns a double. The method should calculate and return the average length of all the strings in the array (in java langauge)
using python, Write a function named displayReverse that takes a list as a parameter and DISPLAYS the contents of the list to the screen in reverse. Submit the code and a screenshot of the program running in Linux
python: Write a function named "write_values" that takes a key-value store mapping strings to strings as a parameter and writes the values of the input to a file named "persuade.txt" with one element per line. If a file named "persuade.txt" already exists it must be overwritten. The function should not return any value
write a function firstLetterWords(words) that takes as a parameter a list of strings named words and returns a dictionary with lower case letters as keys. But now associate with each key the list of the words in words that begin with that letter. For example, if the list is ['ant', 'bee', 'armadillo', 'dog', 'cat'], then your function should return the dictionary {'a': ['ant', 'armadillo'], 'b': ['bee'], 'c': ['cat'], 'd': ['dog']}.
Write a python function alt which takes a list of strings myList as a parameter. alt then returns two strings s1 and s2 as a tuple (s1, s2). Here s1 is the concatenation of the strings in myList in even index positions, and s2 is the concatenation of the strings in myList in odd index positions. (List starts at index 0) For example, if myList = [‘My’, ‘kingdom’, ‘for’, ‘a’ , ‘horse’], then s1 = ‘Myforhorse’ and s2 = ‘kingdoma’.
** In Python ** Write a function named "tweets" that takes a string as a parameter and returns the number of tweets required to tweet the input to the world. Note: The maximum length for a single tweet is 280 characters Please provided an explanation.
Write a function that takes an array of C-strings as a parameter and the number of elements currently stored in the array, and returns a single C-string pointer that is the concatenation of all C-strings in the array. Note: The function must take 2 parameters and return "char *". Any other ways will cause some deduction of points.
Using Python, write a function named add_surname that takes as a parameter a list of first names. **It should use a list comprehension** to return a list that contains only those names that start with a "K", but with the surname "Kardashian" added to each one, with a space between the first and last names. For example, if the original list is: ``` ["Kiki", "Krystal", "Pavel", "Annie", "Koala"] ``` Then the list that is returned should be: ``` ['Kiki Kardashian',...