Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 7.) Use the Design Recipe to write a function countW , which takes in a string as an argument that counts the number of

Question 7.)

Use the Design Recipe to write a function countW, which takes in a string as an argument that counts the number of occurrence of the character "W" in the given string.

Question 8.)

Use the Design Recipe to define a function count_vowels that returns the number of vowels in a given string argument. For these purposes, the vowels are a, e, i, o, and u, but never y. Note: count both upper and lower-case vowels!

For example:

Test Result
print(count_vowels(' "The people who are crazy enough to think they can change the world are the ones who do." Steve Jobs'))

Question 9.)

Use the Design Recipe to write a function called largest_digit which consumes a string and returns the largest digit in the string as an int or None if there are no digits in the string. None is a keyword and type that can be returned (much like True or False).

Hint: You will need to check to see if a character is a numerical digit...try looking here: https://docs.python.org/3/library/stdtypes.html#string-methods

For example:

Test Result
print(type(largest_digit("the")))
print(largest_digit("Cisc106")) 6

Question 10.)

Use the Design Recipe to define a function interleave that takes two strings as arguments. Return a string which is the two arguments interleaved together, i.e., the first character of the first string followed by the first character of the second string followed by the second character of the first string, etc.

Note: the arguments need not be of the same length! If one runs out, then append the rest of the other argument to the returned value.

For example:

Test Result
print(interleave("hat","cat")) hcaatt
print(interleave("clubs","foxes")) cflouxbess
print(interleave("pancakes","fred")) pfarnecdakes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions