Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with finishing these functions by Python code and the code should be satisfied with these tests import unittest import re def string_splitting (
Need help with finishing these functions by Python code
and the code should be satisfied with these tests
import unittest import re def string_splitting ( input_str, delim.): Split the given.string, using the delimiter passed as a paramater. ...Ex. -code-block::python ... >>> string_splitting ("Under.the.Mirabeau flows the. Seine. And our amours",:'.') ....... ['Under', 'the', 'Mirabeau','flows', 'the', 'Seine', "And','our', . 'amours'] ... Topics: 'split() method ...param input_str: the string to be splitted ..:type input_str: str :param delim: delimiter ...:type delim: str :return: an array of string tokens urtype: list pass def matches (input_str, regexp): Return a list of all.substrings that match the given regexp. Ex. code-block::python >>> matches ("abc\tdelfabcde12fabc\t345def", r' (abc\t]\d{2}}') ['abc\t', '12', 'abc\t','34'] Topics: re.findall() method TT TT 11 pass Idef filter (.tpl ): Given a tuple. (immutable. list) of strings, return another list. where: ....*.words that have at least.10.letters are kept unchanged *. words that have less than 10 letters are replaced with the word length: (character.count) ...Ex.. code-block::python "parrott")) >>> filter ( ("lion", "hippopotamus", "kangaroo","tyrannosaurus", [4,'hippopotamus',:8,'tyrannosaurus', :7] ....... Topics: length of sequences and strings, if-else ternary expression, list comprehensions :param.tpl:.atuple of strings :type tpl: tuple :return: a list of strings :rtype: list pass def reverse_minus_last(.tpl ): .... Given a list of values, return.a. second list that meets the given criteria: ....*.it contains all elements of the first list, except the last one the order is reversed ....EX. code-block::python :>>>reverse_minus_last ((1,2,3,4,.5)) .. [4,3,2,1] .... Topics: ranges, subcripting sequences with positive and negative indexes, . 'reversed()' and 'list().functions ...param. tpl: tuple of integers. .:type.tpl: tuple ....:return: a list of integers. crtype: list pass def even_odd( tpl ): ...". Given.a. tuple of integers, return another.list. where even integers are replaced with a.0, and odd integers, ..with.a.1. - EX. code-block::python >>>. even_odd ((9,7,4,-3)) ...[1,1,0,1] .. Topics: list comprehensions :param.tpl: tuple of integers. ...:type.tpl: tuple :return: a list of Os.and. 1s. :rtype: list pass def differences (.tpl.): . """.Given a tuple of integers of size. :math: 'n , return a list where each of the math: 'n-1'.. elements is the diffence between two consecutive elements of the first.list. Ex. code-block:: python >>> differences ((9,7, 4,:3)) ... [2,3,1] Topics: list. comprehensions ...param. tpl: tuple of integers. ..:type.tpl: tuple return: a list of integers crtype: list pass def string_from_different types ( inputi, input2 ): ...Given two inputs of different types. (say: a string and an integer, or an integer and a float, ...), .... construct and return a string that concatenate the two values in a single string. ...EX. code-block:: python :>>>.string_from_different_types (-5,2.3.) "52.31 Topics: 'str. formato function. param input1: any value :type input1: object :param. input2: any value ...:type input2: object :return: a string of the form.'Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started