TORONTO KIDS COMPUTER CLUB | PMCA Saturday 18:30 Python Homework 22.03.26.
20488
post-template-default,single,single-post,postid-20488,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

PMCA Saturday 18:30 Python Homework 22.03.26.

31 Mar PMCA Saturday 18:30 Python Homework 22.03.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.