TORONTO KIDS COMPUTER CLUB | Friday 17:00 Python Practice 21.02.26.
19115
post-template-default,single,single-post,postid-19115,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Friday 17:00 Python Practice 21.02.26.

03 Mar Friday 17:00 Python Practice 21.02.26.

Question 1:
Use recursion to write a function has_digit  that consumes a string and produces True  if the string contains a digit (0 through 9) and False  otherwise.

Hints:

    • Make sure that you have a base case.
    • Make sure to use the function on a shorter string.
    • Before calling the function, first check to see if the string is empty or if the first character is a digit.

Question 2:
Use recursion to write a function is_sorted  that consumes a list of numbers and produces True if the items in the list appear in sorted order and False  otherwise. A list of length zero or one is always in sorted order.

Hints:

    • Make sure that you have a base case.
    • Make sure to use the function on a shorter list.
    • Before calling the function, first check to see if the list is of length zero or one or if the first number is larger than the second number.

No Comments

Sorry, the comment form is closed at this time.