Question: Question # 1 Using Python's string capabilities, loops, and built - in functions, write the code for a Python user - defined function that removes

Question #1
Using Python's string capabilities, loops, and built-in functions,
write the code for a Python user-defined function that removes all characters
from a string except digit characters.
The function returns the resultant string.
The function prototype MUST be: def digits_only(s)
See table below for examples of the original and resultant strings.
Original (s):
"how many seas are there? 7""7"
"In 1990 Guido Van Rossum invented Python!" "1990"
"no digits in this string"
"who is the #1 team in the nhl in 2024?""12024"
Question #2
Using Python's string capabilities, loops, lists, and built-in functions,
write the code for a Python user-defined function that displays
'n' rows of a Fibonacci sequence!
The function prototype MUST be: def draw_fibonacci(n)
A Fibonacci sequence begins with the values and 1 and each subsequent
term in the sequence is comprised of the sum of the 2 previous terms.
Each new value to display is separated from the previous value by a space and
then the expression "ratio: n.xxxxxx"(where n.) represents the the ratio
of the last term divided by the second last term.
NOTE: Be careful of division by zero on the first term!
For example, a 9 row Fibonacci sequence would be:
0 ratio: 0.000000
01 ratio: 0.000000
11 ratio 1.000000
01112 ratio: 2.000000
11123 ratio: 1.500000
0111235 ratio: 1.666667
0111212358 ratio: 1.600000
0111223581321 ratio: 1.615385

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!