Question
PYTHON 3 - please show format Question 7.) Use the Design Recipe to write a function countW , which takes in a string as an
PYTHON 3 - please show format
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
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