QuestionQuestion

Transcribed TextTranscribed Text

1. Write a recursive function recHourglass() that takes two characters and two integers n and indent as parameters and prints an hour glass pattern using the characters. The first character is used for the top triangle in the hour glass and the second character is used for the bottom triangle in the hour glass. The number of characters in the top line of the pattern and in the bottom line of the pattern (i.e. the biggest lines for each of the characters) is n. The indent parameter represents the indentation used in the first line of the pattern and in the last line of the pattern. The indentation increases in the top triangle (using the first character) and decreases in the bottom triangle (using the second character). If n is 0 or negative or one of the characters is the empty string, the function doesn't print anything. You should assume that the indent parameter will be non-negative (i.e. >= 0). The following shows several examples of patterns using different characters, values of n, and amount of indentation. Write a recursive function recLTriangle() that takes two characters and two integers n and indent as parameters and prints an indented triangle pattern that represents half of an hour glass pattern using the characters. The first character is used for the top left-angled triangle in the pattern and the second character is used for the bottom left-angled triangle in the pattern. The number of characters in the top line of the pattern and in the bottom line of the pattern (i.e. the biggest lines for each of the characters) is n. The indent parameter represents the indentation used in the first line of the pattern and in the last line of the pattern. The indentation increases in the top triangle (using the first character) and decreases in the bottom triangle (using the second character). IF one of the characters is empty, blank lines are shown for that portion of the pattern. If n is 0 or negative, the function doesn't print anything. You should assume that the indent parameter will be non-negative (i.e. >= 0). The following shows several examples of patterns using different characters, values of n, and amount of indentation: Write a recursive function recLetterCount() that takes a one-dimensional list as a parameter and returns the number of string that are found in the list that contain a particular letter. Recall that you can determine whether an item is a string by writing type(item) == str. The only list functions you are allowed to use are len(), indexing (lst[i] for an integer i), or slicing (lst[i:j] for integers i and j). In particular, the function should not in any way alter the list passed as a parameter. The following shows several sample runs of the function: 4. Write a recursive function recStringMerge() that takes in two strings and merges them into one. The only string functions you are allowed to use are len(), indexing (str[i] for an integer i), or slicing (str[i:j] for integers i and j).

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

def recHourGlass(f,s,n,i):
    'f is first character, s is second character, n is number of characters and i is indentation'
    if f == "" or s == "" or n <= 0:
       return
    print(" " *...

By purchasing this solution you'll be able to access the following files:
Solution.py and OUTPUT1.png.

$60.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats