Exemplo n.º 1
0
__author__ = "John Doe"

def count_vowels(test_string):
	"""
	Problem Statement-
		Given test_string return the number of vowels in the string.
    
	Input-
	a. test_string: str
    		Normal String.
    		Consists of alphanumeric characters.
    
	Output-
	    The function should return an integer value
		after counting the number of vowels in the string.

	Example-
		>>> count_vowels("Guido van Rossum")
		6

		>>> count_vowels("CommuniPy")
		3
	"""
	pass

if __name__ == '__main__':
	import doctest
	doctest.testmod(verbose=True)
	from test_strings_beginner import test_one
	test_one('test_count_vowels')
Exemplo n.º 2
0
__author__ = "John Doe"


def sample_problem(sample_arg):
    """
    Problem Statement-
        This is a sample problem that takes a sample argument.

    Input-
        a. sample_args: str
            Its the sample argument that should be returned.

    Output-
        The function should return sample_arg

    Example-
        >>> sample_problem("Sample Argument")
        'Sample Argument'

        >>> sample_problem("Sample Argument2")
        'Sample Argument2'
    """
    pass


if __name__ == "__main__":
    import doctest
    doctest.testmod(verbose=True)
    from test_strings_beginner import test_one
    test_one('test_sample_problem')
Exemplo n.º 3
0
    """
	Problem Statement-
		Given test_string, return test_string
		with vowels replaced by the character '!'.
    
	Input-
	a. test_string: str
    		The string which should be replaced.
    		Consists of alphanumeric characters,
    		punctuation etc.
    
	Output-
	    The function should return test_string with
		the vowels replaced by the character '!'.

	Example-
		>>> replace_vowels("CommuniPy")
		'C!mm!n!Py'

		>>> replace_vowels("Vowels")
		'V!w!ls'
	"""
    pass


if __name__ == '__main__':
    import doctest
    doctest.testmod(verbose=True)
    from test_strings_beginner import test_one
    test_one('test_replace_vowels')
Exemplo n.º 4
0
		check if one is palindrome of the other.
		Palindrome: Same string if reads backwards.
    
	Input-
	a. test_string: str
    		Consists of alphanumeric characters.

	b. test_string2: str
    		Consists of alphanumeric characters.
    
	Output-
	    The function should return True or False
		if both strings are palindromes.


	Example-
		>>> is_palindrome("Radar", "radaR")
		True

		>>> is_palindrome("Level", "Stats")
		False
	"""
    pass


if __name__ == '__main__':
    import doctest
    doctest.testmod(verbose=True)
    from test_strings_beginner import test_one
    test_one('test_is_palindrome')
Exemplo n.º 5
0
    """
    Problem Statement-
        Given test_string, return the reverse of
        test_string.
        Try a iterative approach, list reverse aproach and
        a slicing approach.
    
    Input-
        a. test_string: str
            The string which should be reversed.
            Consists of alphanumeric characters,
            punctuation etc.
    
    Output-
        The function should return test_string reversed.

    Example-
        >>> reverse_string("CommuniPy")
        'yPinummoC'

        >>> reverse_string("esreveR")
        'Reverse'
    """
    pass

if __name__ == '__main__':
    import doctest
    doctest.testmod(verbose=True)
    from test_strings_beginner import test_one
    test_one('test_reverse_string')
Exemplo n.º 6
0
def split_string_pairs(test_string):
    """
    Problem Statement-
        Given a string, split it by pairs of two character. If the last character
        is not a pair, append _ to the last one to make it a pair. Return
        an empty list if string is empty.

    Input-
        a. test_string: str
            Its string which should be splitted, it can consist of any character.

    Output-
        The function should return the pair as a list.

    Example-
        >>> split_string("abc")
        ['ab', 'c_']

        >>> split_string("abcd")
        ['ab', 'cd']
    """
    pass


if __name__ == "__main__":
    import doctest
    doctest.testmod(verbose=True)
    from test_strings_beginner import test_one
    test_one('test_split_string_pairs')
Exemplo n.º 7
0
    """
	Problem Statement-
		Given test_string check the length of the string
		and return if the number of characters in even
		or odd.
    
	Input-
	a. test_string: str
    		Normal String.
    		Consists of alphanumeric characters.
    
	Output-
	    The function should return 'Even' or 'Odd'
		after checking the number of characters.

	Example-
		>>> even_or_odd("Even")
		'Even'

		>>> even_or_odd("CommuniPy")
		'Odd'
	"""
    pass


if __name__ == '__main__':
    import doctest
    doctest.testmod(verbose=True)
    from test_strings_beginner import test_one
    test_one('test_even_or_odd')