Write a function that takes a string as a parameter and returns a new string that is the reverse of the old string. Python
from test import testEqual
def reverse(s):
return s
testEqual(reverse("hello"),"olleh")
testEqual(reverse("l"),"l")
testEqual(reverse("follow"),"wollof")
testEqual(reverse(""),"")
from test import testEqual
def reverse(s):
result = ""
for x in s:
result = x + result
return result
testEqual(reverse("hello"),"olleh")
testEqual(reverse("l"),"l")
testEqual(reverse("follow"),"wollof")
testEqual(reverse(""),"")
Write a function that takes a string as a parameter and returns a new string that...
Using C,
Write a function reverse which takes a string as an argument, reverses the string and returns the reversed string. Note; you should not return a string that you created inside the reverse function! For example: Test char str[]-"hello" printf("%s", reverse (str)); Result olleh
in python Write a function that takes a string as an argument returns a new string that is that string repeated 3 times.
Write a recursive function bag_to_set that takes a list as a parameter and returns a new list in which the values that were in the old list appear only once in the new list (the order should be preserved). Sample data: Old list: [4, 5, 3, 4, 5, 2, 2, 4] New list: [4, 5, 3, 2] The function signature is: def bag_to_set(bag): """ ------------------------------------------------------- Copies elements of a bag to a set. Use: new_set = bag_to_set(bag) ------------------------------------------------------- Parameters: bag...
def zigzag(text): Implement a function that takes a string and returns a new string that is a zig-zag rearrangement of it like the one in the examples below. • Parameters: text is a string (no validation needed) • Examples: zigzag('12345678') → '18273645' zigzag('123456789') → '192837465' zigzag('abcdefgh') → 'ahbgcfde' zigzag('GeorgeMason') → 'GneoosragMe' Remember, do not call input() or print() You must have at least one loop in each function. You cannot import any module. You cannot call any Python function...
def zigzag(text): Implement a function that takes a string and returns a new string that is a zig-zag rearrangement of it like the one in the examples below. • Parameters: text is a string (no validation needed) • Examples: zigzag('12345678') → '18273645' zigzag('123456789') → '192837465' zigzag('abcdefgh') → 'ahbgcfde' zigzag('GeorgeMason') → 'GneoosragMe' in python
** 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.
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.
Python Write a function list_copy(l) that takes a list as a parameter and returns a copy of the list using a list comprehension. please provide unittest
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 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.