#source code in python:
def stringsort(data):
val=[i for i in data]
newval=sorted(val)
return "".join(newval)
print("cat becomes:",stringsort("cat"))
print("dog becomes:",stringsort("dog"))
#output:
Python follows indentaion use tabspace for indentaion type the code as the above screenshoot by using tab space otherwise it gives indentation error..
#if you have any doubt comment below...if you like give thumbs up...
python 1. Write a function that takes in a string and returns the string sorted For...
Write a python function that takes a string as input, and returns a dictionary of frequencies of all the characters in the string. For example: freq("dabcabcdbbcd") would return {"d":3, "a":2, "b":4, "c":3}. Then write a driver to demonstrate your function.
in python Write a function that takes a string as an argument returns a new string that is that string repeated 3 times.
IN PYTHON 3) Number of Words Write a function numWords() which takes in a string can prints the number of words in the string. You can assume that words will only be separated with spaces, commas, and periods. "hello, world" -> 2 "this is cool" -> 3 4) Is Sorted Write a function isSorted() which takes in an list of integers and returns true if the numbers are sorted from smallest to largest.
Write a function called double_str that takes a string argument and returns a new string that has all of the same characters as the argument, except each one is repeated twice. For example: double_str('dog') --> 'ddoogg' looking for python coding below is what I have so far double_str = 'robert' double_str 'robert' for i in range(len(double_str)): print(double_str[i])
Write a function maxList that takes in a list of integers as argument and returns their highest. You may not use the max() or the sorted() Python built-in functions.
ANSWER USING PYTHON Write a recursive function that takes 2 sorted lists as arguments and returns a single, merged sorted list as a result. For example, if the two input lists are [0, 2, 4, 6, 8] and [1, 3, 5, 7, 9], the returned result should be [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]. Remember that you can add lists in Python using the + operator ([0] + [1,2,3] = [0,1,2,3]) and can take slices of...
Python 3: Write a function called every_other_character() that takes in a string and returns a new string with every other character removed. That is, the new string will include the first, third, fifth, etc. letters of the given string. Must use a while or for loop in the solution.
1 write a Python function that takes in a list of integers and returns maximum and minimum values in the list as a tuple. Hint (can be done in one pass, you are not allowed to use built-on min and max functions.)max, min = find_max_min(my_list):2 write a Python function that takes in a list of integers (elements), and an integer number (num). The functions should count and return number of integers in elements greater than, less than, and equal to...
Write a function that takes a numerical vector and returns the sorted vector. To detect whether a vector is sorted, use diff() and all() (or any()). So long as the vector is not sorted, pick two random positions from the vector and swap them. (in matlab program) You must use a while loop to solve this problem. Do not use for loops. Do not use sort(), min(), max(), sortrows(), unique() functions. >> v = sortbyrandomswaps( [39 25 91 71] )...
Python Function Name: unscramble Parameters: a string Returns: a string Description: Write a function, unscramble, that takes an input string, and returns a the unscrambled version of the argument. To unscramble the string: When the string has an odd number of characters, middle character is the first character in the unscrambled result Pairs of remaining characters are added to the result, proceeding left to right from inner-most to outer-most characters. Example Call: unscramble('3cis1') Expected result: ics31 Example Call: unscramble('ocicssol') Expected...