TORONTO KIDS COMPUTER CLUB | Monday 20:00 Python Practice 21.05.24.
19512
post-template-default,single,single-post,postid-19512,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Monday 20:00 Python Practice 21.05.24.

26 May Monday 20:00 Python Practice 21.05.24.

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

Post A Comment