# Python Programming Problems

## Question

1. Write the recursive function skipping(n) that takes an integer greater or equal to 0 and returns an integer that represents the sum of every other integer between n and 0 (inclusive)
>>> skipping(11) # 11 + 9 + 7 + 5 + 3 + 1 + 0
36

2. Write the recursive function fortyFives(n) that takes an integer greater or equal to 0 and returns an integer that represents the number of times that a 5 directly follows a 4 in the digits of n. You are not allowed to cast the integer into a string to slice portions of the number. Hint: Using floor division (//) and modulo(%) operations could be helpful here.
>>> fortyFives(145445601)
2

3. Write the recursive function flat(aList) that takes a possibly deep list and flattens it. The function should not mutate the original list. Hint: you can check if something is a list by using the built-in functions type() or isinstance()
>>> x = [3, [[5, 2]], 6, [4]]
>>> flat(x)
[3, 5, 2, 6, 4]
>>> x
[3, [[5, 2]], 6, [4]]

4. Write the recursive function missedChar(txt1, txt2) that takes two strings, txt1 and txt2, where txt1 is a substring of txt2, this means, all characters in txt1 appear in txt2 in the same order, but not necessarily all together, so txt1 is shorter than txt2. The function returns a string that contains the characters you need to add to txt1 to get txt2. The characters in the output string should be in the order you have to add them from left to right. If there are multiple characters in txt2 that could correspond to characters in txt1, use the leftmost one. For example, if txt1 = 'cop' and txt2 = 'conception', then the function should return 'ncetion', not 'cnetion' because the first 'c' in 'cop' corresponds to the first 'c' in 'conception'. Hint: Slicing could be helpful here.
>>> missedChar('at','treatise')
'treise' # We need to add these characters to 'at' to get 'treatise'

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

def skipping(n):
'''
>>> skipping(4)
6
>>> skipping(6)
12
>>> skipping(11)
36
'''
# if n is 0, return 0
if n <= 0:
return 0
else:
return n + skipping(n - 2)...
\$38.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.